diff --git a/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/docker-compose.local.yml b/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/docker-compose.local.yml new file mode 100644 index 0000000000000000000000000000000000000000..677801372ed838db5aca43871f044f65dbba4521 --- /dev/null +++ b/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/docker-compose.local.yml @@ -0,0 +1,10 @@ +services: + smp-springboot: + environment: + ports: + - "8282:8084" + - "3208:3306" + - "5005:5005" + mail-service: + ports: + - "9205:9000" diff --git a/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/docker-compose.test-api-smp20.yml b/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/docker-compose.test-api-smp20.yml index de1f0bdb1c3eea561149b7719b39e8c7021c2abc..53c0e9d269008c4c92030b46689af7dc4b01bfad 100644 --- a/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/docker-compose.test-api-smp20.yml +++ b/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/docker-compose.test-api-smp20.yml @@ -3,15 +3,6 @@ services: ## UI Tests ## testapi: - image: ${IMAGE_TAG:-edeliverytest}/${IMAGE_SMP_TESTS}:${SMP_VERSION} environment: - - TEST_PLAN=api - - TEST_URL=http://smp-springboot-mysql.local:8084/smp/ - TEST_FILE_NAME=DomiSMP-Oasis2-soapui-project.xml - TEST_SUITE=AUTO_BAMBOO_SMP20 - networks: - - test-network -networks: - test-network: - name: ${DOCKER_NETWORK_NAME:-domismp-springboot-mysql_default} - external: true diff --git a/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/runCompose.sh b/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/runCompose.sh index 3ee6d33c54998a2263de7f84a53121f49ec1129e..a8bf6960d8c17ee5d404ae1390e32ddc79b4501e 100755 --- a/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/runCompose.sh +++ b/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/runCompose.sh @@ -4,18 +4,20 @@ WORKDIR="$(cd -P $(dirname ${BASH_SOURCE[0]} ) && pwd)" source "${WORKDIR}/../../functions/run-test.functions" initializeVariables +START_LOCAL="false" SMP_INIT_DATABASE="${SMP_PROJECT_FOLDER}/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb.ddl" #SMP_INIT_DATABASE_DATA="${SMP_PROJECT_FOLDER}/smp-webapp/src/main/smp-setup/database-scripts/mysql5innodb-data.sql" SMP_INIT_DATABASE_DATA="${SMP_PROJECT_FOLDER}/domismp-tests/domismp-tests-api/groovy/mysql-4.1_integration_test_data.sql" # READ arguments -while getopts i:v: option +while getopts i:v:l: option do case "${option}" in i) SMP_INIT_DATABASE_DATA=${OPTARG};; v) SMP_VERSION=${OPTARG};; + l) START_LOCAL=${OPTARG};; *) echo "Unknown option [${option}]. Usage: $0 [-i] [-v]"; exit 1;; esac done diff --git a/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/runTestsAPI.sh b/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/runTestsAPI.sh index 7ed82ca9ed3b75bdeb16a2ea69d6d2154c7def21..8bb0bc7769390dd0d57cf4bfc8c8ec350ce9d8dc 100755 --- a/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/runTestsAPI.sh +++ b/domismp-tests/domismp-docker/compose/domismp-springboot-mysql/runTestsAPI.sh @@ -5,19 +5,4 @@ WORKDIR="$(cd -P $(dirname ${BASH_SOURCE[0]} ) && pwd)" source "${WORKDIR}/../../functions/run-test.functions" initializeVariables -RESULT_FOLDER="${WORKDIR}/results" -SMP_VERSION_SUFFIX=$1 -if [ -n "${SMP_VERSION_SUFFIX}" ]; then - SMP_VERSION_SUFFIX="-${SMP_VERSION_SUFFIX}" -fi -# clear old results -rm -rf "${RESULT_FOLDER}" -mkdir -p "${RESULT_FOLDER}" - -# define network to connect the tests -DOCKER_NETWORK_NAME="${PLAN_PREFIX}_default" -export DOCKER_NETWORK_NAME - -# Starting Docker Compose TEST (in specific project to avoid orphan container warning) -docker compose -f docker-compose.test-api${SMP_VERSION_SUFFIX}.yml -p "run-${PLAN_PREFIX}" up -docker cp "run-${PLAN_PREFIX}-testapi-1:/data/results/soapui-reports" "./results${SMP_VERSION_SUFFIX}" +runTestsFromContainer "testapi" "test-api" "$@" diff --git a/domismp-tests/domismp-docker/compose/domismp-tomcat-mysql/docker-compose.test-api-smp20.yml b/domismp-tests/domismp-docker/compose/domismp-tomcat-mysql/docker-compose.test-api-smp20.yml index a7a7a088576fe8bf436df50eba14e861576667bd..7312a47c334c83a0ce67eb584ac7f8f8bd778b13 100644 --- a/domismp-tests/domismp-docker/compose/domismp-tomcat-mysql/docker-compose.test-api-smp20.yml +++ b/domismp-tests/domismp-docker/compose/domismp-tomcat-mysql/docker-compose.test-api-smp20.yml @@ -1,17 +1,7 @@ services: ## - ## API Tests - ## + ## Execute tests with additional parameters testapi: - image: ${IMAGE_TAG:-edeliverytest}/${IMAGE_SMP_TESTS}:${SMP_VERSION} environment: - - TEST_PLAN=api - - TEST_URL=http://eulogin.protected.smp.local:8080/smp/ - TEST_FILE_NAME=DomiSMP-Oasis2-soapui-project.xml - TEST_SUITE=AUTO_BAMBOO_SMP20 - networks: - - test-network -networks: - test-network: - name: ${DOCKER_NETWORK_NAME:-domismp-tomcat-mysql_default} - external: true diff --git a/domismp-tests/domismp-docker/compose/domismp-tomcat-mysql/runTestsAPI.sh b/domismp-tests/domismp-docker/compose/domismp-tomcat-mysql/runTestsAPI.sh index 7ed82ca9ed3b75bdeb16a2ea69d6d2154c7def21..8bb0bc7769390dd0d57cf4bfc8c8ec350ce9d8dc 100755 --- a/domismp-tests/domismp-docker/compose/domismp-tomcat-mysql/runTestsAPI.sh +++ b/domismp-tests/domismp-docker/compose/domismp-tomcat-mysql/runTestsAPI.sh @@ -5,19 +5,4 @@ WORKDIR="$(cd -P $(dirname ${BASH_SOURCE[0]} ) && pwd)" source "${WORKDIR}/../../functions/run-test.functions" initializeVariables -RESULT_FOLDER="${WORKDIR}/results" -SMP_VERSION_SUFFIX=$1 -if [ -n "${SMP_VERSION_SUFFIX}" ]; then - SMP_VERSION_SUFFIX="-${SMP_VERSION_SUFFIX}" -fi -# clear old results -rm -rf "${RESULT_FOLDER}" -mkdir -p "${RESULT_FOLDER}" - -# define network to connect the tests -DOCKER_NETWORK_NAME="${PLAN_PREFIX}_default" -export DOCKER_NETWORK_NAME - -# Starting Docker Compose TEST (in specific project to avoid orphan container warning) -docker compose -f docker-compose.test-api${SMP_VERSION_SUFFIX}.yml -p "run-${PLAN_PREFIX}" up -docker cp "run-${PLAN_PREFIX}-testapi-1:/data/results/soapui-reports" "./results${SMP_VERSION_SUFFIX}" +runTestsFromContainer "testapi" "test-api" "$@" diff --git a/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/docker-compose.local.yml b/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/docker-compose.local.yml new file mode 100644 index 0000000000000000000000000000000000000000..688de583dfc485b08385000259ab9a20e8e551c6 --- /dev/null +++ b/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/docker-compose.local.yml @@ -0,0 +1,24 @@ +services: + smp-oracle-db: + ports: + - 1921:1521 + + smp-wls-admin: + ports: + - 7901:7001 + + smp-node-01: + ports: + - "19453:8453" + - "19001:8001" + + smp-node-02: + ports: + - "19454:8453" + - "19002:8001" + + smp-httpd: + ports: + - "7980:80" + + diff --git a/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/docker-compose.test-api-smp20.yml b/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/docker-compose.test-api-smp20.yml index adb8c534867432dd66f1273bd98c2813d589ac14..19d88a0bf7ce891cc4655026a87f21eab0c45dae 100644 --- a/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/docker-compose.test-api-smp20.yml +++ b/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/docker-compose.test-api-smp20.yml @@ -3,15 +3,6 @@ services: ## API Tests ## testapi: - image: ${IMAGE_TAG:-edeliverytest}/${IMAGE_SMP_TESTS}:${SMP_VERSION} environment: - - TEST_PLAN=api - - TEST_URL=http://smp-httpd/smp/ - TEST_FILE_NAME=DomiSMP-Oasis2-soapui-project.xml - TEST_SUITE=AUTO_BAMBOO_SMP20 - networks: - - test-network -networks: - test-network: - name: ${DOCKER_NETWORK_NAME:-domismp-tomcat-mysql_default} - external: true diff --git a/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/runCompose.sh b/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/runCompose.sh index 5fc9f7212c0c831f30527c0fa51c832715bfbcef..fbaa1fbaf40205f845516f34a30da13ce9f551fe 100755 --- a/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/runCompose.sh +++ b/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/runCompose.sh @@ -30,14 +30,15 @@ SMP_DB_PASSWORD="test" SMP_JDBC_URL="jdbc:oracle:thin:@//smp-oracle-db:1521/${ORA_SERVICE}" SMP_DB_SCRIPTS=./properties/db-scripts SMP_WLS_INIT_SCRIPTS=./properties/weblogic-init - +START_LOCAL="false" # READ arguments -while getopts i:v: option +while getopts i:v:l: option do case "${option}" in i) SMP_INIT_DATABASE_DATA=${OPTARG};; v) SMP_VERSION=${OPTARG};; + l) START_LOCAL=${OPTARG};; *) echo "Unknown option [${option}]. Usage: $0 [-i] [-v]"; exit 1;; esac done diff --git a/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/runTestsAPI.sh b/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/runTestsAPI.sh index b301f31c71dec81846afe748b92263ad366a4b56..7f7254d7ab2b3e040ab3d44a3154d9b7359420d2 100755 --- a/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/runTestsAPI.sh +++ b/domismp-tests/domismp-docker/compose/domismp-wls122-oradb/runTestsAPI.sh @@ -5,19 +5,5 @@ WORKDIR="$(cd -P $(dirname "${BASH_SOURCE[0]}" ) && pwd)" source "${WORKDIR}/../../functions/run-test.functions" initializeVariables -RESULT_FOLDER="${WORKDIR}/results" -SMP_VERSION_SUFFIX=$1 -if [ -n "${SMP_VERSION_SUFFIX}" ]; then - SMP_VERSION_SUFFIX="-${SMP_VERSION_SUFFIX}" -fi -# clear old results -rm -rf "${RESULT_FOLDER}" -mkdir -p "${RESULT_FOLDER}" +runTestsFromContainer "testapi" "test-api" "$@" -# define network to connect the tests -DOCKER_NETWORK_NAME="${PLAN_PREFIX}_default" -export DOCKER_NETWORK_NAME - -# Starting Docker Compose TEST (in specific project to avoid orphan container warning) -docker compose -f docker-compose.test-api${SMP_VERSION_SUFFIX}.yml -p "run-${PLAN_PREFIX}" up -docker cp "run-${PLAN_PREFIX}-testapi-1:/data/results/soapui-reports" "./results${SMP_VERSION_SUFFIX}" diff --git a/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/docker-compose.local.yml b/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/docker-compose.local.yml new file mode 100644 index 0000000000000000000000000000000000000000..ebac39b9c6fd942d45dbbcff67714c90c6f1ae6c --- /dev/null +++ b/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/docker-compose.local.yml @@ -0,0 +1,22 @@ +services: + smp-oracle-db: + ports: + - 1821:1521 + + smp-wls-admin: + ports: + - 7801:7001 + + smp-node-01: + ports: + - "18453:8453" + - "18001:8001" + + smp-node-02: + ports: + - "18454:8453" + - "18002:8001" + + smp-httpd: + ports: + - "7880:80" diff --git a/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/docker-compose.test-api-smp20.yml b/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/docker-compose.test-api-smp20.yml index adb8c534867432dd66f1273bd98c2813d589ac14..19d88a0bf7ce891cc4655026a87f21eab0c45dae 100644 --- a/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/docker-compose.test-api-smp20.yml +++ b/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/docker-compose.test-api-smp20.yml @@ -3,15 +3,6 @@ services: ## API Tests ## testapi: - image: ${IMAGE_TAG:-edeliverytest}/${IMAGE_SMP_TESTS}:${SMP_VERSION} environment: - - TEST_PLAN=api - - TEST_URL=http://smp-httpd/smp/ - TEST_FILE_NAME=DomiSMP-Oasis2-soapui-project.xml - TEST_SUITE=AUTO_BAMBOO_SMP20 - networks: - - test-network -networks: - test-network: - name: ${DOCKER_NETWORK_NAME:-domismp-tomcat-mysql_default} - external: true diff --git a/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/runCompose.sh b/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/runCompose.sh index 5fc9f7212c0c831f30527c0fa51c832715bfbcef..2a548e790e6bf1c004c039b1da2c61c0f7422422 100755 --- a/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/runCompose.sh +++ b/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/runCompose.sh @@ -14,7 +14,7 @@ initializeVariables SMP_INIT_DATABASE="${SMP_PROJECT_FOLDER}/smp-webapp/src/main/smp-setup/database-scripts/oracle10g.ddl" #SMP_INIT_DATABASE_DATA="${SMP_PROJECT_FOLDER}/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-data.sql" SMP_INIT_DATABASE_DATA="${SMP_PROJECT_FOLDER}/domismp-tests/domismp-tests-api/groovy/oracle-4.1_integration_test_data.sql" - +START_LOCAL="false" #ORA_VERSION="19.3.0" #ORA_EDITION="se2" @@ -32,12 +32,13 @@ SMP_DB_SCRIPTS=./properties/db-scripts SMP_WLS_INIT_SCRIPTS=./properties/weblogic-init # READ arguments -while getopts i:v: option +while getopts i:v:l: option do case "${option}" in i) SMP_INIT_DATABASE_DATA=${OPTARG};; v) SMP_VERSION=${OPTARG};; + l) START_LOCAL=${OPTARG};; *) echo "Unknown option [${option}]. Usage: $0 [-i] [-v]"; exit 1;; esac done diff --git a/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/runTestsAPI.sh b/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/runTestsAPI.sh index 07a8948879073df9aa6a682da4f4150b0bc5bbf9..797453514c3d55af21130e5dcbc50d42e1f62f98 100755 --- a/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/runTestsAPI.sh +++ b/domismp-tests/domismp-docker/compose/domismp-wls141-oradb/runTestsAPI.sh @@ -5,20 +5,4 @@ WORKDIR="$(cd -P $(dirname "${BASH_SOURCE[0]}" ) && pwd)" source "${WORKDIR}/../../functions/run-test.functions" initializeVariables -RESULT_FOLDER="${WORKDIR}/results" - -SMP_VERSION_SUFFIX=$1 -if [ -n "${SMP_VERSION_SUFFIX}" ]; then - SMP_VERSION_SUFFIX="-${SMP_VERSION_SUFFIX}" -fi -# clear old results -rm -rf "${RESULT_FOLDER}" -mkdir -p "${RESULT_FOLDER}" - -# define network to connect the tests -DOCKER_NETWORK_NAME="${PLAN_PREFIX}_default" -export DOCKER_NETWORK_NAME - -# Starting Docker Compose TEST (in specific project to avoid orphan container warning) -docker compose -f docker-compose.test-api${SMP_VERSION_SUFFIX}.yml -p "run-${PLAN_PREFIX}" up -docker cp "run-${PLAN_PREFIX}-testapi-1:/data/results/soapui-reports" "./results${SMP_VERSION_SUFFIX}" +runTestsFromContainer "testapi" "test-api" "$@" diff --git a/domismp-tests/domismp-docker/functions/run-test.functions b/domismp-tests/domismp-docker/functions/run-test.functions index 0c9d2b9e3bbfc98aef2536c1391e74975eed4494..e0c461685eef79934bab5e0d899be78f6dc32f01 100644 --- a/domismp-tests/domismp-docker/functions/run-test.functions +++ b/domismp-tests/domismp-docker/functions/run-test.functions @@ -33,17 +33,74 @@ function stopAndClearTestContainers() { } ################################################################ -# Function exports the logs to file and stop and clear containers +# function starts the container with the prefix and version. If local is set to true, +# and docker-compose.local.yml is present, then local docker compose file is used as well function startTestContainers() { COMPOSE_FILE="-f docker-compose.yml" if [ "${START_LOCAL}" == "true" ]; then - COMPOSE_FILE="${COMPOSE_FILE} -f docker-compose.local.yml" + # check if local docker compose file is present and use it + # else log and and continue without it + if [ ! -f "docker-compose.local.yml" ]; then + echo "Local docker compose file not found!" + else + echo "Local docker compose file found, add to the execution!" + COMPOSE_FILE="${COMPOSE_FILE} -f docker-compose.local.yml" + fi fi + : "${SMP_VERSION?"Need to set SMP_VERSION non-empty!"}" echo "Start containers with prefix ${PLAN_PREFIX} for version ${SMP_VERSION}" docker compose -p "${PLAN_PREFIX}" ${COMPOSE_FILE} up -d --force-recreate --wait --wait-timeout 300 } +################################################################ +# Function starts the testing container which executes the tests. +# The function requires the test yaml suffix (e.g. test-api, test-ui) as parameter +# and the optional second parameter is the test variant (e.g. smp20) +function runTestsFromContainer() { + : "${1?"The container service name is missing : eg: testapi!"}" + : "${2?"The compose suffix is mandatory: e.g. test-api, test-ui!"}" + : "${WORKDIR?"Work dir is not set!"}" + : "${SMP_VERSION?"Need to set SMP_VERSION non-empty!"}" + + COMPOSE_FILE="docker-compose.${2}.yml" + TEST_PLAN_SUFFIX="${3+-${3}}" + + if [ ! -f "${COMPOSE_FILE}" ]; then + echo "Docker compose file to execute tests [${COMPOSE_FILE}] not found!" + exit 2 + fi + # add -f to the compose file + COMPOSE_FILE="-f ${COMPOSE_FILE}" + # if {3} is sets then add additional compose file with the variant + if [ -n "${TEST_PLAN_SUFFIX}" ]; then + ADDITIONAL_DOCKER_COMPOSE_FILE="docker-compose.${2}${TEST_PLAN_SUFFIX}.yml" + if [ -f "${ADDITIONAL_DOCKER_COMPOSE_FILE}" ]; then + COMPOSE_FILE="${COMPOSE_FILE} -f ${ADDITIONAL_DOCKER_COMPOSE_FILE}" + else + echo "Variant docker compose file [${ADDITIONAL_DOCKER_COMPOSE_FILE}] not found!" + exit 3 + fi + fi + DOCKER_NETWORK_NAME="${PLAN_PREFIX}_default" + export SMP_VERSION + export DOCKER_NETWORK_NAME + + RESULT_FOLDER="${WORKDIR}/results-${2}${TEST_PLAN_SUFFIX}" + # clear old results + rm -rf "${RESULT_FOLDER}" + mkdir -p "${RESULT_FOLDER}" + + echo "Start testing containers ${COMPOSE_FILE} with prefix ${PLAN_PREFIX} for version ${SMP_VERSION}" + docker compose -p "run-${PLAN_PREFIX}" ${COMPOSE_FILE} up + # copy results from container + TEST_CONTAINER_NAME="run-${PLAN_PREFIX}-${1}-1" + echo "Copy results from container from "${TEST_CONTAINER_NAME}:/data/results/soapui-reports" to ${RESULT_FOLDER}" + docker cp "${TEST_CONTAINER_NAME}:/data/results/soapui-reports" ${RESULT_FOLDER} + echo "Copy logs from container from ${TEST_CONTAINER_NAME} to ${RESULT_FOLDER}/smp-${2}${TEST_PLAN_SUFFIX}.log" + docker logs "${TEST_CONTAINER_NAME}" > "${RESULT_FOLDER}/smp-${2}${TEST_PLAN_SUFFIX}.log" 2>&1 +} + # method creates init scripts for application oracle database initialization from scratch! # - 01_create_user.sql - recreate user and schema # - 02_oracle10g.sql - init database script