Run integration tests in parallel

This commit is contained in:
Jamie Curnow 2024-01-09 10:25:10 +10:00
parent f7c87f63bd
commit b699f05f47
No known key found for this signature in database
GPG Key ID: FFBB624C43388E9E
2 changed files with 61 additions and 56 deletions

99
Jenkinsfile vendored
View File

@ -100,59 +100,62 @@ pipeline {
} }
} }
} }
stage('Integration Tests Sqlite') { stage('Integration Tests') {
steps { parallel {
// Bring up a stack stage('Sqlite') {
sh 'docker-compose up -d fullstack-sqlite' steps {
sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-sqlite) 120' // Bring up a stack
// Stop and Start it, as this will test it's ability to restart with existing data sh 'docker-compose up -d fullstack-sqlite'
sh 'docker-compose stop fullstack-sqlite' sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-sqlite) 120'
sh 'docker-compose start fullstack-sqlite' // Stop and Start it, as this will test it's ability to restart with existing data
sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-sqlite) 120' 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 // Run tests
sh 'rm -rf test/results' sh 'rm -rf test/results-sqlite'
sh 'docker-compose up cypress-sqlite' sh 'docker-compose up cypress-sqlite'
// Get results // Get results
sh 'docker cp -L "$(docker-compose ps --all -q cypress-sqlite):/test/results" test/' sh 'docker cp -L "$(docker-compose ps --all -q cypress-sqlite):/test/results" test/results-sqlite'
} }
post { post {
always { always {
// Dumps to analyze later // Dumps to analyze later
sh 'mkdir -p debug' sh 'mkdir -p debug/sqlite'
sh 'docker-compose logs fullstack-sqlite > debug/docker_fullstack_sqlite.log' sh 'docker-compose logs fullstack-sqlite > debug/sqlite/docker_fullstack_sqlite.log'
sh 'docker-compose logs db > debug/docker_db.log' // Cypress videos and screenshot artifacts
// Cypress videos and screenshot artifacts dir(path: 'test/results-sqlite') {
dir(path: 'test/results') { archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml'
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml' }
junit 'test/results-sqlite/junit/*'
}
} }
junit 'test/results/junit/*'
} }
} stage('Mysql') {
} steps {
stage('Integration Tests Mysql') { // Bring up a stack
steps { sh 'docker-compose up -d fullstack-mysql'
// Bring up a stack sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-mysql) 120'
sh 'docker-compose up -d fullstack-mysql'
sh './scripts/wait-healthy $(docker-compose ps --all -q fullstack-mysql) 120'
// Run tests // Run tests
sh 'rm -rf test/results' sh 'rm -rf test/results-mysql'
sh 'docker-compose up cypress-mysql' sh 'docker-compose up cypress-mysql'
// Get results // Get results
sh 'docker cp -L "$(docker-compose ps --all -q cypress-mysql):/test/results" test/' sh 'docker cp -L "$(docker-compose ps --all -q cypress-mysql):/test/results" test/results-mysql'
} }
post { post {
always { always {
// Dumps to analyze later // Dumps to analyze later
sh 'mkdir -p debug' sh 'mkdir -p debug/mysql'
sh 'docker-compose logs fullstack-mysql > debug/docker_fullstack_mysql.log' sh 'docker-compose logs fullstack-mysql > debug/mysql/docker_fullstack_mysql.log'
sh 'docker-compose logs db > debug/docker_db.log' sh 'docker-compose logs db > debug/mysql/docker_db.log'
// Cypress videos and screenshot artifacts // Cypress videos and screenshot artifacts
dir(path: 'test/results') { dir(path: 'test/results-mysql') {
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml' archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: '**/*.xml'
}
junit 'test/results-mysql/junit/*'
}
} }
junit 'test/results/junit/*'
} }
} }
} }

View File

@ -14,7 +14,7 @@ services:
DB_MYSQL_PASSWORD: 'npm' DB_MYSQL_PASSWORD: 'npm'
DB_MYSQL_NAME: 'npm' DB_MYSQL_NAME: 'npm'
volumes: volumes:
- npm_data:/data - npm_data_mysql:/data
expose: expose:
- 81 - 81
- 80 - 80
@ -37,7 +37,7 @@ services:
PGID: 1000 PGID: 1000
DISABLE_IPV6: 'true' DISABLE_IPV6: 'true'
volumes: volumes:
- npm_data:/data - npm_data_sqlite:/data
expose: expose:
- 81 - 81
- 80 - 80
@ -55,7 +55,7 @@ services:
MYSQL_USER: 'npm' MYSQL_USER: 'npm'
MYSQL_PASSWORD: 'npm' MYSQL_PASSWORD: 'npm'
volumes: volumes:
- db_data:/var/lib/mysql - mysql_data:/var/lib/mysql
cypress-mysql: cypress-mysql:
image: "${IMAGE}-cypress:ci-${BUILD_NUMBER}" image: "${IMAGE}-cypress:ci-${BUILD_NUMBER}"
@ -65,7 +65,7 @@ services:
environment: environment:
CYPRESS_baseUrl: 'http://fullstack-mysql:81' CYPRESS_baseUrl: 'http://fullstack-mysql:81'
volumes: volumes:
- cypress-logs:/results - cypress_logs_mysql:/results
command: cypress run --browser chrome --config-file=${CYPRESS_CONFIG:-cypress/config/ci.json} command: cypress run --browser chrome --config-file=${CYPRESS_CONFIG:-cypress/config/ci.json}
cypress-sqlite: cypress-sqlite:
@ -76,10 +76,12 @@ services:
environment: environment:
CYPRESS_baseUrl: "http://fullstack-sqlite:81" CYPRESS_baseUrl: "http://fullstack-sqlite:81"
volumes: volumes:
- cypress-logs:/results - cypress_logs_sqlite:/results
command: cypress run --browser chrome --config-file=${CYPRESS_CONFIG:-cypress/config/ci.json} command: cypress run --browser chrome --config-file=${CYPRESS_CONFIG:-cypress/config/ci.json}
volumes: volumes:
cypress-logs: cypress_logs_mysql:
npm_data: cypress_logs_sqlite:
db_data: npm_data_mysql:
npm_data_sqlite:
mysql_data: