Merge pull request #881 from gradido/community_test_db

Community-Server Test with new db migration
This commit is contained in:
einhornimmond 2021-09-23 13:47:08 +02:00 committed by GitHub
commit 536e97f8a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -417,8 +417,6 @@ jobs:
env: env:
MARIADB_ALLOW_EMPTY_PASSWORD: 1 MARIADB_ALLOW_EMPTY_PASSWORD: 1
MARIADB_USER: root MARIADB_USER: root
# ports:
# - 3306:3306
options: --health-cmd="mysqladmin ping" options: --health-cmd="mysqladmin ping"
--health-interval=5s --health-interval=5s
--health-timeout=5s --health-timeout=5s
@ -427,11 +425,14 @@ jobs:
- name: get mariadb container id - name: get mariadb container id
run: echo "::set-output name=id::$(docker container ls | grep mariadb | awk '{ print $1 }')" run: echo "::set-output name=id::$(docker container ls | grep mariadb | awk '{ print $1 }')"
id: mariadb_container id: mariadb_container
- name: show networks
run: echo "$(docker network ls)"
- name: get automatic created network - name: get automatic created network
run: echo "::set-output name=id::$(docker network ls | grep github_network | awk '{ print $1 }')" run: echo "::set-output name=id::$(docker network ls | grep github_network | awk '{ print $1 }')"
id: network 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 - name: Start Login-Server
run: docker run --network ${{ steps.network.outputs.id }} --name=login-server -d gradido/login_server:with-config run: docker run --network ${{ steps.network.outputs.id }} --name=login-server -d gradido/login_server:with-config
- name: get login-server container id - name: get login-server container id
@ -452,12 +453,13 @@ jobs:
path: /tmp path: /tmp
- name: Load Docker Image - name: Load Docker Image
run: docker load < /tmp/community_server.tar run: docker load < /tmp/community_server.tar
# for debugging login-server # for debugging login-server
- name: check login-server - name: check login-server
run: docker logs ${{ steps.login_server_container.outputs.id }} run: docker logs ${{ steps.login_server_container.outputs.id }}
- name: check mariadb - name: check mariadb
run: docker logs ${{ steps.mariadb_container.outputs.id }} run: docker logs ${{ steps.mariadb_container.outputs.id }}
- name: check migration
run: docker logs ${{ steps.database_container.outputs.id }}
########################################################################## ##########################################################################
# UNIT TESTS BACKEND COMMUNITY-SERVER ####################################### # UNIT TESTS BACKEND COMMUNITY-SERVER #######################################
########################################################################## ##########################################################################

View File

@ -25,6 +25,12 @@ export default async (): Promise<void> => {
DEFAULT CHARACTER SET utf8mb4 DEFAULT CHARACTER SET utf8mb4
DEFAULT COLLATE utf8mb4_unicode_ci;`) 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 // Check if old migration table is present, delete if needed
const [rows] = await con.query(`SHOW TABLES FROM \`${CONFIG.DB_DATABASE}\` LIKE 'migrations';`) const [rows] = await con.query(`SHOW TABLES FROM \`${CONFIG.DB_DATABASE}\` LIKE 'migrations';`)
if ((<RowDataPacket>rows).length > 0) { if ((<RowDataPacket>rows).length > 0) {