Skip to content

Commit 5a77e8e

Browse files
authored
Adjust test settings to gather timing data (#3683)
* Update unit test settings make it closer to the updated integration_tests.sh settings * Add additional logging for test timing e.g. [cloudfoundry-identity-metrics-data] Unit tests completed: 42 tests, 42 passed, 0 failed, 0 skipped in 6978ms SLOW TEST: org.cloudfoundry.identity.uaa.performance.LoginPagePerformanceMockMvcTest.idpDiscoveryRedirectsToOIDCProvider(JdbcIdentityProviderProvisioning) took 32292ms * Adjust metaspace size This doc shows the default is 384m https://docs.gradle.org/9.2.0/userguide/config_gradle.html#sec:configuring_jvm_memory Seeing the following message: The Daemon will expire after the build after running out of JVM Metaspace. The project memory settings are likely not configured or are configured to an insufficient value. The daemon will restart for the next build, which may increase subsequent build times. These settings can be adjusted by setting 'org.gradle.jvmargs' in 'gradle.properties'. The currently configured max heap space is '1 GiB' and the configured max metaspace is '128 MiB'. For more information on how to set these values, please refer to https://docs.gradle.org/9.2.0/userguide/build_environment.html#sec:configuring_jvm_memory in the Gradle documentation. To disable this warning, set 'org.gradle.daemon.performance.disable-logging=true'.
1 parent afc96e5 commit 5a77e8e

File tree

3 files changed

+84
-16
lines changed

3 files changed

+84
-16
lines changed

build.gradle

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,40 @@ subprojects {
112112
"-XX:HeapDumpPath=/var/log/uaa-tests.hprof"
113113
]
114114

115+
// Enable test timing to identify slow tests
116+
// This helps debug CI performance issues
117+
reports {
118+
junitXml.required = true
119+
html.required = true
120+
}
121+
115122
testLogging {
116123
events("failed")
117124
exceptionFormat = "full"
118-
// Uncomment the following line to see all standard output from tests (there's a ton of it!)
119-
//showStandardStreams = true
125+
// Set showStandardStreams=true to see all standard output from tests (there's a ton of it!)
126+
showStandardStreams = false
127+
showCauses = true
128+
showExceptions = true
129+
showStackTraces = true
130+
}
131+
132+
// Add system property to enable detailed test timing
133+
systemProperty("junit.jupiter.execution.timeout.default", System.getProperty("junit.jupiter.execution.timeout.default", "0"))
134+
135+
// Log slow tests to help identify bottlenecks
136+
afterTest { descriptor, result ->
137+
def duration = result.endTime - result.startTime
138+
if (duration > 10000) { // 10 seconds
139+
logger.warn("SLOW TEST: ${descriptor.className}.${descriptor.name} took ${duration}ms")
140+
}
141+
}
142+
143+
// Log summary of test execution times
144+
afterSuite { descriptor, result ->
145+
if (descriptor.parent == null) {
146+
def duration = result.endTime - result.startTime
147+
logger.lifecycle("[${project.name}] Unit tests completed: ${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped in ${duration}ms")
148+
}
120149
}
121150
}
122151

@@ -144,8 +173,30 @@ subprojects {
144173
testLogging {
145174
events("failed")
146175
exceptionFormat = "full"
147-
// Uncomment the following line to see all standard output from tests (there's a ton of it!)
148-
//showStandardStreams = true
176+
// Set showStandardStreams=true to see all standard output from tests (there's a ton of it!)
177+
showStandardStreams = false
178+
showCauses = true
179+
showExceptions = true
180+
showStackTraces = true
181+
}
182+
183+
// Add system property to enable detailed test timing
184+
systemProperty("junit.jupiter.execution.timeout.default", System.getProperty("junit.jupiter.execution.timeout.default", "0"))
185+
186+
// Log slow tests to help identify bottlenecks
187+
afterTest { descriptor, result ->
188+
def duration = result.endTime - result.startTime
189+
if (duration > 20000) { // 20 seconds
190+
logger.warn("SLOW TEST: ${descriptor.className}.${descriptor.name} took ${duration}ms")
191+
}
192+
}
193+
194+
// Log summary of test execution times
195+
afterSuite { descriptor, result ->
196+
if (descriptor.parent == null) {
197+
def duration = result.endTime - result.startTime
198+
logger.lifecycle("[${project.name}] Integration tests completed: ${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped in ${duration}ms")
199+
}
149200
}
150201
}
151202

scripts/integration_tests.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ function main() {
3636
# Increased Gradle daemon heap to 1GB to prevent hanging with 2 workers
3737
# --no-configuration-cache prevents stale Kotlin compiler state reuse between daemon processes
3838
# logging.manager is set to org.apache.logging.log4j.jul.LogManager to prevent log4j2 from using java.util.logging
39+
# See https://docs.gradle.org/9.2.0/userguide/config_gradle.html#sec:configuring_jvm_memory
3940
echo "Setting boot heap to ${jvm_heap:=640m}"
4041
echo "Setting boot metaspace to ${jvm_metaspace:=192m}"
4142
echo "Setting Gradle daemon heap to ${gradle_heap:=1024m}"
@@ -77,7 +78,7 @@ function main() {
7778
# Explicit Gradle daemon memory for Kotlin 2.2 with additional GC tuning
7879
readonly assemble_code="./gradlew '-Dspring.profiles.active=${test_profile}' \
7980
'-Djava.security.egd=file:/dev/./urandom' \
80-
'-Dorg.gradle.jvmargs=-Dfile.encoding=utf8 -Xms64m -Xmx${gradle_heap} -XX:MaxMetaspaceSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=100' \
81+
'-Dorg.gradle.jvmargs=-Dfile.encoding=utf8 -Xms64m -Xmx${gradle_heap} -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:MaxGCPauseMillis=100' \
8182
assemble \
8283
--no-watch-fs \
8384
--no-daemon \
@@ -93,7 +94,7 @@ function main() {
9394
'-Dspring.profiles.active=${test_profile}' \
9495
'-Djava.security.egd=file:/dev/./urandom' \
9596
'-DskipUaaAutoStart=true' \
96-
'-Dorg.gradle.jvmargs=-Dfile.encoding=utf8 -Xms64m -Xmx${gradle_test_heap} -XX:MaxMetaspaceSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:ParallelGCThreads=2 -XX:CICompilerCount=2 -Djdk.lang.processReaperUseDefaultStackSize=true' \
97+
'-Dorg.gradle.jvmargs=-Dfile.encoding=utf8 -Xms64m -Xmx${gradle_test_heap} -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:ParallelGCThreads=2 -XX:CICompilerCount=2 -Djdk.lang.processReaperUseDefaultStackSize=true' \
9798
'-Dorg.gradle.daemon.idletimeout=300000' \
9899
'-Dorg.gradle.parallel=false' \
99100
'-Dorg.gradle.workers.max=2' \

scripts/unit_tests.sh

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,37 @@ function main() {
2121
pushd "$(dirname ${script_dir})"
2222
start_ldap
2323

24-
set -x
25-
26-
./gradlew "-Dspring.profiles.active=${test_profile}" \
27-
"-Djava.security.egd=file:/dev/./urandom" \
28-
clean assemble compileTestJava \
29-
--stacktrace \
30-
--no-daemon \
31-
--console=plain
24+
# See https://docs.gradle.org/9.2.0/userguide/config_gradle.html#sec:configuring_jvm_memory
25+
echo "Setting Gradle daemon heap to ${gradle_heap:=1024m}"
26+
echo "Setting test worker heap to ${gradle_test_heap:=640m}"
27+
28+
set -x
29+
./gradlew -Dspring.profiles.active=${test_profile} \
30+
-Djava.security.egd=file:/dev/./urandom \
31+
"-Dorg.gradle.jvmargs=-Dfile.encoding=utf8 -Xms64m -Xmx${gradle_heap} -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:MaxGCPauseMillis=100" \
32+
clean assemble compileTestJava \
33+
--no-watch-fs \
34+
--no-daemon \
35+
--no-configuration-cache \
36+
--max-workers=2 \
37+
--stacktrace \
38+
--console=plain
3239

3340
./gradlew "-Dspring.profiles.active=${test_profile}" \
34-
"-Djava.security.egd=file:/dev/./urandom" \
41+
-Djava.security.egd=file:/dev/./urandom \
42+
"-Dorg.gradle.jvmargs=-Dfile.encoding=utf8 -Xms64m -Xmx${gradle_test_heap} -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:ParallelGCThreads=2 -XX:CICompilerCount=2 -Djdk.lang.processReaperUseDefaultStackSize=true" \
43+
-Dorg.gradle.daemon.idletimeout=300000 \
44+
-Dorg.gradle.parallel=false \
45+
-Dorg.gradle.workers.max=2 \
3546
${UAA_GRADLE_UNIT_TEST_COMMAND:-test} \
36-
--stacktrace \
47+
--no-watch-fs \
3748
--no-daemon \
49+
--no-configuration-cache \
50+
--max-workers=2 \
51+
--stacktrace \
3852
--console=plain
53+
54+
{ set +x; } 2>/dev/null
3955
popd
4056
}
4157

0 commit comments

Comments
 (0)