From 0fee33bb95150d6e14b228da716c14ca06e820da Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Thu, 15 Dec 2022 10:14:30 +0100 Subject: [PATCH] Normalize JVM heap usage in tests and handle OOM situations Closes #16089 --- .github/actions/upload-heapdumps/action.yml | 12 +++++++ .github/workflows/ci.yml | 40 +++++++++++++++++++++ pom.xml | 2 +- quarkus/tests/integration/pom.xml | 4 +-- saml-core/pom.xml | 4 +-- server-spi-private/pom.xml | 3 +- testsuite/model/pom.xml | 2 +- 7 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 .github/actions/upload-heapdumps/action.yml diff --git a/.github/actions/upload-heapdumps/action.yml b/.github/actions/upload-heapdumps/action.yml new file mode 100644 index 00000000000..ed4d56c1f25 --- /dev/null +++ b/.github/actions/upload-heapdumps/action.yml @@ -0,0 +1,12 @@ +name: Upload JVM Heapdumps +description: Upload JVM Heapdumps + +runs: + using: composite + steps: + - id: upload-jvm-heapdumps + name: Upload JVM Heapdumps + uses: actions/upload-artifact@v3 + with: + name: jvm-heap-dumps + path: '**/java_pid*.hprof' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30db4eca9c9..b2a2fef366b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,6 +58,10 @@ jobs: ./mvnw test -nsu -B -pl "$PROJECTS" -am + - name: Upload JVM Heapdumps + if: always() + uses: ./.github/actions/upload-heapdumps + - id: upload-surefire-reports name: Upload Surefire reports uses: ./.github/actions/upload-surefire-reports @@ -88,6 +92,10 @@ jobs: echo "Tests: $TESTS" ./mvnw test -Dsurefire.rerunFailingTestsCount=${{ env.SUREFIRE_RERUN_FAILING_COUNT }} -nsu -B -Pauth-server-quarkus -Dtest=$TESTS -pl testsuite/integration-arquillian/tests/base | misc/log/trimmer.sh + - name: Upload JVM Heapdumps + if: always() + uses: ./.github/actions/upload-heapdumps + - id: upload-surefire-reports name: Upload Surefire reports uses: ./.github/actions/upload-surefire-reports @@ -128,6 +136,10 @@ jobs: ./mvnw install -nsu -B -pl quarkus/tests/integration -am -DskipTests ./mvnw test -nsu -B -pl quarkus/tests/integration ${PARAMS["${{ matrix.server }}"]} | misc/log/trimmer.sh + - name: Upload JVM Heapdumps + if: always() + uses: ./.github/actions/upload-heapdumps + - id: upload-surefire-reports name: Upload Surefire reports uses: ./.github/actions/upload-surefire-reports @@ -165,6 +177,10 @@ jobs: echo "Tests: $TESTS" ./mvnw test -nsu -B -Pauth-server-quarkus -Dtest=$TESTS -pl testsuite/integration-arquillian/tests/base | misc/log/trimmer.sh + - name: Upload JVM Heapdumps + if: always() + uses: ./.github/actions/upload-heapdumps + - id: upload-surefire-reports name: Upload Surefire reports uses: ./.github/actions/upload-surefire-reports @@ -218,6 +234,10 @@ jobs: echo "Tests: $TESTS" ./mvnw test -nsu -B -Pauth-server-quarkus ${PARAMS["${{ matrix.db }}"]} -Dtest=$TESTS -pl testsuite/integration-arquillian/tests/base | misc/log/trimmer.sh + - name: Upload JVM Heapdumps + if: always() + uses: ./.github/actions/upload-heapdumps + - id: upload-surefire-reports name: Upload Surefire reports uses: ./.github/actions/upload-surefire-reports @@ -248,6 +268,10 @@ jobs: echo "Tests: $TESTS" ./mvnw test -nsu -B -Pauth-server-quarkus -Pdb-${{ matrix.db }} -Dtest=$TESTS -pl testsuite/integration-arquillian/tests/base | misc/log/trimmer.sh + - name: Upload JVM Heapdumps + if: always() + uses: ./.github/actions/upload-heapdumps + - id: upload-surefire-reports name: Upload Surefire reports uses: ./.github/actions/upload-surefire-reports @@ -271,6 +295,10 @@ jobs: - name: Run model tests run: testsuite/model/test-all-profiles.sh + - name: Upload JVM Heapdumps + if: always() + uses: ./.github/actions/upload-heapdumps + clustering-integration-tests: name: Legacy Clustering IT needs: build @@ -289,6 +317,10 @@ jobs: run: | ./mvnw test -nsu -B -Pauth-server-cluster-quarkus -Dsession.cache.owners=2 -Dtest=**.cluster.** -pl testsuite/integration-arquillian/tests/base | misc/log/trimmer.sh + - name: Upload JVM Heapdumps + if: always() + uses: ./.github/actions/upload-heapdumps + - id: upload-surefire-reports name: Upload Surefire reports uses: ./.github/actions/upload-surefire-reports @@ -315,6 +347,10 @@ jobs: - name: Run crypto tests (BCFIPS approved mode) run: ./mvnw test -nsu -B -am -pl crypto/default,crypto/fips1402,crypto/elytron -Dcom.redhat.fips=true -Dorg.bouncycastle.fips.approved_only=true + - name: Upload JVM Heapdumps + if: always() + uses: ./.github/actions/upload-heapdumps + - id: upload-surefire-reports name: Upload Surefire reports uses: ./.github/actions/upload-surefire-reports @@ -344,6 +380,10 @@ jobs: echo "Tests: $TESTS" ./mvnw test -nsu -B -Pauth-server-quarkus,auth-server-fips140-2 -Dtest=$TESTS -pl testsuite/integration-arquillian/tests/base | misc/log/trimmer.sh + - name: Upload JVM Heapdumps + if: always() + uses: ./.github/actions/upload-heapdumps + - id: upload-surefire-reports name: Upload Surefire reports uses: ./.github/actions/upload-surefire-reports diff --git a/pom.xml b/pom.xml index d894af297cc..b4020c0b5ad 100644 --- a/pom.xml +++ b/pom.xml @@ -1783,7 +1783,7 @@ ${surefire-plugin.version} once - -Djava.awt.headless=true ${surefire.memory.settings} ${surefire.system.args} -Duser.language=en -Duser.region=US + -Djava.awt.headless=true ${surefire.memory.settings} ${surefire.system.args} -Duser.language=en -Duser.region=US -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError alphabetical false diff --git a/quarkus/tests/integration/pom.xml b/quarkus/tests/integration/pom.xml index 924032aca63..f9410615037 100644 --- a/quarkus/tests/integration/pom.xml +++ b/quarkus/tests/integration/pom.xml @@ -108,7 +108,7 @@ org.apache.maven.plugins maven-surefire-plugin - -Djdk.net.hosts.file=${project.build.testOutputDirectory}/hosts_file + -Djdk.net.hosts.file=${project.build.testOutputDirectory}/hosts_file -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError ${kc.quarkus.tests.dist} @@ -162,7 +162,7 @@ org.apache.maven.plugins maven-surefire-plugin - -Xmx1024m -XX:MaxMetaspaceSize=512m + -Xmx1024m -XX:MaxMetaspaceSize=512m -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError true diff --git a/saml-core/pom.xml b/saml-core/pom.xml index 75a40c9528a..15092993dbb 100755 --- a/saml-core/pom.xml +++ b/saml-core/pom.xml @@ -104,7 +104,7 @@ with-security-manager-all-permissions test - -Dmaven.basedir=${basedir} -Djava.security.manager -Djava.security.policy=${basedir}/src/test/resources/all-permissions.policy + -Dmaven.basedir=${basedir} -Djava.security.manager -Djava.security.policy=${basedir}/src/test/resources/all-permissions.policy -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError SecurityActionsTest ${skip.security-manager.tests} @@ -113,7 +113,7 @@ with-security-manager-named-permissions test - -Djava.security.debug=access -Dmaven.basedir=${basedir} -Djava.security.manager -Djava.security.policy=${basedir}/src/test/resources/named-permissions.policy + -Djava.security.debug=access -Dmaven.basedir=${basedir} -Djava.security.manager -Djava.security.policy=${basedir}/src/test/resources/named-permissions.policy -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError SecurityActionsTest ${skip.security-manager.tests} diff --git a/server-spi-private/pom.xml b/server-spi-private/pom.xml index 5d927bdde47..31c459a2d7d 100755 --- a/server-spi-private/pom.xml +++ b/server-spi-private/pom.xml @@ -92,7 +92,8 @@ - -Dfile.encoding=UTF-8 + + -Dfile.encoding=UTF-8 -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError diff --git a/testsuite/model/pom.xml b/testsuite/model/pom.xml index 2cdfeb75bed..f128a34bdc3 100644 --- a/testsuite/model/pom.xml +++ b/testsuite/model/pom.xml @@ -160,7 +160,7 @@ org.apache.maven.plugins maven-surefire-plugin - @{argLine} + @{argLine} -Xmx1024m -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError