Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit ec571b95 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

updating the docker scripts to execute the tests

parent 15d7f14d
Branches updateResultsFolder
No related tags found
No related merge requests found
Pipeline #221773 failed
Showing
with 129 additions and 109 deletions
services:
smp-springboot:
environment:
ports:
- "8282:8084"
- "3208:3306"
- "5005:5005"
mail-service:
ports:
- "9205:9000"
......@@ -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
......@@ -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
......
......@@ -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" "$@"
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
......@@ -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" "$@"
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"
......@@ -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
......@@ -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
......
......@@ -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}"
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"
......@@ -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
......@@ -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
......
......@@ -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" "$@"
......@@ -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
......
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