From b699f05f47fa4e7499ad7d067d14ae7d32c6af01 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Tue, 9 Jan 2024 10:25:10 +1000 Subject: [PATCH] Run integration tests in parallel --- Jenkinsfile | 99 +++++++++++++++++++----------------- docker/docker-compose.ci.yml | 18 ++++--- 2 files changed, 61 insertions(+), 56 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bdbb3f6..e047572 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -100,59 +100,62 @@ pipeline { } } } - stage('Integration Tests Sqlite') { - steps { - // Bring up a stack - sh 'docker-compose up -d fullstack-sqlite' - sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-sqlite) 120' - // Stop and Start it, as this will test it's ability to restart with existing data - sh 'docker-compose stop fullstack-sqlite' - sh 'docker-compose start fullstack-sqlite' - sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-sqlite) 120' + stage('Integration Tests') { + parallel { + stage('Sqlite') { + steps { + // Bring up a stack + sh 'docker-compose up -d fullstack-sqlite' + sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-sqlite) 120' + // Stop and Start it, as this will test it's ability to restart with existing data + sh 'docker-compose stop fullstack-sqlite' + sh 'docker-compose start fullstack-sqlite' + sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-sqlite) 120' - // Run tests - sh 'rm -rf test/results' - sh 'docker-compose up cypress-sqlite' - // Get results - sh 'docker cp -L "$(docker-compose ps --all -q cypress-sqlite):/test/results" test/' - } - post { - always { - // Dumps to analyze later - sh 'mkdir -p debug' - sh 'docker-compose logs fullstack-sqlite > debug/docker_fullstack_sqlite.log' - sh 'docker-compose logs db > debug/docker_db.log' - // Cypress videos and screenshot artifacts - dir(path: 'test/results') { - archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml' + // Run tests + sh 'rm -rf test/results-sqlite' + sh 'docker-compose up cypress-sqlite' + // Get results + sh 'docker cp -L "$(docker-compose ps --all -q cypress-sqlite):/test/results" test/results-sqlite' + } + post { + always { + // Dumps to analyze later + sh 'mkdir -p debug/sqlite' + sh 'docker-compose logs fullstack-sqlite > debug/sqlite/docker_fullstack_sqlite.log' + // Cypress videos and screenshot artifacts + dir(path: 'test/results-sqlite') { + archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml' + } + junit 'test/results-sqlite/junit/*' + } } - junit 'test/results/junit/*' } - } - } - stage('Integration Tests Mysql') { - steps { - // Bring up a stack - sh 'docker-compose up -d fullstack-mysql' - sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-mysql) 120' + stage('Mysql') { + steps { + // Bring up a stack + sh 'docker-compose up -d fullstack-mysql' + sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-mysql) 120' - // Run tests - sh 'rm -rf test/results' - sh 'docker-compose up cypress-mysql' - // Get results - sh 'docker cp -L "$(docker-compose ps --all -q cypress-mysql):/test/results" test/' - } - post { - always { - // Dumps to analyze later - sh 'mkdir -p debug' - sh 'docker-compose logs fullstack-mysql > debug/docker_fullstack_mysql.log' - sh 'docker-compose logs db > debug/docker_db.log' - // Cypress videos and screenshot artifacts - dir(path: 'test/results') { - archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml' + // Run tests + sh 'rm -rf test/results-mysql' + sh 'docker-compose up cypress-mysql' + // Get results + sh 'docker cp -L "$(docker-compose ps --all -q cypress-mysql):/test/results" test/results-mysql' + } + post { + always { + // Dumps to analyze later + sh 'mkdir -p debug/mysql' + sh 'docker-compose logs fullstack-mysql > debug/mysql/docker_fullstack_mysql.log' + sh 'docker-compose logs db > debug/mysql/docker_db.log' + // Cypress videos and screenshot artifacts + dir(path: 'test/results-mysql') { + archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml' + } + junit 'test/results-mysql/junit/*' + } } - junit 'test/results/junit/*' } } } diff --git a/docker/docker-compose.ci.yml b/docker/docker-compose.ci.yml index 209d2d0..66e240d 100644 --- a/docker/docker-compose.ci.yml +++ b/docker/docker-compose.ci.yml @@ -14,7 +14,7 @@ services: DB_MYSQL_PASSWORD: 'npm' DB_MYSQL_NAME: 'npm' volumes: - - npm_data:/data + - npm_data_mysql:/data expose: - 81 - 80 @@ -37,7 +37,7 @@ services: PGID: 1000 DISABLE_IPV6: 'true' volumes: - - npm_data:/data + - npm_data_sqlite:/data expose: - 81 - 80 @@ -55,7 +55,7 @@ services: MYSQL_USER: 'npm' MYSQL_PASSWORD: 'npm' volumes: - - db_data:/var/lib/mysql + - mysql_data:/var/lib/mysql cypress-mysql: image: "${IMAGE}-cypress:ci-${BUILD_NUMBER}" @@ -65,7 +65,7 @@ services: environment: CYPRESS_baseUrl: 'http://fullstack-mysql:81' volumes: - - cypress-logs:/results + - cypress_logs_mysql:/results command: cypress run --browser chrome --config-file=${CYPRESS_CONFIG:-cypress/config/ci.json} cypress-sqlite: @@ -76,10 +76,12 @@ services: environment: CYPRESS_baseUrl: "http://fullstack-sqlite:81" volumes: - - cypress-logs:/results + - cypress_logs_sqlite:/results command: cypress run --browser chrome --config-file=${CYPRESS_CONFIG:-cypress/config/ci.json} volumes: - cypress-logs: - npm_data: - db_data: + cypress_logs_mysql: + cypress_logs_sqlite: + npm_data_mysql: + npm_data_sqlite: + mysql_data: