From e2dc3c3d1c0a5d908ed19d0dc65c663b2fa1caf2 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Tue, 9 Oct 2018 13:26:54 +0200 Subject: [PATCH] Minimize # of needed free ports for tests Created a special version of docker-compose files that do not expose any ports unless really needed for test execution. This is to minimize potential conflicts during test execution. --- demo/postgresql/docker-compose-tests.yml | 71 +++++++++++++++ demo/postgresql/tests/main.bats | 2 +- demo/shibboleth/docker-compose-tests.yml | 108 +++++++++++++++++++++++ demo/shibboleth/tests/main.bats | 4 +- 4 files changed, 182 insertions(+), 3 deletions(-) create mode 100644 demo/postgresql/docker-compose-tests.yml create mode 100644 demo/shibboleth/docker-compose-tests.yml diff --git a/demo/postgresql/docker-compose-tests.yml b/demo/postgresql/docker-compose-tests.yml new file mode 100644 index 0000000..d71ea16 --- /dev/null +++ b/demo/postgresql/docker-compose-tests.yml @@ -0,0 +1,71 @@ +# Version for running Bats tests. +# Minimizes the number of ports mapped to localhost, to avoid collisions during testing. + +version: "3.3" + +services: + midpoint_data: + image: postgres:9.5 + environment: + - POSTGRES_PASSWORD_FILE=/run/secrets/mp_database_password.txt + - POSTGRES_USER=midpoint + - POSTGRES_INITDB_ARGS=--lc-collate=en_US.utf8 --lc-ctype=en_US.utf8 + expose: + - 5432 + networks: + - net + secrets: + - mp_database_password.txt + volumes: + - midpoint_data:/var/lib/postgresql/data + + midpoint_server: + image: tier/midpoint:latest + ports: + - 8443:443 + environment: + - ENV + - USERTOKEN + - REPO_DATABASE_TYPE=postgresql + - REPO_HOST=midpoint_data + - REPO_DATABASE=midpoint + - REPO_USER=midpoint + - REPO_MISSING_SCHEMA_ACTION + - REPO_UPGRADEABLE_SCHEMA_ACTION + - REPO_SCHEMA_VERSION_IF_MISSING + - REPO_SCHEMA_VARIANT + - MP_MEM_MAX + - MP_MEM_INIT + - MP_JAVA_OPTS + - TIER_BEACON_OPT_OUT + - TIMEZONE + networks: + - net + secrets: + - mp_database_password.txt + - mp_keystore_password.txt + - mp_host-key.pem + volumes: + - midpoint_home:/opt/midpoint/var + - type: bind + source: ./configs-and-secrets/midpoint/httpd/host-cert.pem + target: /etc/pki/tls/certs/host-cert.pem + - type: bind + source: ./configs-and-secrets/midpoint/httpd/host-cert.pem + target: /etc/pki/tls/certs/cachain.pem + +networks: + net: + driver: bridge + +secrets: + mp_database_password.txt: + file: ./configs-and-secrets/midpoint/application/database_password.txt + mp_keystore_password.txt: + file: ./configs-and-secrets/midpoint/application/keystore_password.txt + mp_host-key.pem: + file: ./configs-and-secrets/midpoint/httpd/host-key.pem + +volumes: + midpoint_data: + midpoint_home: diff --git a/demo/postgresql/tests/main.bats b/demo/postgresql/tests/main.bats index 57d2182..e5681f5 100755 --- a/demo/postgresql/tests/main.bats +++ b/demo/postgresql/tests/main.bats @@ -8,7 +8,7 @@ load ../../../library } @test "010 Initialize and start midPoint" { - docker-compose up --build -d + docker-compose -f docker-compose-tests.yml up --build -d wait_for_midpoint_start postgresql_midpoint_server_1 } diff --git a/demo/shibboleth/docker-compose-tests.yml b/demo/shibboleth/docker-compose-tests.yml new file mode 100644 index 0000000..7dff130 --- /dev/null +++ b/demo/shibboleth/docker-compose-tests.yml @@ -0,0 +1,108 @@ +# Version for running Bats tests. +# Minimizes the number of ports mapped to localhost, to avoid collisions during testing. + +version: "3.3" + +services: + + midpoint_data: + image: tier/mariadb:mariadb10 + expose: + - 3306 + networks: + - net + volumes: + - midpoint_mysql:/var/lib/mysql + - midpoint_data:/var/lib/mysqlmounted + environment: + - CREATE_NEW_DATABASE=if_needed + + midpoint_server: + image: tier/midpoint:latest + ports: + - 8443:443 + environment: + - AUTHENTICATION + - ENV + - USERTOKEN + - REPO_DATABASE_TYPE + - REPO_JDBC_URL + - REPO_HOST + - REPO_PORT + - REPO_DATABASE + - REPO_USER + - REPO_MISSING_SCHEMA_ACTION + - REPO_UPGRADEABLE_SCHEMA_ACTION + - REPO_SCHEMA_VERSION_IF_MISSING + - REPO_SCHEMA_VARIANT + - MP_MEM_MAX + - MP_MEM_INIT + - MP_JAVA_OPTS + - TIER_BEACON_OPT_OUT + - TIMEZONE + networks: + - net + secrets: + - mp_database_password.txt + - mp_keystore_password.txt + - mp_sp-key.pem + - mp_host-key.pem + volumes: + - midpoint_home:/opt/midpoint/var + - type: bind + source: ./configs-and-secrets/midpoint/httpd/host-cert.pem + target: /etc/pki/tls/certs/host-cert.pem + - type: bind + source: ./configs-and-secrets/midpoint/httpd/host-cert.pem + target: /etc/pki/tls/certs/cachain.pem + - type: bind + source: ./configs-and-secrets/midpoint/shibboleth/shibboleth2.xml + target: /etc/shibboleth/shibboleth2.xml + - type: bind + source: ./configs-and-secrets/midpoint/shibboleth/idp-metadata.xml + target: /etc/shibboleth/idp-metadata.xml + - type: bind + source: ./configs-and-secrets/midpoint/shibboleth/sp-cert.pem + target: /etc/shibboleth/sp-cert.pem + + directory: + build: ./directory/ + expose: + - 389 + networks: + - net + volumes: + - ldap:/var/lib/dirsrv + + idp: + build: ./idp/ + depends_on: + - directory + ports: + - 443:443 + environment: + - JETTY_MAX_HEAP=64m + - JETTY_BROWSER_SSL_KEYSTORE_PASSWORD=password + - JETTY_BACKCHANNEL_SSL_KEYSTORE_PASSWORD=password + networks: + - net + +networks: + net: + driver: bridge + +secrets: + mp_database_password.txt: + file: ./configs-and-secrets/midpoint/application/database_password.txt + mp_keystore_password.txt: + file: ./configs-and-secrets/midpoint/application/keystore_password.txt + mp_host-key.pem: + file: ./configs-and-secrets/midpoint/httpd/host-key.pem + mp_sp-key.pem: + file: ./configs-and-secrets/midpoint/shibboleth/sp-key.pem + +volumes: + midpoint_mysql: + midpoint_data: + midpoint_home: + ldap: diff --git a/demo/shibboleth/tests/main.bats b/demo/shibboleth/tests/main.bats index b74341b..5c91133 100755 --- a/demo/shibboleth/tests/main.bats +++ b/demo/shibboleth/tests/main.bats @@ -9,7 +9,7 @@ load ../../../library } @test "010 Initialize and start containers" { - docker-compose up --build -d + docker-compose -f docker-compose-tests.yml up --build -d } @test "012 Wait for Shibboleth to start up" { @@ -64,7 +64,7 @@ load ../../../library } @test "210 Start with internal authentication" { - env AUTHENTICATION=internal docker-compose up -d + env AUTHENTICATION=internal docker-compose -f docker-compose-tests.yml up -d } @test "220 Wait for midPoint to start up" {