cmd/storj-sim: allow overriding executables (#2976)

The backward compatibility test upgrades only half of the storage nodes and
tests with both the release and new uplink.
This commit is contained in:
Egon Elbre 2019-09-09 22:13:38 +03:00 committed by GitHub
parent 1e22f58043
commit 7589ca796f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 9 deletions

View File

@ -192,7 +192,15 @@ func (process *Process) Exec(ctx context.Context, command string) (err error) {
}
}
cmd := exec.CommandContext(ctx, process.Executable, process.Arguments[command]...)
executable := process.Executable
// use executable inside the directory, if it exists
localExecutable := filepath.Join(process.Directory, executable)
if _, err := os.Lstat(localExecutable); !os.IsNotExist(err) {
executable = localExecutable
}
cmd := exec.CommandContext(ctx, executable, process.Arguments[command]...)
cmd.Dir = process.processes.Directory
cmd.Env = append(os.Environ(), "STORJ_LOG_NOTIME=1")

View File

@ -17,12 +17,8 @@ setup(){
}
random_bytes_file 2x1024 "$TEST_FILES_DIR/small-upload-testfile" # create 2kb file of random bytes (inline)
random_bytes_file 5x1024x1024 "$TEST_FILES_DIR/big-upload-testfile" # create 5mb file of random bytes (remote)
echo "setup test successfully"
}
cleanup(){
rm -rf "$STORJ_NETWORK_DIR"
echo "cleaned up test successfully"
echo "setup test successfully"
}
if [[ "$1" == "upload" ]]; then
@ -72,9 +68,10 @@ if [[ "$1" == "download" ]]; then
echo "download test on current branch: big upload testfile does not match uploaded file"
exit 1
fi
fi
if [[ "$1" == "cleanup" ]]; then
uplink --config-dir "$GATEWAY_0_DIR" rm "sj://$BUCKET/small-upload-testfile"
uplink --config-dir "$GATEWAY_0_DIR" rm "sj://$BUCKET/big-upload-testfile"
uplink --config-dir "$GATEWAY_0_DIR" rb "sj://$BUCKET"
cleanup
fi

View File

@ -48,7 +48,27 @@ PATH=$RELEASE_DIR/bin:$PATH storj-sim -x --host $STORJ_NETWORK_HOST4 network --p
PATH=$RELEASE_DIR/bin:$PATH storj-sim -x --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-backwards.sh upload
# this replaces anywhere that has "/release/" in the config file, which currently just renames the static dir paths
sed -i -e 's#/release/#/branch/#g' $STORJ_NETWORK_DIR/satellite/0/config.yaml
sed -i -e 's#/release/#/branch/#g' `storj-sim network env SATELLITE_0_DIR`/config.yaml
## Ensure that partially upgraded network works
# keep half of the storage nodes on the old version
ln $RELEASE_DIR/bin/storagenode `storj-sim network env STORAGENODE_0_DIR`/storagenode
ln $RELEASE_DIR/bin/storagenode `storj-sim network env STORAGENODE_1_DIR`/storagenode
ln $RELEASE_DIR/bin/storagenode `storj-sim network env STORAGENODE_2_DIR`/storagenode
ln $RELEASE_DIR/bin/storagenode `storj-sim network env STORAGENODE_3_DIR`/storagenode
ln $RELEASE_DIR/bin/storagenode `storj-sim network env STORAGENODE_4_DIR`/storagenode
# run download part of backward compatibility tests from the current branch, using new uplink
PATH=$BRANCH_DIR/bin:$PATH storj-sim -x --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-backwards.sh download
## Ensure that old uplink works
# overwrite new uplink with release branch and test the download
cp $RELEASE_DIR/bin/uplink $BRANCH_DIR/bin/uplink
# run download part of backward compatibility tests from the current branch
PATH=$BRANCH_DIR/bin:$PATH storj-sim -x --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-backwards.sh download
PATH=$BRANCH_DIR/bin:$PATH storj-sim -x --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-backwards.sh download
# run a delete in the network
PATH=$BRANCH_DIR/bin:$PATH storj-sim -x --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-backwards.sh cleanup