From 746cbfc6597fc0b898ab09a37cec0280365f03d0 Mon Sep 17 00:00:00 2001 From: Yingrong Zhao Date: Wed, 21 Oct 2020 13:29:52 -0400 Subject: [PATCH] scripts/tests/rollingupgrade: test current release version on master branch Currently, we are testing previous release version upgrading to latest master on each master build However, this behavior is only desired when the test is running on a release branch. Change-Id: Iaeb66f44951c9e4934ca3c8316d1e490d7958239 --- Jenkinsfile | 2 +- .../test-sim-rolling-upgrade.sh | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d8f4466d0..f246c3141 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -67,7 +67,7 @@ node('node') { sh 'docker exec postgres-$BUILD_NUMBER createdb -U postgres teststorj' // fetch the remote master branch sh 'git fetch --no-tags --progress -- https://github.com/storj/storj.git +refs/heads/master:refs/remotes/origin/master' - sh 'docker run -u $(id -u):$(id -g) --rm -i -v $PWD:$PWD -w $PWD --entrypoint $PWD/scripts/tests/rollingupgrade/test-sim-rolling-upgrade.sh -e STORJ_SIM_POSTGRES -e STORJ_SIM_REDIS --link redis-$BUILD_NUMBER:redis --link postgres-$BUILD_NUMBER:postgres -e CC=gcc storjlabs/golang:1.15.2' + sh 'docker run -u $(id -u):$(id -g) --rm -i -v $PWD:$PWD -w $PWD --entrypoint $PWD/scripts/tests/rollingupgrade/test-sim-rolling-upgrade.sh -e BRANCH_NAME -e STORJ_SIM_POSTGRES -e STORJ_SIM_REDIS --link redis-$BUILD_NUMBER:redis --link postgres-$BUILD_NUMBER:postgres -e CC=gcc storjlabs/golang:1.15.2' } catch(err){ throw err diff --git a/scripts/tests/rollingupgrade/test-sim-rolling-upgrade.sh b/scripts/tests/rollingupgrade/test-sim-rolling-upgrade.sh index 1dcd2b77f..f880bacb4 100755 --- a/scripts/tests/rollingupgrade/test-sim-rolling-upgrade.sh +++ b/scripts/tests/rollingupgrade/test-sim-rolling-upgrade.sh @@ -47,16 +47,23 @@ populate_sno_versions(){ # set peers' versions # in stage 1: satellite, uplink, and storagenode use latest release version # in stage 2: satellite core uses latest release version and satellite api uses master. Storage nodes are split into half on latest release version and half on master. Uplink uses the latest release version plus master +BRANCH_NAME=${BRANCH_NAME:-""} git fetch --tags +# if it's running on a release branch, we will set the stage 1 version to be the latest previous major release +# if it's running on master, we will set the stage 1 version to be the current release version current_commit=$(git rev-parse HEAD) -current_release_version=$(git describe --tags $current_commit | cut -d '.' -f 1-2) -previous_release_version=$(git describe --tags `git rev-list --exclude='*rc*' --exclude=$current_release_version* --tags --max-count=1`) -stage1_sat_version=$previous_release_version -stage1_uplink_version=$previous_release_version -stage1_storagenode_versions=$(populate_sno_versions $previous_release_version 10) +stage1_release_version=$(git tag -l --sort -version:refname | grep -v rc | head -1) +if [[ $BRANCH_NAME = v* ]]; then + current_major_release_version=$(git describe --tags $current_commit | cut -d '.' -f 1-2) + previous_release_version=$(git describe --tags `git rev-list --exclude='*rc*' --exclude=$current_major_release_version* --tags --max-count=1`) + stage1_release_version=$previous_release_version +fi +stage1_sat_version=$stage1_release_version +stage1_uplink_version=$stage1_release_version +stage1_storagenode_versions=$(populate_sno_versions $stage1_release_version 10) stage2_sat_version=$current_commit -stage2_uplink_versions=$previous_release_version\ $current_commit -stage2_storagenode_versions=$(populate_sno_versions $previous_release_version 5)\ $(populate_sno_versions $current_commit 5) +stage2_uplink_versions=$stage1_release_version\ $current_commit +stage2_storagenode_versions=$(populate_sno_versions $stage1_release_version 5)\ $(populate_sno_versions $current_commit 5) echo "stage1_sat_version" $stage1_sat_version echo "stage1_uplink_version" $stage1_uplink_version @@ -201,7 +208,6 @@ for version in ${unique_versions}; do echo -e "\nAdding worktree for ${version} in ${dir}." git worktree add -f "$dir" "${version}" - rm -f ${dir}/private/version/release.go rm -f ${dir}/internal/version/release.go # clear out release information cat > ${dir}/private/version/release.go <<-EOF @@ -210,7 +216,7 @@ for version in ${unique_versions}; do package version EOF - if [[ $version = $previous_release_version || $version = $current_commit ]] + if [[ $version = $stage1_release_version || $version = $current_commit ]] then echo "Installing storj-sim for ${version} in ${dir}." pushd ${dir}