Skip to content

Commit 8334278

Browse files
authored
Merge pull request #3703 from cloudfoundry/testnames
Streamline Gradle commands in test jobs rename jobs to make it easier to distinguish unit/int test runs Restore the ability to search for " failed" without these extra matches Inline Gradle and Java commands Escape profile setting
2 parents 463a9ee + c4f2ffb commit 8334278

File tree

5 files changed

+87
-95
lines changed

5 files changed

+87
-95
lines changed

.github/workflows/integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ permissions:
77
pull-requests: read
88

99
jobs:
10-
container-test-job:
10+
db-integration-test:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
fail-fast: false

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ permissions:
77
pull-requests: read
88

99
jobs:
10-
container-test-job:
10+
db-unit-test:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
fail-fast: false

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ subprojects {
144144
afterSuite { descriptor, result ->
145145
if (descriptor.parent == null) {
146146
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")
147+
def testLabel = result.testCount == 1 ? "unit-test" : "unit-tests"
148+
logger.lifecycle("[${project.name}] Completed ${result.testCount} ${testLabel} in ${duration}ms (passed=${result.successfulTestCount};failed=${result.failedTestCount};skipped=${result.skippedTestCount})")
148149
}
149150
}
150151
}
@@ -195,7 +196,8 @@ subprojects {
195196
afterSuite { descriptor, result ->
196197
if (descriptor.parent == null) {
197198
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+
def testLabel = result.testCount == 1 ? "integration-test" : "integration-tests"
200+
logger.lifecycle("[${project.name}] Completed ${result.testCount} ${testLabel} in ${duration}ms (passed=${result.successfulTestCount};failed=${result.failedTestCount};skipped=${result.skippedTestCount})")
199201
}
200202
}
201203
}

scripts/integration_tests.sh

Lines changed: 78 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -42,94 +42,53 @@ function main() {
4242
echo "Setting Gradle daemon heap to ${gradle_heap:=1024m}"
4343
echo "Setting test worker heap to ${gradle_test_heap:=640m}"
4444

45-
readonly launch_boot="nohup java \
46-
-XX:+UseG1GC \
47-
-XX:G1HeapRegionSize=1m \
48-
-Xms64m -Xmx${jvm_heap} \
49-
-XX:MaxMetaspaceSize=${jvm_metaspace} \
50-
-XX:MetaspaceSize=${jvm_metaspace} \
51-
-XX:+UseStringDeduplication \
52-
-XX:MaxGCPauseMillis=200 \
53-
-XX:+HeapDumpOnOutOfMemoryError \
54-
-XX:HeapDumpPath=${wd} \
55-
-DCLOUDFOUNDRY_CONFIG_PATH=${wd}/scripts/boot \
56-
-Dlogging.config=${wd}/scripts/boot/log4j2.properties \
57-
-Dlog4j.configurationFile=${wd}/scripts/boot/log4j2.properties \
58-
-Dlog4j2.formatMsgNoLookups=true \
59-
-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager \
60-
-DSECRETS_DIR=${wd}/scripts/boot \
61-
-Djava.security.egd=file:/dev/./urandom \
62-
-Djava.io.tmpdir=${temp_dir} \
63-
-Dorg.bouncycastle.native.loader.install_dir=${temp_dir} \
64-
-Dmetrics.perRequestMetrics=true \
65-
-Dserver.servlet.context-path=/uaa \
66-
-Dserver.tomcat.basedir=${wd}/scripts/boot/tomcat \
67-
-Dsmtp.host=localhost \
68-
-Dsmtp.port=2525 \
69-
-Dspring.profiles.active=${test_profile} \
70-
-Dstatsd.enabled=true \
71-
-Dfile.encoding=UTF-8 \
72-
-Duser.country=US \
73-
-Duser.language=en \
74-
-Duser.variant \
75-
-jar ${wd}/uaa/build/libs/cloudfoundry-identity-uaa-0.0.0.war \
76-
> boot.log 2>&1 &"
77-
78-
# Explicit Gradle daemon memory for Kotlin 2.2 with additional GC tuning
79-
readonly assemble_code="./gradlew '-Dspring.profiles.active=${test_profile}' \
80-
'-Djava.security.egd=file:/dev/./urandom' \
81-
'-Dorg.gradle.jvmargs=-Dfile.encoding=utf8 -Xms64m -Xmx${gradle_heap} -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:MaxGCPauseMillis=100' \
82-
assemble \
83-
--no-watch-fs \
84-
--no-daemon \
85-
--no-configuration-cache \
86-
--max-workers=2 \
87-
--stacktrace \
88-
--console=plain"
89-
90-
# Explicit memory limits for test JVMs with GC tuning and classloader fixes
91-
# All flags required to prevent classloading deadlocks and thread starvation during test init
92-
# --no-configuration-cache prevents stale Kotlin compiler state reuse between daemon processes
93-
readonly compile_test_code="./gradlew \
94-
'-Dspring.profiles.active=${test_profile}' \
95-
'-Djava.security.egd=file:/dev/./urandom' \
96-
'-DskipUaaAutoStart=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' \
98-
'-Dorg.gradle.daemon.idletimeout=300000' \
99-
'-Dorg.gradle.parallel=false' \
100-
'-Dorg.gradle.workers.max=2' \
101-
clean assemble compileTestJava \
102-
--no-watch-fs \
103-
--no-daemon \
104-
--no-configuration-cache \
105-
--max-workers=2 \
106-
--stacktrace \
107-
--console=plain"
108-
109-
# Explicit memory limits for test JVMs with GC tuning and classloader fixes
110-
# All flags required to prevent classloading deadlocks and thread starvation during test init
111-
readonly integration_test_code="./gradlew \
112-
'-Dspring.profiles.active=${test_profile}' \
113-
'-Djava.security.egd=file:/dev/./urandom' \
114-
'-DskipUaaAutoStart=true' \
115-
'-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' \
116-
'-Dorg.gradle.daemon.idletimeout=300000' \
117-
'-Dorg.gradle.parallel=false' \
118-
'-Dorg.gradle.workers.max=2' \
119-
${UAA_GRADLE_INT_TEST_COMMAND:-integrationTest} \
120-
--no-watch-fs \
121-
--no-daemon \
122-
--no-configuration-cache \
123-
--max-workers=2 \
124-
--stacktrace \
125-
--console=plain"
126-
12745
if [[ "${RUN_TESTS:-true}" = 'true' ]]; then
12846
set -x
129-
eval "$assemble_code"
47+
# Explicit Gradle daemon memory with additional GC tuning
48+
./gradlew -Dspring.profiles.active="${test_profile}" \
49+
-Djava.security.egd=file:/dev/./urandom \
50+
-Dorg.gradle.jvmargs="-Dfile.encoding=utf8 -Xms64m -Xmx${gradle_heap} -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:MaxGCPauseMillis=100" \
51+
assemble \
52+
--no-watch-fs \
53+
--no-daemon \
54+
--no-configuration-cache \
55+
--max-workers=2 \
56+
--stacktrace \
57+
--console=plain
13058

13159
# Start and ensure the boot server is running before integration tests
132-
eval "$launch_boot"
60+
nohup java \
61+
-XX:+UseG1GC \
62+
-XX:G1HeapRegionSize=1m \
63+
-Xms64m -Xmx${jvm_heap} \
64+
-XX:MaxMetaspaceSize=${jvm_metaspace} \
65+
-XX:MetaspaceSize=${jvm_metaspace} \
66+
-XX:+UseStringDeduplication \
67+
-XX:MaxGCPauseMillis=200 \
68+
-XX:+HeapDumpOnOutOfMemoryError \
69+
-XX:HeapDumpPath="${wd}" \
70+
-DCLOUDFOUNDRY_CONFIG_PATH="${wd}/scripts/boot" \
71+
-Dlogging.config="${wd}/scripts/boot/log4j2.properties" \
72+
-Dlog4j.configurationFile="${wd}/scripts/boot/log4j2.properties" \
73+
-Dlog4j2.formatMsgNoLookups=true \
74+
-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager \
75+
-DSECRETS_DIR="${wd}/scripts/boot" \
76+
-Djava.security.egd=file:/dev/./urandom \
77+
-Djava.io.tmpdir="${temp_dir}" \
78+
-Dorg.bouncycastle.native.loader.install_dir="${temp_dir}" \
79+
-Dmetrics.perRequestMetrics=true \
80+
-Dserver.servlet.context-path=/uaa \
81+
-Dserver.tomcat.basedir="${wd}/scripts/boot/tomcat" \
82+
-Dsmtp.host=localhost \
83+
-Dsmtp.port=2525 \
84+
-Dspring.profiles.active="${test_profile}" \
85+
-Dstatsd.enabled=true \
86+
-Dfile.encoding=UTF-8 \
87+
-Duser.country=US \
88+
-Duser.language=en \
89+
-Duser.variant \
90+
-jar "${wd}/uaa/build/libs/cloudfoundry-identity-uaa-0.0.0.war" \
91+
> boot.log 2>&1 &
13392
echo $! > boot.pid
13493
{ set +x; } 2>/dev/null
13594

@@ -144,9 +103,36 @@ function main() {
144103
if [[ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ]]; then
145104
export DBUS_SESSION_BUS_ADDRESS=/dev/null
146105
fi
106+
147107
set -x
148-
eval "$compile_test_code"
149-
eval "$integration_test_code"
108+
# Explicit memory limits for test JVMs with GC tuning and classloader fixes
109+
# All flags required to prevent classloading deadlocks and thread starvation during test init
110+
# --no-configuration-cache prevents stale Kotlin compiler state reuse between daemon processes
111+
./gradlew \
112+
-Dspring.profiles.active="${test_profile}" \
113+
-DskipUaaAutoStart=true \
114+
--no-daemon \
115+
--no-configuration-cache \
116+
compileTestJava
117+
118+
# Explicit memory limits for test JVMs with GC tuning and classloader fixes
119+
# All flags required to prevent classloading deadlocks and thread starvation during test init
120+
./gradlew \
121+
-Dspring.profiles.active="${test_profile}" \
122+
-Djava.security.egd=file:/dev/./urandom \
123+
-DskipUaaAutoStart=true \
124+
-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" \
125+
-Dorg.gradle.daemon.idletimeout=300000 \
126+
-Dorg.gradle.parallel=false \
127+
-Dorg.gradle.workers.max=2 \
128+
${UAA_GRADLE_INT_TEST_COMMAND:-integrationTest} \
129+
--no-watch-fs \
130+
--no-daemon \
131+
--no-configuration-cache \
132+
--max-workers=2 \
133+
--stacktrace \
134+
--console=plain
135+
150136
{ set +x; } 2>/dev/null
151137

152138
# Clean up: kill the boot server
@@ -158,10 +144,14 @@ function main() {
158144
fi
159145
else
160146
set -x
161-
echo "$integration_test_code"
147+
echo "./gradlew \
148+
-Dspring.profiles.active=${test_profile} \
149+
-DskipUaaAutoStart=true \
150+
${UAA_GRADLE_INT_TEST_COMMAND:-integrationTest} \
151+
--console=plain"
162152
bash
163153
fi
164154
popd
165155
}
166156

167-
main "$@"
157+
main "$@"

scripts/unit_tests.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ function main() {
2626
echo "Setting test worker heap to ${gradle_test_heap:=640m}"
2727

2828
set -x
29-
./gradlew -Dspring.profiles.active=${test_profile} \
29+
./gradlew -Dspring.profiles.active="${test_profile}" \
3030
-Djava.security.egd=file:/dev/./urandom \
3131
"-Dorg.gradle.jvmargs=-Dfile.encoding=utf8 -Xms64m -Xmx${gradle_heap} -XX:MaxMetaspaceSize=384m -XX:+UseG1GC -XX:MaxGCPauseMillis=100" \
32-
clean assemble compileTestJava \
32+
clean compileTestJava \
3333
--no-watch-fs \
3434
--no-daemon \
3535
--no-configuration-cache \
3636
--max-workers=2 \
3737
--stacktrace \
3838
--console=plain
3939

40-
./gradlew "-Dspring.profiles.active=${test_profile}" \
40+
./gradlew -Dspring.profiles.active="${test_profile}" \
4141
-Djava.security.egd=file:/dev/./urandom \
4242
"-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" \
4343
-Dorg.gradle.daemon.idletimeout=300000 \

0 commit comments

Comments
 (0)