Skip to content

Commit

Permalink
Merge pull request #277 from lukaszbudnik/integration-testing-only-ma…
Browse files Browse the repository at this point in the history
…in-db-flavours

Integration testing only main db flavours
  • Loading branch information
lukaszbudnik committed Sep 1, 2021
2 parents eec6f1a + 820084d commit 3ede937
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Start docker-compose services
run: docker-compose -f test/docker-compose.yaml up -d
run: docker-compose -f test/docker-compose-it.yaml up -d

- name: Build and test migrator
env:
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ go:
- '1.17'
before_script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker-compose -f test/docker-compose.yaml up -d
- docker-compose -f test/docker-compose-it.yaml up -d
script:
- "./coverage.sh"
- "./test/http-integration-tests.sh"
after_success:
- bash <(curl -s https://codecov.io/bash)
env:
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,7 @@ docker-compose will start and configure the following services:
2. `migrator-dev` - service built from local branch, listening on port `8282`
3. `postgres` - PostgreSQL service, listening on port `54325`
4. `mysql` - MySQL service, listening on port `3306`
5. `mariadb` - MariaDB (MySQL flavour), listening on port `13306`
6. `percona` - Percona (MySQL flavour), listening on port `23306`
7. `mssql` - MS SQL Server, listening on port `1433`
5. `mssql` - MS SQL Server, listening on port `1433`

> Note: Every database container has a ready-to-use migrator config in `test` directory. You can edit `test/docker-compose.yaml` file and switch to a different database. By default `migrator` and `migrator-dev` services use `test/migrator-docker.yaml` which connects to `mysql` service.

Expand Down
2 changes: 1 addition & 1 deletion db/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func getSupportedDatabases() []string {
return []string{"postgresql", "mysql", "mariadb", "percona", "mssql"}
return []string{"postgresql", "mysql", "mssql"}
}

func TestGetTenants(t *testing.T) {
Expand Down
65 changes: 65 additions & 0 deletions test/docker-compose-it.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
version: "3.6"
services:
postgres:
image: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_PASSWORD=supersecret
- POSTGRES_DB=migrator
volumes:
- ./create-test-tenants.sql:/docker-entrypoint-initdb.d/create-test-tenants.sql
mysql:
image: mysql
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=supersecret
volumes:
- ./create-test-tenants.sql:/docker-entrypoint-initdb.d/create-test-tenants.sql
mssql:
image: mcr.microsoft.com/mssql/server:2017-latest
ports:
- "1433:1433"
environment:
- SA_PASSWORD=Super5ecret
- ACCEPT_EULA=Y
volumes:
- ./create-test-tenants-mssql.sql:/docker-entrypoint-initdb.d/create-test-tenants-mssql.sql
command:
- /bin/bash
- -c
- |
/opt/mssql/bin/sqlservr &
PID=$$!
is_up=-1
while [ $$is_up -ne 0 ] && [ $$is_up -ne 16 ] ; do
/opt/mssql-tools/bin/sqlcmd -l 30 -S localhost -h-1 -V1 -U sa -P $$SA_PASSWORD -Q "CREATE DATABASE migrator"
is_up=$$?
sleep 5
done
if [ $$is_up -eq 0 ]; then
for script in /docker-entrypoint-initdb.d/*.sql
do /opt/mssql-tools/bin/sqlcmd -U sa -P $$SA_PASSWORD -d migrator -l 30 -e -i $$script
done
fi
wait $$PID
migrator-dev:
image: migrator-dev
build:
context: ..
dockerfile: test/migrator-dev/Dockerfile
depends_on:
- mysql
- postgres
- mssql
ports:
- "8282:8080"
environment:
- MIGRATOR_YAML=/data/migrator-docker.yaml
volumes:
- .:/data
links:
- mysql
- postgres
- mssql
30 changes: 1 addition & 29 deletions test/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,18 @@ services:
- MYSQL_ROOT_PASSWORD=supersecret
volumes:
- ./create-test-tenants.sql:/docker-entrypoint-initdb.d/create-test-tenants.sql
mariadb:
image: mariadb
ports:
- "13306:3306"
environment:
- MYSQL_ROOT_PASSWORD=supersecret
volumes:
- ./create-test-tenants.sql:/docker-entrypoint-initdb.d/create-test-tenants.sql
percona:
image: percona
ports:
- "23306:3306"
environment:
- MYSQL_ROOT_PASSWORD=supersecret
volumes:
- ./create-test-tenants.sql:/docker-entrypoint-initdb.d/create-test-tenants.sql
# phpmyadmin:
# image: phpmyadmin/phpmyadmin
# depends_on:
# - mysql
# - mariadb
# - percona
# ports:
# - "8888:80"
# environment:
# - PMA_HOSTS=mysql,mariadb,percona
# - PMA_HOSTS=mysql
# - PMA_USER=root
# - PMA_PASSWORD=supersecret
# links:
# - mysql
# - mariadb
# - percona
mssql:
image: mcr.microsoft.com/mssql/server:2017-latest
ports:
Expand Down Expand Up @@ -88,8 +68,6 @@ services:
image: lukasz/migrator:latest
depends_on:
- mysql
- mariadb
- percona
- postgres
- mssql
ports:
Expand All @@ -100,8 +78,6 @@ services:
- .:/data
links:
- mysql
- mariadb
- percona
- postgres
- mssql
migrator-dev:
Expand All @@ -111,8 +87,6 @@ services:
dockerfile: test/migrator-dev/Dockerfile
depends_on:
- mysql
- mariadb
- percona
- postgres
- mssql
ports:
Expand All @@ -123,7 +97,5 @@ services:
- .:/data
links:
- mysql
- mariadb
- percona
- postgres
- mssql
6 changes: 3 additions & 3 deletions test/http-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if [ "$version_create_name" != "$VERSION_NAME" ]; then
exit 1
fi
echo "New version successfully created"
echo $version_create | jq
echo $version_create | jq '.'

# 4. Fetch migrator versions - will now contain version created above

Expand Down Expand Up @@ -155,7 +155,7 @@ if [ "$tenant_create_version_name" != "$VERSION_NAME" ]; then
exit 1
fi
echo "New tenant successfully created"
echo $tenant_create | jq
echo $tenant_create | jq '.'

# 6. Fetch tenants - will now contain tenant create above

Expand All @@ -176,4 +176,4 @@ echo "--------------------------------------------------------------------------

echo "All good!"

cleanup
cleanup
8 changes: 0 additions & 8 deletions test/migrator-mariadb.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions test/migrator-percona.yaml

This file was deleted.

0 comments on commit 3ede937

Please sign in to comment.