scripts/tests/testversions: fix older uplink setup

This PR does follwing changes:
    1. Change oldest uplink version in the test to v0.35.3
        When the test is first created, we decided to support uplink
        version starting from v0.17.1, however with many API changes,
        older uplinks are not usable with latest version of the network
        anymore. One of the reasons being older uplinks uses deprecated
        endpoint. Therefore, we will change the oldest uplink version to
        the one that's using only new endpoints.
    2. Disable tls certificate verification in uplink
    3. Use storj-sim version control server instead of production one
    4. Skip uplink version v1.3.x due to bug in that release

Change-Id: I926a6bb9829cb7181ee752437cdcb67e59197fe0
This commit is contained in:
Yingrong Zhao 2020-11-11 16:51:49 -05:00
parent 3e56403599
commit 54c5d564a1
2 changed files with 18 additions and 26 deletions

View File

@ -32,7 +32,7 @@ major_release_tags=$(
grep -v rc | # remove release candidates
sort -n -k2,2 -t'.' --unique | # only keep the largest patch version
sort -V | # resort based using "version sort"
awk 'BEGIN{FS="[v.]"} $2 >= 0 && $3 >= 15 || $2 >= 1 {print $0}' # keep only >= v0.15.x and v1.0.0
awk 'BEGIN{FS="[v.]"} $2 >= 0 && $3 >= 35 || $2 >= 1 && $3 != 3 {print $0}' # keep only >= v0.31.x and v1.0.0 except v1.3.x
)
current_release_version=$(echo $major_release_tags | xargs -n 1 | tail -1)
stage1_sat_version=$current_release_version

View File

@ -12,6 +12,18 @@ test_files_dir="${main_cfg_dir}/testfiles"
stage1_dst_dir="${main_cfg_dir}/stage1"
stage2_dst_dir="${main_cfg_dir}/stage2"
replace_in_file(){
local src="$1"
local dest="$2"
local path=$3
case "$OSTYPE" in
darwin*)
sed -i '' "s|# ${src}|${dest}|" "${path}" ;;
*)
sed -i "s|# ${src}|${dest}|" "${path}" ;;
esac
}
setup(){
mkdir -p "$test_files_dir" "$stage1_dst_dir" "$stage2_dst_dir"
random_bytes_file () {
@ -55,32 +67,12 @@ if [ ! -d ${main_cfg_dir}/uplink ]; then
mkdir -p ${main_cfg_dir}/uplink
api_key=$(storj-sim --config-dir=$main_cfg_dir network env GATEWAY_0_API_KEY)
sat_addr=$(storj-sim --config-dir=$main_cfg_dir network env SATELLITE_0_ADDR)
should_use_access=$(echo $uplink_version | awk 'BEGIN{FS="[v.]"} $3 >= 30 || $2 >= 1 {print $0}')
if [[ ${#should_use_access} -gt 0 ]]; then
access=$(storj-sim --config-dir=$main_cfg_dir network env GATEWAY_0_ACCESS)
new_access=$(go run $update_access_script_path $(storj-sim --config-dir=$main_cfg_dir network env SATELLITE_0_DIR) $access)
uplink import --config-dir="${main_cfg_dir}/uplink" "${new_access}"
else
uplink setup --config-dir="${main_cfg_dir}/uplink" --non-interactive --api-key="$api_key" --satellite-addr="$sat_addr" --enc.encryption-key="test"
fi
fi
if [[ $uplink_version = "v0.29.10" ]]; then
uplink share --config-dir="${main_cfg_dir}/uplink" | grep "Scope" | awk -F ": " '{print $2}' | tee ${main_cfg_dir}/uplink/access.txt
fi
# after version v0.30.x we need to use access instead of separate values for api key, sat addr, and encryption key
should_use_access=$(echo $uplink_version | awk 'BEGIN{FS="[v.]"} $3 == 30 {print $0}')
if [[ ${#should_use_access} -gt 0 ]] && [ -e ${main_cfg_dir}/uplink/access.txt ]
then
# the access provided by storj-sim uses an empty encryption key; we cannot do uplink setup above with an empty encryption key
# therefore, we use a hack -> get an access key from the existing uplink config, then import that same access key
# super hack:
access=$(head -n 1 ${main_cfg_dir}/uplink/access.txt)
access=$(storj-sim --config-dir=$main_cfg_dir network env GATEWAY_0_ACCESS)
new_access=$(go run $update_access_script_path $(storj-sim --config-dir=$main_cfg_dir network env SATELLITE_0_DIR) $access)
uplink import --config-dir="${main_cfg_dir}/uplink" "${new_access}"
rm -rf ${main_cfg_dir}/uplink/access.txt
uplink --metrics.addr="" import --config-dir="${main_cfg_dir}/uplink" "${new_access}"
replace_in_file "version.server-address:.*" "version.server-address: http://$(storj-sim --config-dir=$main_cfg_dir network env VERSIONCONTROL_0_ADDR)" ${main_cfg_dir}/uplink/config.yaml
replace_in_file "tls.use-peer-ca-whitelist:.*" "tls.use-peer-ca-whitelist: false" ${main_cfg_dir}/uplink/config.yaml
fi
echo -e "\nConfig directory for satellite:"