scripts/tests: fix gateway tests
Change-Id: I9a23ef08794043ad615066ae5929df9ff3a02d69
This commit is contained in:
parent
92a2be2abd
commit
99c88efbbf
2
Makefile
2
Makefile
@ -88,7 +88,7 @@ install-sim: ## install storj-sim
|
||||
## install exact version of storj/gateway
|
||||
mkdir -p .build/gateway-tmp
|
||||
-cd .build/gateway-tmp && go mod init gatewaybuild
|
||||
cd .build/gateway-tmp && go mod edit -replace github.com/minio/minio=github.com/storj/minio@storj && GO111MODULE=on go get storj.io/gateway@master
|
||||
cd .build/gateway-tmp && GO111MODULE=on go get storj.io/gateway@latest
|
||||
|
||||
##@ Test
|
||||
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -41,6 +40,10 @@ const (
|
||||
folderPermissions = 0744
|
||||
)
|
||||
|
||||
var (
|
||||
defaultAccess = "17jgVrPRktsquJQFzpT533WHmZnF6QDkuv8w3Ry5XPzAkh3vj7D1dbJ5MatQRiyRE2ZEiA1Y6fYnhoWqr2n7VgycdXSUPz1QzhthBsHqGXCrRcjSp8RbbVE1VJqDej9nLgB5YDPh3Q5JrVjQeMe9saHAL5rE5tUYJAeynVdre8HeTJMXcwau5"
|
||||
)
|
||||
|
||||
const (
|
||||
// The following values of peer class and endpoints are used
|
||||
// to create a port with a consistent format for storj-sim services.
|
||||
@ -434,7 +437,6 @@ func newNetwork(flags *Flags) (*Processes, error) {
|
||||
|
||||
// Create gateways for each satellite
|
||||
for i, satellite := range satellites {
|
||||
i := i
|
||||
satellite := satellite
|
||||
process := processes.New(Info{
|
||||
Name: fmt.Sprintf("gateway/%d", i),
|
||||
@ -446,9 +448,15 @@ func newNetwork(flags *Flags) (*Processes, error) {
|
||||
// gateway must wait for the corresponding satellite to start up
|
||||
process.WaitForStart(satellite)
|
||||
|
||||
accessData := defaultAccess
|
||||
|
||||
process.Arguments = withCommon(process.Directory, Arguments{
|
||||
"setup": {
|
||||
"--non-interactive",
|
||||
|
||||
"--access", accessData,
|
||||
"--server.address", process.Address,
|
||||
|
||||
"--debug.addr", net.JoinHostPort(host, port(gatewayPeer, i, debugHTTP)),
|
||||
},
|
||||
|
||||
@ -461,8 +469,20 @@ func newNetwork(flags *Flags) (*Processes, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
vip := viper.New()
|
||||
vip.AddConfigPath(process.Directory)
|
||||
if err := vip.ReadInConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: maybe all the config flags should be exposed for all processes?
|
||||
|
||||
// check if gateway config has an api key, if it's not
|
||||
// create example project with key and add it to the config
|
||||
// so that gateway can have access to the satellite
|
||||
if runAccessData := vip.GetString("access"); !flags.OnlyEnv && runAccessData == accessData {
|
||||
var consoleAddress string
|
||||
err = readConfigString(&consoleAddress, satellite.Directory, "console.address")
|
||||
err := readConfigString(&consoleAddress, satellite.Directory, "console.address")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -472,8 +492,7 @@ func newNetwork(flags *Flags) (*Processes, error) {
|
||||
for apiKey == "" {
|
||||
apiKey, err = newConsoleEndpoints(consoleAddress).createOrGetAPIKey()
|
||||
if err != nil && time.Since(start) > 3*time.Second {
|
||||
log.Printf("Failed retrieving GATEWAY_%d_ACCESS: %s\n", i, err.Error())
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
@ -496,7 +515,19 @@ func newNetwork(flags *Flags) (*Processes, error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
process.AddExtra("ACCESS", accessData)
|
||||
vip.Set("access", accessData)
|
||||
|
||||
if err := vip.WriteConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if runAccessData := vip.GetString("access"); runAccessData != accessData {
|
||||
process.AddExtra("ACCESS", runAccessData)
|
||||
}
|
||||
|
||||
process.AddExtra("ACCESS_KEY", vip.GetString("minio.access-key"))
|
||||
process.AddExtra("SECRET_KEY", vip.GetString("minio.secret-key"))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ install_sim(){
|
||||
rm -rf .build/gateway-tmp
|
||||
mkdir -p .build/gateway-tmp
|
||||
pushd .build/gateway-tmp
|
||||
go mod init gatewaybuild && go mod edit -replace github.com/minio/minio=github.com/storj/minio@storj && GOBIN=${bin_dir} GO111MODULE=on go get storj.io/gateway@master
|
||||
go mod init gatewaybuild && GOBIN=${bin_dir} GO111MODULE=on go get storj.io/gateway@latest
|
||||
popd
|
||||
fi
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user