From 1b1cf266eb112e9520260db9a1905d429b689a4d Mon Sep 17 00:00:00 2001 From: Hynek Mlnarik Date: Thu, 28 Apr 2022 17:59:15 +0200 Subject: [PATCH] Add support for async profiler to model testsuite Fixes: #11743 --- testsuite/model/README.md | 50 ++++++++++++++++++++++++++++ testsuite/model/pom.xml | 12 +++++++ testsuite/model/test-all-profiles.sh | 2 +- 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 testsuite/model/README.md diff --git a/testsuite/model/README.md b/testsuite/model/README.md new file mode 100644 index 00000000000..c0cd5a2b710 --- /dev/null +++ b/testsuite/model/README.md @@ -0,0 +1,50 @@ +Model testsuite +=============== + +Model testsuite runs tests on raw `KeycloakSessionFactory` which is +initialized only with those providers that are explicitly enabled +in a used profile via `keycloak.model.parameters` system property. + +This allows writing tests and running those in different +configurations quickly, e.g. once with legacy JPA storage, +second time with purely new Hot Rod implementation. + +The valid parameters are names of classes in `org.keycloak.testsuite.model.parameters` +package, and it is possible to combine those by providing multiple class names +separated by comma. + +To simplify matters, common combinations of parameters are defined as maven profiles. + + +Test coverage +------------- + +To see test coverage via jacoco, set `jacoco.skip` property to `false`, e.g.: + +``` +mvn test -Pjpa -Dtest=ClientModelTest -Djacoco.skip=false +``` + +Then you can generate the coverage report by using the following command: + +``` +mvn org.jacoco:jacoco-maven-plugin:0.8.7:report \ + -Djacoco.skip=false -Djacoco.dataFile=target/jacoco.exec +``` + +The test coverage report is then available from `target/site/jacoco/index.html` file. + +Profiling +--------- + +If you have [Async Profiler](https://github.com/jvm-profiling-tools/async-profiler/) +installed, you can generate flame graphs of the test run for profiling purposes. +To do so, you set `libasyncProfilerPath` system property to the location of the +async profiler library: + +``` +mvn test -Pjpa -Dtest=ClientModelTest \ + -DlibasyncProfilerPath=/usr/local/async-profiler/build/libasyncProfiler.so +``` + +The results are available in the `target/profile.html` file. diff --git a/testsuite/model/pom.xml b/testsuite/model/pom.xml index e76d5960cce..0c725a1102a 100644 --- a/testsuite/model/pom.xml +++ b/testsuite/model/pom.xml @@ -308,6 +308,18 @@ + + .asyncProfiler + + libasyncProfilerPath + + + cpu + target/profile.html + -agentpath:${libasyncProfilerPath}=start,event=${asyncProfiler.event},file=${asyncProfiler.file} + + + diff --git a/testsuite/model/test-all-profiles.sh b/testsuite/model/test-all-profiles.sh index ca9930fe9c3..5d21c6ad2f6 100755 --- a/testsuite/model/test-all-profiles.sh +++ b/testsuite/model/test-all-profiles.sh @@ -11,7 +11,7 @@ mvn -version EXIT_CODE=0 mvn clean -for I in `perl -ne 'print "$1\n" if (m,([^<]+),)' pom.xml`; do +for I in `perl -ne 'print "$1\n" if (m,([^.<]+),)' pom.xml`; do echo "========" echo "======== Start of Profile $I" echo "========"