KEYCLOAK-6683 Ability to archive logs of provisioned docker instances
This commit is contained in:
parent
a63a01c9ea
commit
63383f8032
3 changed files with 49 additions and 0 deletions
|
@ -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=<PROVISIONER>]`
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -643,6 +643,35 @@
|
|||
</properties>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>collect</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>collect-artifacts</id>
|
||||
<phase>post-integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>./${provisioner}.sh</executable>
|
||||
<environmentVariables>
|
||||
<PROVISIONER>${provisioner}</PROVISIONER>
|
||||
<DEPLOYMENT>${deployment}</DEPLOYMENT>
|
||||
<OPERATION>collect</OPERATION>
|
||||
</environmentVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>teardown</id>
|
||||
<properties>
|
||||
|
|
Loading…
Reference in a new issue