scripts/tests/testversions: fix installation during setup

This PR fixes below issues:
1. remove concurrent installation for various versions
    We were doing this to decrease the amount of execution time the versions test.
    However, it's returning incorrect exit code when there's an
    installation failure.
    Right now, we are only installing two versions of `storj-sim` and
    the rest are only doing uplink cli installation. The performance of
    this test should be hugely impacted by the setup step now.
2. only remove release settings instead of deleting the entire file
    uplink CLI is referrencing `private/version` package. Therefore, we
    cannot delete it
3. add back `GATEWAY_0_API_KEY` in storj-sim
    In order to set up older version of uplink cli, we need access to
    the gate way api key.

Change-Id: Ia3c37c197bd007b6e1f7c2bd71adde42181d46f0
This commit is contained in:
Yingrong Zhao 2020-10-16 12:01:28 -04:00 committed by Yingrong Zhao
parent 2ce3170bb4
commit 8fd841b910
2 changed files with 30 additions and 18 deletions

View File

@ -20,12 +20,14 @@ import (
"time"
"github.com/alessio/shellescape"
"github.com/btcsuite/btcutil/base58"
"github.com/spf13/viper"
"github.com/zeebo/errs"
"golang.org/x/sync/errgroup"
"storj.io/common/fpath"
"storj.io/common/identity"
"storj.io/common/pb"
"storj.io/common/processgroup"
"storj.io/common/storj"
"storj.io/storj/private/dbutil"
@ -524,6 +526,10 @@ func newNetwork(flags *Flags) (*Processes, error) {
if runAccessData := vip.GetString("access"); runAccessData != accessData {
process.AddExtra("ACCESS", runAccessData)
if apiKey, err := getAPIKey(runAccessData); err == nil {
process.AddExtra("API_KEY", apiKey)
}
}
process.AddExtra("ACCESS_KEY", vip.GetString("minio.access-key"))
@ -667,6 +673,22 @@ func identitySetup(network *Processes) (*Processes, error) {
return processes, nil
}
// getAPIKey parses an access string to return its corresponding api key.
func getAPIKey(access string) (apiKey string, err error) {
data, version, err := base58.CheckDecode(access)
if err != nil || version != 0 {
return "", errors.New("invalid access grant format")
}
p := new(pb.Scope)
if err := pb.Unmarshal(data, p); err != nil {
return "", err
}
apiKey = base58.CheckEncode(p.ApiKey, 0)
return apiKey, nil
}
// readConfigString reads from dir/config.yaml flagName returns the value in `into`.
func readConfigString(into *string, dir, flagName string) error {
vip := viper.New()

View File

@ -96,7 +96,7 @@ install_sim(){
rm -rf .build/gateway-tmp
mkdir -p .build/gateway-tmp
pushd .build/gateway-tmp
go mod init gatewaybuild && GOBIN=${bin_dir} GO111MODULE=on go get storj.io/gateway@v1.0.0-rc.8
go mod init gatewaybuild && GOBIN=${bin_dir} GO111MODULE=on go get storj.io/gateway@latest
popd
fi
}
@ -168,8 +168,6 @@ echo "Setting up environments for versions" ${unique_versions}
# clean up git worktree
git worktree prune
for version in ${unique_versions}; do
# run in parallel
(
dir=$(version_dir ${version})
bin_dir=${dir}/bin
@ -180,23 +178,26 @@ for version in ${unique_versions}; do
else
git worktree add -f "$dir" "${version}"
fi
rm -f ${dir}/private/version/release.go
rm -f ${dir}/internal/version/release.go
if [[ $version = $current_release_version || $version = "master" ]]
then
if [ -d "${dir}/private/version/release.go" ]; then
# clear out release information
cat > ${dir}/private/version/release.go <<-EOF
// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
package version
EOF
fi
if [[ $version = $current_release_version || $version = "master" ]]
then
echo "Installing storj-sim for ${version} in ${dir}."
install_sim ${dir} ${bin_dir}
echo "finished installing"
echo "Setting up storj-sim for ${version}. Bin: ${bin_dir}, Config: ${dir}/local-network"
PATH=${bin_dir}:$PATH storj-sim -x --host="${STORJ_NETWORK_HOST4}" --postgres="${STORJ_SIM_POSTGRES}" --config-dir "${dir}/local-network" network setup > /dev/null 2>&1
PATH=${bin_dir}:$PATH storj-sim -x --host="${STORJ_NETWORK_HOST4}" --postgres="${STORJ_SIM_POSTGRES}" --config-dir "${dir}/local-network" network setup >/dev/null 2>&1
echo "Finished setting up. ${dir}/local-network:" $(ls ${dir}/local-network)
echo "Binary shasums:"
shasum ${bin_dir}/satellite
@ -215,17 +216,6 @@ for version in ${unique_versions}; do
echo "Binary shasums:"
shasum ${bin_dir}/uplink
fi
) &
done
for job in `jobs -p`
do
echo "wait for $job"
RESULT=0
wait $job || RESULT=1
if [ "$RESULT" == "1" ]; then
exit $?
fi
done
# Use stage 1 satellite version as the starting state. Create a cp of that