Enable ipv6 tests (#1204)

This commit is contained in:
Egon Elbre 2019-02-06 14:47:00 +02:00 committed by GitHub
parent fdbe2db273
commit 60b0275a44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 11 deletions

View File

@ -138,6 +138,9 @@ func newNetwork(flags *Flags) (*Processes, error) {
},
"run": {},
})
bootstrap.ExecBefore["run"] = func(process *Process) error {
return readConfigString(&bootstrap.Address, bootstrap.Directory, "server.address")
}
// Create satellites making all satellites wait for bootstrap to start
var satellites []*Process
@ -165,10 +168,15 @@ func newNetwork(flags *Flags) (*Processes, error) {
},
"run": {},
})
process.ExecBefore["run"] = func(process *Process) error {
return readConfigString(&process.Address, process.Directory, "server.address")
}
}
// Create gateways for each satellite
for i, satellite := range satellites {
satellite := satellite
process := processes.New(Info{
Name: fmt.Sprintf("gateway/%d", i),
Executable: "gateway",
@ -199,6 +207,11 @@ func newNetwork(flags *Flags) (*Processes, error) {
})
process.ExecBefore["run"] = func(process *Process) error {
err := readConfigString(&process.Address, process.Directory, "server.address")
if err != nil {
return err
}
vip := viper.New()
vip.AddConfigPath(process.Directory)
if err := vip.ReadInConfig(); err != nil {
@ -212,14 +225,18 @@ func newNetwork(flags *Flags) (*Processes, error) {
// so that gateway can have access to the satellite
apiKey := vip.GetString("client.api-key")
if apiKey == "" {
consoleAddress := fmt.Sprintf(
"http://%s/api/graphql/v0",
net.JoinHostPort(host, strconv.Itoa(consolePort+i)))
var consoleAddress string
satelliteConfigErr := readConfigString(&consoleAddress, satellite.Directory, "console.address")
if satelliteConfigErr != nil {
return satelliteConfigErr
}
consoleAPIAddress := "http://" + consoleAddress + "/api/graphql/v0"
// wait for console server to start
time.Sleep(3 * time.Second)
if err := addExampleProjectWithKey(&apiKey, consoleAddress); err != nil {
if err := addExampleProjectWithKey(&apiKey, consoleAPIAddress); err != nil {
return err
}
@ -265,6 +282,10 @@ func newNetwork(flags *Flags) (*Processes, error) {
},
"run": {},
})
process.ExecBefore["run"] = func(process *Process) error {
return readConfigString(&process.Address, process.Directory, "server.address")
}
}
{ // verify that we have all binaries
@ -325,3 +346,16 @@ func identitySetup(network *Processes) (*Processes, error) {
return processes, nil
}
// readConfigString reads from dir/config.yaml flagName returns the value in `into`
func readConfigString(into *string, dir, flagName string) error {
vip := viper.New()
vip.AddConfigPath(dir)
if err := vip.ReadInConfig(); err != nil {
return err
}
if v := vip.GetString(flagName); v != "" {
*into = v
}
return nil
}

View File

@ -1,5 +1,6 @@
#!/bin/bash
set -ueo pipefail
set +x
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
@ -12,7 +13,7 @@ cleanup(){
}
trap cleanup EXIT
export STORJ_LOCAL_NETWORK=$TMP
export STORJ_NETWORK_DIR=$TMP
# setup the network
storj-sim -x network setup
@ -21,9 +22,10 @@ storj-sim -x network setup
storj-sim -x network test bash $SCRIPTDIR/test-sim-aws.sh
storj-sim -x network destroy
# ipv6 tests disabled because aws-cli doesn't seem to support connecting to ipv6 host
# # setup the network with ipv6
# storj-sim -x --host "::1" network setup
# # run aws-cli tests using ipv6
# storj-sim -x --host "::1" network test bash $SCRIPTDIR/test-storj-sim-aws.sh
# storj-sim -x network destroy
# setup the network with ipv6
storj-sim -x --host "::1" network setup
# aws-cli doesn't support gateway with ipv6 address, so change it to use localhost
find $STORJ_NETWORK_DIR/gateway -type f -name config.yaml -exec sed -i "s/server.address: \"\[::1\]/server.address: \"127.0.0.1/" {} +
# run aws-cli tests using ipv6
storj-sim -x --host "::1" network test bash $SCRIPTDIR/test-sim-aws.sh
storj-sim -x network destroy