Skip to content

Commit

Permalink
build: move Run Versions test to a separated job
Browse files Browse the repository at this point in the history
Run Versions test is intermittent and slow.

We need to rewrite it with storj-up, preferable with a container where
 old versions are cached, instead of rebuilding them everytime
 (which is -- IMHO -- the root cause of the intermittency).

As we discussed on the chat, we can separate the runs, until we prioritize this work.

Change-Id: I7fdf6fdb20625fd76d6334be0d0afe72af1b734a
  • Loading branch information
elek authored and Storj Robot committed Nov 21, 2023
1 parent 51ba901 commit 7c25e37
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 35 deletions.
35 changes: 0 additions & 35 deletions Jenkinsfile
Expand Up @@ -10,41 +10,6 @@ node('node') {

echo "Current build result: ${currentBuild.result}"
}
if (env.BRANCH_NAME == "main") {
stage('Run Versions Test') {
lastStage = env.STAGE_NAME
try {
echo "Running Versions test"

env.STORJ_SIM_POSTGRES = 'postgres://postgres@postgres:5432/teststorj?sslmode=disable'
env.STORJ_SIM_REDIS = 'redis:6379'

echo "STORJ_SIM_POSTGRES: $STORJ_SIM_POSTGRES"
echo "STORJ_SIM_REDIS: $STORJ_SIM_REDIS"
sh 'docker run --rm -d -e POSTGRES_HOST_AUTH_METHOD=trust --name postgres-$BUILD_NUMBER postgres:12.3'
sh 'docker run --rm -d --name redis-$BUILD_NUMBER redis:latest'

sh '''until $(docker logs postgres-$BUILD_NUMBER | grep "database system is ready to accept connections" > /dev/null)
do printf '.'
sleep 5
done
'''
sh 'docker exec postgres-$BUILD_NUMBER createdb -U postgres teststorj'
// fetch the remote main branch
sh 'git fetch --no-tags --progress -- https://github.com/storj/storj.git +refs/heads/main:refs/remotes/origin/main'
sh 'docker run -u $(id -u):$(id -g) --rm -i -v $PWD:$PWD -w $PWD --entrypoint $PWD/scripts/tests/testversions/test-sim-versions.sh -e STORJ_SIM_POSTGRES -e STORJ_SIM_REDIS --link redis-$BUILD_NUMBER:redis --link postgres-$BUILD_NUMBER:postgres storjlabs/golang:1.21.3'
}
catch(err){
throw err
}
finally {
sh 'docker stop postgres-$BUILD_NUMBER || true'
sh 'docker rm postgres-$BUILD_NUMBER || true'
sh 'docker stop redis-$BUILD_NUMBER || true'
sh 'docker rm redis-$BUILD_NUMBER || true'
}
}
}

stage('Run Rolling Upgrade Test') {
lastStage = env.STAGE_NAME
Expand Down
64 changes: 64 additions & 0 deletions Jenkinsfile.versions
@@ -0,0 +1,64 @@
def lastStage = ''
node('node') {
properties([disableConcurrentBuilds()])
try {
currentBuild.result = "SUCCESS"

stage('Checkout') {
lastStage = env.STAGE_NAME
checkout scm

echo "Current build result: ${currentBuild.result}"
}

stage('Run Versions Test') {
lastStage = env.STAGE_NAME
try {
echo "Running Versions test"

env.STORJ_SIM_POSTGRES = 'postgres://postgres@postgres:5432/teststorj?sslmode=disable'
env.STORJ_SIM_REDIS = 'redis:6379'

echo "STORJ_SIM_POSTGRES: $STORJ_SIM_POSTGRES"
echo "STORJ_SIM_REDIS: $STORJ_SIM_REDIS"
sh 'docker run --rm -d -e POSTGRES_HOST_AUTH_METHOD=trust --name postgres-$BUILD_NUMBER postgres:12.3'
sh 'docker run --rm -d --name redis-$BUILD_NUMBER redis:latest'

sh '''until $(docker logs postgres-$BUILD_NUMBER | grep "database system is ready to accept connections" > /dev/null)
do printf '.'
sleep 5
done
'''
sh 'docker exec postgres-$BUILD_NUMBER createdb -U postgres teststorj'
// fetch the remote main branch
sh 'git fetch --no-tags --progress -- https://github.com/storj/storj.git +refs/heads/main:refs/remotes/origin/main'
sh 'docker run -u $(id -u):$(id -g) --rm -i -v $PWD:$PWD -w $PWD --entrypoint $PWD/scripts/tests/testversions/test-sim-versions.sh -e STORJ_SIM_POSTGRES -e STORJ_SIM_REDIS --link redis-$BUILD_NUMBER:redis --link postgres-$BUILD_NUMBER:postgres storjlabs/golang:1.21.3'
}
catch(err){
throw err
}
finally {
sh 'docker stop postgres-$BUILD_NUMBER || true'
sh 'docker rm postgres-$BUILD_NUMBER || true'
sh 'docker stop redis-$BUILD_NUMBER || true'
sh 'docker rm redis-$BUILD_NUMBER || true'
}
}
}
catch (err) {
echo "Caught errors! ${err}"
echo "Setting build result to FAILURE"
currentBuild.result = "FAILURE"

slackSend color: 'danger', message: "@build-team ${env.BRANCH_NAME} build failed during stage ${lastStage} ${env.BUILD_URL}"

throw err

}
finally {
stage('Cleanup') {
deleteDir()
}

}
}

0 comments on commit 7c25e37

Please sign in to comment.