From 5e75d6d70e8c279a2d0a376faeee196165838b55 Mon Sep 17 00:00:00 2001 From: Donkie Date: Sun, 21 May 2023 23:38:41 +0200 Subject: [PATCH] Run integration tests on all db types --- .github/workflows/integration-test.yml | 2 +- .../docker-compose-cockroachdb.yml | 39 +++++++++++++++++++ tests_integration/docker-compose-mariadb.yml | 33 ++++++++++++++++ tests_integration/docker-compose-sqlite.yml | 13 +++++++ tests_integration/run.py | 6 +++ 5 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 tests_integration/docker-compose-cockroachdb.yml create mode 100644 tests_integration/docker-compose-mariadb.yml create mode 100644 tests_integration/docker-compose-sqlite.yml diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index c2c266f..70d2803 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -52,7 +52,7 @@ jobs: needs: [build, build-tester] strategy: matrix: - dbtype: ["postgres"] + dbtype: ["postgres", "sqlite", "mariadb", "cockroachdb"] runs-on: ubuntu-latest steps: - name: Checkout diff --git a/tests_integration/docker-compose-cockroachdb.yml b/tests_integration/docker-compose-cockroachdb.yml new file mode 100644 index 0000000..41b59c8 --- /dev/null +++ b/tests_integration/docker-compose-cockroachdb.yml @@ -0,0 +1,39 @@ +version: '3.9' +services: + db: + image: cockroachdb/cockroach:v23.1.1 + command: start-single-node + environment: + - COCKROACH_USER=john + - COCKROACH_PASSWORD=abc + - COCKROACH_DATABASE=spoolman + healthcheck: + test: + [ + "CMD", + "curl", + "-f", + "http://localhost:8080/health?ready=1" + ] + interval: 5s + timeout: 10s + retries: 5 + spoolman: + image: donkie/spoolman:test + environment: + - SPOOLMAN_DB_TYPE=cockroachdb + - SPOOLMAN_DB_HOST=db + - SPOOLMAN_DB_PORT=26257 + - SPOOLMAN_DB_NAME=spoolman + - SPOOLMAN_DB_USERNAME=john + - SPOOLMAN_DB_PASSWORD=abc + - SPOOLMAN_LOGGING_LEVEL=DEBUG + depends_on: + db: + condition: service_healthy + tester: + image: donkie/spoolman-tester:latest + volumes: + - ./tests:/tester/tests + depends_on: + - spoolman diff --git a/tests_integration/docker-compose-mariadb.yml b/tests_integration/docker-compose-mariadb.yml new file mode 100644 index 0000000..4fbeb81 --- /dev/null +++ b/tests_integration/docker-compose-mariadb.yml @@ -0,0 +1,33 @@ +version: '3.9' +services: + db: + image: mariadb:latest + environment: + - MARIADB_USER=john + - MARIADB_RANDOM_ROOT_PASSWORD=yes + - MARIADB_PASSWORD=abc + - MARIADB_DATABASE=spoolman + healthcheck: + test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ] + interval: 1s + timeout: 20s + retries: 10 + spoolman: + image: donkie/spoolman:test + environment: + - SPOOLMAN_DB_TYPE=mysql + - SPOOLMAN_DB_HOST=db + - SPOOLMAN_DB_PORT=3306 + - SPOOLMAN_DB_NAME=spoolman + - SPOOLMAN_DB_USERNAME=john + - SPOOLMAN_DB_PASSWORD=abc + - SPOOLMAN_LOGGING_LEVEL=DEBUG + depends_on: + db: + condition: service_healthy + tester: + image: donkie/spoolman-tester:latest + volumes: + - ./tests:/tester/tests + depends_on: + - spoolman diff --git a/tests_integration/docker-compose-sqlite.yml b/tests_integration/docker-compose-sqlite.yml new file mode 100644 index 0000000..596d54f --- /dev/null +++ b/tests_integration/docker-compose-sqlite.yml @@ -0,0 +1,13 @@ +version: '3.8' +services: + spoolman: + image: donkie/spoolman:test + environment: + - SPOOLMAN_DB_TYPE=sqlite + - SPOOLMAN_LOGGING_LEVEL=DEBUG + tester: + image: donkie/spoolman-tester:latest + volumes: + - ./tests:/tester/tests + depends_on: + - spoolman diff --git a/tests_integration/run.py b/tests_integration/run.py index f818ba6..47a2e43 100644 --- a/tests_integration/run.py +++ b/tests_integration/run.py @@ -6,3 +6,9 @@ os.system("docker build -t donkie/spoolman:test .") os.system("docker build -t donkie/spoolman-tester:latest tests_integration") os.system("docker-compose -f tests_integration/docker-compose-postgres.yml down -v") os.system("docker-compose -f tests_integration/docker-compose-postgres.yml up --abort-on-container-exit") +os.system("docker-compose -f tests_integration/docker-compose-sqlite.yml down -v") +os.system("docker-compose -f tests_integration/docker-compose-sqlite.yml up --abort-on-container-exit") +os.system("docker-compose -f tests_integration/docker-compose-mariadb.yml down -v") +os.system("docker-compose -f tests_integration/docker-compose-mariadb.yml up --abort-on-container-exit") +os.system("docker-compose -f tests_integration/docker-compose-cockroachdb.yml down -v") +os.system("docker-compose -f tests_integration/docker-compose-cockroachdb.yml up --abort-on-container-exit")