From 63383f80324b2a9a494e40266a2168538c7da17c Mon Sep 17 00:00:00 2001 From: Tomas Kyjovsky Date: Tue, 6 Mar 2018 23:43:47 +0100 Subject: [PATCH] KEYCLOAK-6683 Ability to archive logs of provisioned docker instances --- testsuite/performance/README.md | 7 +++++ testsuite/performance/tests/docker-compose.sh | 13 +++++++++ testsuite/performance/tests/pom.xml | 29 +++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/testsuite/performance/README.md b/testsuite/performance/README.md index 24b12ba1a8..bc6b5d45c8 100644 --- a/testsuite/performance/README.md +++ b/testsuite/performance/README.md @@ -80,6 +80,13 @@ it is necessary to update the generated Keycloak server configuration (inside `k adding a `clean` goal to the provisioning command like so: `mvn clean verify -Pprovision …`. It is *not* necessary to update this configuration when switching between `singlenode` and `cluster` deployments. +### Collect Artifacts + +Usage: `mvn verify -Pcollect` + +Collects artifacts such as logs from the provisioned system and stores them in `tests/target/collected-artifacts/${deployment}-TIMESTAMP/`. +When used in combination with teardown (see below) the artifacts are collected just before the system is torn down. + ### Teardown Usage: `mvn verify -Pteardown [-Dprovisioner=]` diff --git a/testsuite/performance/tests/docker-compose.sh b/testsuite/performance/tests/docker-compose.sh index 68529ebc9e..930b0bcd9b 100755 --- a/testsuite/performance/tests/docker-compose.sh +++ b/testsuite/performance/tests/docker-compose.sh @@ -409,6 +409,19 @@ case "$OPERATION" in ;; + collect) + TIMESTAMP=`date +%s` + ARTIFACTS_DIR="${PROJECT_BUILD_DIRECTORY}/collected-artifacts/${DEPLOYMENT}-${TIMESTAMP}" + SERVICES=`docker-compose -f $DOCKER_COMPOSE_FILE -p ${PROJECT_NAME} config --services` + echo "Collecting docker container logs." + rm -rf ${ARTIFACTS_DIR}; mkdir -p ${ARTIFACTS_DIR} + for SERVICE in ${SERVICES}; do + docker logs "${PROJECT_NAME}_${SERVICE}_1" > ${ARTIFACTS_DIR}/${SERVICE}.log 2>&1; + if [[ $? != 0 ]]; then echo "ERROR collecting from: ${SERVICE}"; rm ${ARTIFACTS_DIR}/${SERVICE}.log; fi + done + if [ -z "$(ls -A ${ARTIFACTS_DIR})" ]; then echo "No logs were collected."; rm -rf ${ARTIFACTS_DIR}; fi + ;; + *) echo "Unsupported operation: '$OPERATION'" exit 1 diff --git a/testsuite/performance/tests/pom.xml b/testsuite/performance/tests/pom.xml index 37bb52bf20..6c996c75b5 100644 --- a/testsuite/performance/tests/pom.xml +++ b/testsuite/performance/tests/pom.xml @@ -643,6 +643,35 @@ + + collect + + + + org.codehaus.mojo + exec-maven-plugin + + + collect-artifacts + post-integration-test + + exec + + + ./${provisioner}.sh + + ${provisioner} + ${deployment} + collect + + + + + + + + + teardown