From 0acb58c2311d4bff8f77cdc4a68f2a6e4d454ef3 Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Wed, 22 Sep 2021 12:28:36 +0200 Subject: [PATCH 1/6] use database for migration test db, remove debug code --- .github/workflows/test.yml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e31fa6b7d..046d63681 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -413,22 +413,31 @@ jobs: needs: [build_test_community_server] services: mariadb: - image: gradido/mariadb:test + image: mariadb/server:10.5 env: MARIADB_ALLOW_EMPTY_PASSWORD: 1 MARIADB_USER: root - # ports: - # - 3306:3306 + MARIADB_DATABASE: gradido_community_test options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=5s --health-retries=3 + database: + image: gradido/database:production_up + build: + context: ./database + target: production_up + depends_on: + - mariadb + networks: + - internal-net + environment: + - NODE_ENV="production" + - DB_HOST=mariadb steps: - name: get mariadb container id run: echo "::set-output name=id::$(docker container ls | grep mariadb | awk '{ print $1 }')" id: mariadb_container - - name: show networks - run: echo "$(docker network ls)" - name: get automatic created network run: echo "::set-output name=id::$(docker network ls | grep github_network | awk '{ print $1 }')" id: network @@ -452,12 +461,6 @@ jobs: path: /tmp - name: Load Docker Image run: docker load < /tmp/community_server.tar - - # for debugging login-server - - name: check login-server - run: docker logs ${{ steps.login_server_container.outputs.id }} - - name: check mariadb - run: docker logs ${{ steps.mariadb_container.outputs.id }} ########################################################################## # UNIT TESTS BACKEND COMMUNITY-SERVER ####################################### ########################################################################## From 3e1f0dfa1210ccebf96065d7399e7db8184a942c Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Wed, 22 Sep 2021 12:45:30 +0200 Subject: [PATCH 2/6] add database like login-server --- .github/workflows/test.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 046d63681..de1da0dc9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -413,7 +413,7 @@ jobs: needs: [build_test_community_server] services: mariadb: - image: mariadb/server:10.5 + image: gradido/mariadb:test env: MARIADB_ALLOW_EMPTY_PASSWORD: 1 MARIADB_USER: root @@ -424,16 +424,9 @@ jobs: --health-retries=3 database: image: gradido/database:production_up - build: - context: ./database - target: production_up - depends_on: - - mariadb - networks: - - internal-net - environment: - - NODE_ENV="production" - - DB_HOST=mariadb + env: + NODE_ENV: "production" + DB_HOST: mariadb steps: - name: get mariadb container id run: echo "::set-output name=id::$(docker container ls | grep mariadb | awk '{ print $1 }')" @@ -441,6 +434,8 @@ jobs: - name: get automatic created network run: echo "::set-output name=id::$(docker network ls | grep github_network | awk '{ print $1 }')" id: network + - name: Start database migration + run: docker run --network ${{ steps.network.outputs.id }} --name=database -d gradido/database:production_up --env NODE_ENV=production --env DB_HOST=mariadb --target production_up - name: Start Login-Server run: docker run --network ${{ steps.network.outputs.id }} --name=login-server -d gradido/login_server:with-config - name: get login-server container id From d18e41d38982a427896bb67525201f37b42ded16 Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Wed, 22 Sep 2021 12:50:24 +0200 Subject: [PATCH 3/6] fix --- .github/workflows/test.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index de1da0dc9..bfb73fd1e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -422,11 +422,6 @@ jobs: --health-interval=5s --health-timeout=5s --health-retries=3 - database: - image: gradido/database:production_up - env: - NODE_ENV: "production" - DB_HOST: mariadb steps: - name: get mariadb container id run: echo "::set-output name=id::$(docker container ls | grep mariadb | awk '{ print $1 }')" From a223509608f97780072ba83e125001e8e241338e Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Wed, 22 Sep 2021 13:04:01 +0200 Subject: [PATCH 4/6] fix2 --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bfb73fd1e..726a41945 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -423,9 +423,6 @@ jobs: --health-timeout=5s --health-retries=3 steps: - - name: get mariadb container id - run: echo "::set-output name=id::$(docker container ls | grep mariadb | awk '{ print $1 }')" - id: mariadb_container - name: get automatic created network run: echo "::set-output name=id::$(docker network ls | grep github_network | awk '{ print $1 }')" id: network From 9e7f74b1769a82896e29ebbe70aff700c93f58c7 Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Thu, 23 Sep 2021 13:12:36 +0200 Subject: [PATCH 5/6] add debugging --- .github/workflows/test.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 726a41945..e1b0ca20c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -423,11 +423,17 @@ jobs: --health-timeout=5s --health-retries=3 steps: + - name: get mariadb container id + run: echo "::set-output name=id::$(docker container ls | grep mariadb | awk '{ print $1 }')" + id: mariadb_container - name: get automatic created network run: echo "::set-output name=id::$(docker network ls | grep github_network | awk '{ print $1 }')" id: network - name: Start database migration run: docker run --network ${{ steps.network.outputs.id }} --name=database -d gradido/database:production_up --env NODE_ENV=production --env DB_HOST=mariadb --target production_up + - name: get database migration container id + run: echo "::set-output name=id::$(docker container ls | grep database | awk '{ print $1 }')" + id: database_container - name: Start Login-Server run: docker run --network ${{ steps.network.outputs.id }} --name=login-server -d gradido/login_server:with-config - name: get login-server container id @@ -448,6 +454,13 @@ jobs: path: /tmp - name: Load Docker Image run: docker load < /tmp/community_server.tar + # for debugging login-server + - name: check login-server + run: docker logs ${{ steps.login_server_container.outputs.id }} + - name: check mariadb + run: docker logs ${{ steps.mariadb_container.outputs.id }} + - name: check migration + run: docker logs ${{ steps.database_container.outputs.id }} ########################################################################## # UNIT TESTS BACKEND COMMUNITY-SERVER ####################################### ########################################################################## From 91d51ea7c3b5911cb612768a19a70b22d58ee5b5 Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Thu, 23 Sep 2021 13:25:38 +0200 Subject: [PATCH 6/6] fix 2 --- .github/workflows/test.yml | 1 - database/src/prepare.ts | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e1b0ca20c..ed959e4fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -417,7 +417,6 @@ jobs: env: MARIADB_ALLOW_EMPTY_PASSWORD: 1 MARIADB_USER: root - MARIADB_DATABASE: gradido_community_test options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=5s diff --git a/database/src/prepare.ts b/database/src/prepare.ts index 440289aea..fda4b4e13 100644 --- a/database/src/prepare.ts +++ b/database/src/prepare.ts @@ -25,6 +25,12 @@ export default async (): Promise => { DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;`) + // Create Database `gradido_community_test` for tests + await con.query(` + CREATE DATABASE IF NOT EXISTS ${CONFIG.DB_DATABASE}_test + DEFAULT CHARACTER SET utf8mb4 + DEFAULT COLLATE utf8mb4_unicode_ci;`) + // Check if old migration table is present, delete if needed const [rows] = await con.query(`SHOW TABLES FROM \`${CONFIG.DB_DATABASE}\` LIKE 'migrations';`) if ((rows).length > 0) {