Skip to content
Snippets Groups Projects
Unverified Commit faca09c6 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

Conditionally start Docker containers for E2E tests (#34655)

* Conditionally start Docker containers for E2E tests

* Check out before initializing Docker containers

* Use official action to log in to DockerHub

* Evaluate conditional expressions

* Try shell conditionals

* Fix errors due to unset vars

* Run either Mongo or Pg+MySQL
parent cc24e188
No related branches found
No related tags found
No related merge requests found
name: Prepare Docker containers
description: Prepare Docker containers for E2E tests.
inputs:
username:
description: DockerHub username
required: true
password:
description: DockerHub password/token
required: true
maildev:
description: Maildev
required: true
default: 'false'
openldap:
description: Maildev
required: true
default: 'false'
postgres:
description: Maildev
required: true
default: 'false'
mysql:
description: Maildev
required: true
default: 'false'
mongo:
description: Maildev
required: true
default: 'false'
runs:
using: "composite"
steps:
- name: Authenticate to prevent API rate limit
uses: docker/login-action@v3
with:
username: ${{ inputs.username }}
password: ${{ inputs.password }}
- name: Start Containers
run: |
if ${{ inputs.maildev }}; then
echo "Starting maildev container..." &&
docker run -d -p 1080:1080 -p 1025:1025 maildev/maildev:2.0.5 &&
while ! nc -z localhost 1080; do sleep 1; done &&
while ! nc -z localhost 1025; do sleep 1; done &&
echo "Maildev is up and running!"
fi
if ${{ inputs.openldap }}; then
echo "Starting openldap container..." &&
docker run -d -p 389:389 \
--env LDAP_ADMIN_PASSWORD=adminpass \
--env LDAP_USERS=user01@example.org,user02@example.org \
--env LDAP_PASSWORDS=123456,123465 \
--env LDAP_ROOT=dc=example,dc=org \
--env LDAP_PORT_NUMBER=389 \
bitnami/openldap:2.6.4 &&
while ! nc -z localhost 389; do sleep 1; done &&
echo "Openldap is up and running!"
fi
if ${{ inputs.postgres }}; then
echo "Starting postgres container..." &&
docker run -d -p 5404:5432 metabase/qa-databases:postgres-sample-12 &&
while ! nc -z localhost 5404; do sleep 1; done &&
echo "Postgres is up and running!"
fi
if ${{ inputs.mysql }}; then
echo "Starting mysql container..." &&
docker run -d -p 3304:3306 metabase/qa-databases:mysql-sample-8 &&
while ! nc -z localhost 3304; do sleep 1; done &&
echo "MySQL is up and running!"
fi
if ${{ inputs.mongo }}; then
echo "Starting mongo container..." &&
docker run -d -p 27004:27017 metabase/qa-databases:mongo-sample-4.4 &&
while ! nc -z localhost 27004; do sleep 1; done &&
echo "Mongo is up and running!"
fi
shell: bash
...@@ -29,51 +29,20 @@ jobs: ...@@ -29,51 +29,20 @@ jobs:
MB_SNOWPLOW_AVAILABLE: true MB_SNOWPLOW_AVAILABLE: true
MB_SNOWPLOW_URL: "http://localhost:9090" # Snowplow micro MB_SNOWPLOW_URL: "http://localhost:9090" # Snowplow micro
TZ: US/Pacific # to make node match the instance tz TZ: US/Pacific # to make node match the instance tz
services:
maildev:
image: maildev/maildev:2.0.5
ports:
- "1080:1080"
- "1025:1025"
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
openldap:
image: bitnami/openldap:2.6.4
ports:
- 389:389
env:
LDAP_ADMIN_PASSWORD: adminpass
LDAP_USERS: user01@example.org,user02@example.org
LDAP_PASSWORDS: 123456,123465
LDAP_ROOT: dc=example,dc=org
LDAP_PORT_NUMBER: 389
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
postgres-sample:
image: metabase/qa-databases:postgres-sample-12
ports:
- "5404:5432"
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
mongo-sample:
image: metabase/qa-databases:mongo-sample-4.4
ports:
- 27004:27017
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
mysql-sample:
image: metabase/qa-databases:mysql-sample-8
ports:
- 3304:3306
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Prepare Docker containers
uses: ./.github/actions/e2e-prepare-containers
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
maildev: true
openldap: true
postgres: true
mysql: true
mongo: true
- name: Download Metabase uberjar from a previously stored artifact - name: Download Metabase uberjar from a previously stored artifact
run: | run: |
curl -L \ curl -L \
......
...@@ -174,44 +174,21 @@ jobs: ...@@ -174,44 +174,21 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: ${{ fromJSON(needs.e2e-matrix-builder.outputs.matrix) }} matrix: ${{ fromJSON(needs.e2e-matrix-builder.outputs.matrix) }}
services:
maildev:
image: maildev/maildev:2.0.5
ports:
- "1080:1080"
- "1025:1025"
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
openldap:
image: bitnami/openldap:2.6.4
ports:
- 389:389
env:
LDAP_ADMIN_PASSWORD: adminpass
LDAP_USERS: user01@example.org,user02@example.org
LDAP_PASSWORDS: 123456,123465
LDAP_ROOT: dc=example,dc=org
LDAP_PORT_NUMBER: 389
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
postgres-sample:
image: metabase/qa-databases:postgres-sample-12
ports:
- "5404:5432"
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
mysql-sample:
image: metabase/qa-databases:mysql-sample-8
ports:
- 3304:3306
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Prepare Docker containers
uses: ./.github/actions/e2e-prepare-containers
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
maildev: true
openldap: ${{ startsWith(matrix.name, 'admin') }}
postgres: ${{ matrix.name != 'mongo'}}
mysql: ${{ matrix.name != 'mongo'}}
mongo: ${{ matrix.name == 'mongo'}}
- name: Download Metabase uberjar from a previously stored artifact - name: Download Metabase uberjar from a previously stored artifact
if: needs.download_uberjar.result == 'success' if: needs.download_uberjar.result == 'success'
run: | run: |
...@@ -245,7 +222,6 @@ jobs: ...@@ -245,7 +222,6 @@ jobs:
jar xf target/uberjar/metabase.jar version.properties jar xf target/uberjar/metabase.jar version.properties
mv version.properties resources/ mv version.properties resources/
- name: Prepare front-end environment - name: Prepare front-end environment
uses: ./.github/actions/prepare-frontend uses: ./.github/actions/prepare-frontend
- name: Prepare JDK ${{ matrix.java-version }} - name: Prepare JDK ${{ matrix.java-version }}
...@@ -291,14 +267,6 @@ jobs: ...@@ -291,14 +267,6 @@ jobs:
env: env:
TERM: xterm TERM: xterm
# Mongo
- name: Start Mongo server
if: matrix.name == 'mongo'
run: docker run -d -p 27004:27017 --name e2e-mongo metabase/qa-databases:mongo-sample-4.4
- name: Wait until the port 27004 is ready
if: matrix.name == 'mongo'
run: while ! nc -z localhost 27004; do sleep 1; done
timeout-minutes: 3
- name: Run E2E tests that depend on Mongo - name: Run E2E tests that depend on Mongo
if: matrix.name == 'mongo' if: matrix.name == 'mongo'
run: | run: |
...@@ -385,18 +353,16 @@ jobs: ...@@ -385,18 +353,16 @@ jobs:
name: percy-visual-regression-tests name: percy-visual-regression-tests
env: env:
MB_EDITION: ${{ matrix.edition }} MB_EDITION: ${{ matrix.edition }}
services:
maildev:
image: maildev/maildev:2.0.5
ports:
- "1080:1080"
- "1025:1025"
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Prepare Docker containers
uses: ./.github/actions/e2e-prepare-containers
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
maildev: true
- name: Download Metabase uberjar from a previously stored artifact - name: Download Metabase uberjar from a previously stored artifact
if: needs.download_uberjar.result == 'success' if: needs.download_uberjar.result == 'success'
run: | run: |
......
...@@ -13,36 +13,36 @@ describe("qa databases snapshots", { tags: "@external" }, () => { ...@@ -13,36 +13,36 @@ describe("qa databases snapshots", { tags: "@external" }, () => {
}); });
it("creates snapshots for supported qa databases", () => { it("creates snapshots for supported qa databases", () => {
addPostgresDatabase(); if (Cypress.env("QA_DB_MONGO") === true) {
snapshot("postgres-12"); addMongoDatabase();
deleteDatabase("postgresID"); snapshot("mongo-4");
deleteDatabase("mongoID");
restoreAndAuthenticate();
setupWritableDB("postgres"); restoreAndAuthenticate();
addPostgresDatabase("Writable Postgres12", true); } else {
snapshot("postgres-writable"); addPostgresDatabase();
deleteDatabase("postgresID"); snapshot("postgres-12");
deleteDatabase("postgresID");
restoreAndAuthenticate(); restoreAndAuthenticate();
addMySQLDatabase(); setupWritableDB("postgres");
snapshot("mysql-8"); addPostgresDatabase("Writable Postgres12", true);
deleteDatabase("mysqlID"); snapshot("postgres-writable");
deleteDatabase("postgresID");
restoreAndAuthenticate(); restoreAndAuthenticate();
setupWritableDB("mysql"); addMySQLDatabase();
addMySQLDatabase("Writable MySQL8", true); snapshot("mysql-8");
snapshot("mysql-writable"); deleteDatabase("mysqlID");
deleteDatabase("mysqlID");
restoreAndAuthenticate(); restoreAndAuthenticate();
if (Cypress.env("QA_DB_MONGO") === true) { setupWritableDB("mysql");
addMongoDatabase(); addMySQLDatabase("Writable MySQL8", true);
snapshot("mongo-4"); snapshot("mysql-writable");
deleteDatabase("mongoID"); deleteDatabase("mysqlID");
restoreAndAuthenticate(); restoreAndAuthenticate();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment