Hi All,
I’ve been trying to run some tests which involve a mysql service that runs a database import. The import seems to run correctly but for some reason when running the tests, the database exists but it has no contents (no tables at all). I’m not sure why that is and wondered if anyone had any idea why that may be.
It’s almost like the database is wiped by the time the tests have been run but the actual database is still there, just empty.
I’ve included my gitlab-ci.yml file below but if any further information is needed, please let me know.
Thanks,
Sam
I’m running this on gitlab.com.
image: maven:3-jdk-8
# Mysql server needed to run tests
services:
- mysql:latest
variables:
# Configure mysql environment variables (https://hub.docker.com/_/mysql/)
MYSQL_DATABASE: "db0001"
MYSQL_ROOT_PASSWORD: "root"
stages:
- connect
- test
- build
test:
script: "mvn verify"
build:
script: "mvn install -B"
connect:
image: mysql
script:
- mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" < database/skeleton.sql
- echo "select count(*) from $MYSQL_DATABASE.nameservers;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
- echo "show databases;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"