keycloak-uncached

Merge pull request #5064 from tkyjovsk/KEYCLOAK-6683 KEYCLOAK-6683

3/7/2018 11:16:16 AM

Details

diff --git a/testsuite/performance/README.md b/testsuite/performance/README.md
index 24b12ba..bc6b5d4 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=<PROVISIONER>]`
diff --git a/testsuite/performance/tests/docker-compose.sh b/testsuite/performance/tests/docker-compose.sh
index 68529eb..930b0bc 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 37bb52b..6c996c7 100644
--- a/testsuite/performance/tests/pom.xml
+++ b/testsuite/performance/tests/pom.xml
@@ -644,6 +644,35 @@
         </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>
                 <delete.data>true</delete.data>