From 93f3650cf8015e0043c769d5187eb67b4e2ffbc6 Mon Sep 17 00:00:00 2001 From: Moby von Briesen Date: Tue, 7 Jan 2020 12:06:59 -0500 Subject: [PATCH] ci: add build number to postgres and redis docker containers for versions and rolling upgrade tests If the containers are just named `postgres` and `redis`, we run into build issues when the master branch and a release branch are building simultaneously. This change fixes that. Change-Id: Ibd49a0369900ab4865a4cdc6d6c89991cb7f044f --- Jenkinsfile | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c9df05acb..0861c01c3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,25 +18,27 @@ node('node') { echo "STORJ_SIM_POSTGRES: $STORJ_SIM_POSTGRES" echo "STORJ_SIM_REDIS: $STORJ_SIM_REDIS" - sh 'docker run --rm -d --name postgres postgres:9.6' - sh 'docker run --rm -d --name redis redis:latest' + sh 'docker run --rm -d --name postgres-$BUILD_NUMBER postgres:9.6' + sh 'docker run --rm -d --name redis-$BUILD_NUMBER redis:latest' - sh '''until $(docker logs postgres | grep "database system is ready to accept connections" > /dev/null) + 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 createdb -U postgres teststorj' + 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/testversions/test-sim-versions.sh -e STORJ_SIM_POSTGRES -e STORJ_SIM_REDIS --link redis:redis --link postgres:postgres -e CC=gcc storjlabs/golang:1.13.5' + 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 -e CC=gcc storjlabs/golang:1.13.5' } catch(err){ throw err } finally { - sh 'docker stop postgres || true' - sh 'docker stop redis || true' + 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' } } @@ -49,25 +51,27 @@ node('node') { echo "STORJ_SIM_POSTGRES: $STORJ_SIM_POSTGRES" echo "STORJ_SIM_REDIS: $STORJ_SIM_REDIS" - sh 'docker run --rm -d --name postgres postgres:9.6' - sh 'docker run --rm -d --name redis redis:latest' + sh 'docker run --rm -d --name postgres-$BUILD_NUMBER postgres:9.6' + sh 'docker run --rm -d --name redis-$BUILD_NUMBER redis:latest' - sh '''until $(docker logs postgres | grep "database system is ready to accept connections" > /dev/null) + 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 createdb -U postgres teststorj' + 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:redis --link postgres:postgres -e CC=gcc storjlabs/golang:1.13.5' + 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.13.5' } catch(err){ throw err } finally { - sh 'docker stop postgres || true' - sh 'docker stop redis || true' + 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' } }