Fix flaky cron trigger test in SpringSchedulingTest#10792
Open
Fix flaky cron trigger test in SpringSchedulingTest#10792
Conversation
The "schedule trigger test according to cron expression" test was flaky because the cron expression (every 5 seconds) could fire a second time between blockUntilExecute() returning and the assertTraces() call completing, producing 3 or 4 traces instead of the expected 2. Fix by closing the Spring application context immediately after the first execution completes, before entering the expect block. The ScheduledTasksEndpoint bean reference is captured before closing so the endpoint assertion in the and: block still works. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… close The scheduledTaskEndpoint.scheduledTasks() call fails after context.close() because the endpoint is no longer available. Capture the cron tasks list in setup: before closing the context so the and: assertion block uses the pre-captured value. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 64 metrics, 7 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.61.0-SNAPSHOT~072361c6b5, baseline=1.61.0-SNAPSHOT~cc122288e5
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.068 s) : 0, 1067637
Total [baseline] (11.031 s) : 0, 11030659
Agent [candidate] (1.055 s) : 0, 1054724
Total [candidate] (10.931 s) : 0, 10930570
section appsec
Agent [baseline] (1.244 s) : 0, 1243853
Total [baseline] (11.222 s) : 0, 11222325
Agent [candidate] (1.244 s) : 0, 1244343
Total [candidate] (11.122 s) : 0, 11122183
section iast
Agent [baseline] (1.235 s) : 0, 1234507
Total [baseline] (11.353 s) : 0, 11353473
Agent [candidate] (1.229 s) : 0, 1228550
Total [candidate] (11.31 s) : 0, 11309653
section profiling
Agent [baseline] (1.18 s) : 0, 1180488
Total [baseline] (11.027 s) : 0, 11027227
Agent [candidate] (1.189 s) : 0, 1188770
Total [candidate] (11.019 s) : 0, 11019034
gantt
title petclinic - break down per module: candidate=1.61.0-SNAPSHOT~072361c6b5, baseline=1.61.0-SNAPSHOT~cc122288e5
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.222 ms) : 0, 1222
crashtracking [candidate] (1.185 ms) : 0, 1185
BytebuddyAgent [baseline] (631.675 ms) : 0, 631675
BytebuddyAgent [candidate] (626.883 ms) : 0, 626883
AgentMeter [baseline] (29.323 ms) : 0, 29323
AgentMeter [candidate] (29.087 ms) : 0, 29087
GlobalTracer [baseline] (258.211 ms) : 0, 258211
GlobalTracer [candidate] (256.59 ms) : 0, 256590
AppSec [baseline] (31.792 ms) : 0, 31792
AppSec [candidate] (31.502 ms) : 0, 31502
Debugger [baseline] (59.91 ms) : 0, 59910
Debugger [candidate] (59.342 ms) : 0, 59342
Remote Config [baseline] (596.677 µs) : 0, 597
Remote Config [candidate] (588.245 µs) : 0, 588
Telemetry [baseline] (8.645 ms) : 0, 8645
Telemetry [candidate] (8.571 ms) : 0, 8571
Flare Poller [baseline] (10.161 ms) : 0, 10161
Flare Poller [candidate] (4.992 ms) : 0, 4992
section appsec
crashtracking [baseline] (1.187 ms) : 0, 1187
crashtracking [candidate] (1.19 ms) : 0, 1190
BytebuddyAgent [baseline] (656.706 ms) : 0, 656706
BytebuddyAgent [candidate] (656.777 ms) : 0, 656777
AgentMeter [baseline] (11.991 ms) : 0, 11991
AgentMeter [candidate] (11.97 ms) : 0, 11970
GlobalTracer [baseline] (257.715 ms) : 0, 257715
GlobalTracer [candidate] (257.635 ms) : 0, 257635
IAST [baseline] (23.892 ms) : 0, 23892
IAST [candidate] (23.945 ms) : 0, 23945
AppSec [baseline] (177.336 ms) : 0, 177336
AppSec [candidate] (177.728 ms) : 0, 177728
Debugger [baseline] (65.683 ms) : 0, 65683
Debugger [candidate] (65.611 ms) : 0, 65611
Remote Config [baseline] (570.739 µs) : 0, 571
Remote Config [candidate] (573.007 µs) : 0, 573
Telemetry [baseline] (8.935 ms) : 0, 8935
Telemetry [candidate] (9.088 ms) : 0, 9088
Flare Poller [baseline] (3.606 ms) : 0, 3606
Flare Poller [candidate] (3.644 ms) : 0, 3644
section iast
crashtracking [baseline] (1.202 ms) : 0, 1202
crashtracking [candidate] (1.214 ms) : 0, 1214
BytebuddyAgent [baseline] (801.466 ms) : 0, 801466
BytebuddyAgent [candidate] (797.647 ms) : 0, 797647
AgentMeter [baseline] (11.591 ms) : 0, 11591
AgentMeter [candidate] (11.384 ms) : 0, 11384
GlobalTracer [baseline] (248.31 ms) : 0, 248310
GlobalTracer [candidate] (247.198 ms) : 0, 247198
IAST [baseline] (25.307 ms) : 0, 25307
IAST [candidate] (25.156 ms) : 0, 25156
AppSec [baseline] (26.592 ms) : 0, 26592
AppSec [candidate] (26.301 ms) : 0, 26301
Debugger [baseline] (64.334 ms) : 0, 64334
Debugger [candidate] (63.988 ms) : 0, 63988
Remote Config [baseline] (537.747 µs) : 0, 538
Remote Config [candidate] (543.857 µs) : 0, 544
Telemetry [baseline] (14.356 ms) : 0, 14356
Telemetry [candidate] (14.298 ms) : 0, 14298
Flare Poller [baseline] (4.785 ms) : 0, 4785
Flare Poller [candidate] (4.578 ms) : 0, 4578
section profiling
crashtracking [baseline] (1.174 ms) : 0, 1174
crashtracking [candidate] (1.186 ms) : 0, 1186
BytebuddyAgent [baseline] (681.519 ms) : 0, 681519
BytebuddyAgent [candidate] (687.343 ms) : 0, 687343
AgentMeter [baseline] (8.663 ms) : 0, 8663
AgentMeter [candidate] (8.653 ms) : 0, 8653
GlobalTracer [baseline] (215.461 ms) : 0, 215461
GlobalTracer [candidate] (216.733 ms) : 0, 216733
AppSec [baseline] (31.949 ms) : 0, 31949
AppSec [candidate] (32.246 ms) : 0, 32246
Debugger [baseline] (62.076 ms) : 0, 62076
Debugger [candidate] (64.056 ms) : 0, 64056
Remote Config [baseline] (584.286 µs) : 0, 584
Remote Config [candidate] (585.377 µs) : 0, 585
Telemetry [baseline] (11.284 ms) : 0, 11284
Telemetry [candidate] (9.727 ms) : 0, 9727
Flare Poller [baseline] (3.499 ms) : 0, 3499
Flare Poller [candidate] (3.541 ms) : 0, 3541
ProfilingAgent [baseline] (93.503 ms) : 0, 93503
ProfilingAgent [candidate] (93.558 ms) : 0, 93558
Profiling [baseline] (94.075 ms) : 0, 94075
Profiling [candidate] (94.125 ms) : 0, 94125
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.61.0-SNAPSHOT~072361c6b5, baseline=1.61.0-SNAPSHOT~cc122288e5
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.06 s) : 0, 1059518
Total [baseline] (8.85 s) : 0, 8849519
Agent [candidate] (1.057 s) : 0, 1057171
Total [candidate] (8.831 s) : 0, 8831240
section iast
Agent [baseline] (1.228 s) : 0, 1227577
Total [baseline] (9.544 s) : 0, 9543861
Agent [candidate] (1.228 s) : 0, 1228372
Total [candidate] (9.566 s) : 0, 9565513
gantt
title insecure-bank - break down per module: candidate=1.61.0-SNAPSHOT~072361c6b5, baseline=1.61.0-SNAPSHOT~cc122288e5
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.214 ms) : 0, 1214
crashtracking [candidate] (1.189 ms) : 0, 1189
BytebuddyAgent [baseline] (629.203 ms) : 0, 629203
BytebuddyAgent [candidate] (628.284 ms) : 0, 628284
AgentMeter [baseline] (29.197 ms) : 0, 29197
AgentMeter [candidate] (29.113 ms) : 0, 29113
GlobalTracer [baseline] (257.569 ms) : 0, 257569
GlobalTracer [candidate] (257.146 ms) : 0, 257146
AppSec [baseline] (31.771 ms) : 0, 31771
AppSec [candidate] (31.751 ms) : 0, 31751
Debugger [baseline] (58.8 ms) : 0, 58800
Debugger [candidate] (58.824 ms) : 0, 58824
Remote Config [baseline] (589.534 µs) : 0, 590
Remote Config [candidate] (590.491 µs) : 0, 590
Telemetry [baseline] (8.665 ms) : 0, 8665
Telemetry [candidate] (8.626 ms) : 0, 8626
Flare Poller [baseline] (6.423 ms) : 0, 6423
Flare Poller [candidate] (5.684 ms) : 0, 5684
section iast
crashtracking [baseline] (1.205 ms) : 0, 1205
crashtracking [candidate] (1.212 ms) : 0, 1212
BytebuddyAgent [baseline] (797.731 ms) : 0, 797731
BytebuddyAgent [candidate] (797.355 ms) : 0, 797355
AgentMeter [baseline] (11.282 ms) : 0, 11282
AgentMeter [candidate] (11.351 ms) : 0, 11351
GlobalTracer [baseline] (246.735 ms) : 0, 246735
GlobalTracer [candidate] (247.862 ms) : 0, 247862
IAST [baseline] (25.047 ms) : 0, 25047
IAST [candidate] (25.175 ms) : 0, 25175
AppSec [baseline] (26.324 ms) : 0, 26324
AppSec [candidate] (26.353 ms) : 0, 26353
Debugger [baseline] (62.84 ms) : 0, 62840
Debugger [candidate] (62.817 ms) : 0, 62817
Remote Config [baseline] (536.889 µs) : 0, 537
Remote Config [candidate] (531.528 µs) : 0, 532
Telemetry [baseline] (14.852 ms) : 0, 14852
Telemetry [candidate] (14.751 ms) : 0, 14751
Flare Poller [baseline] (4.925 ms) : 0, 4925
Flare Poller [candidate] (4.884 ms) : 0, 4884
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 3 performance regressions! Performance is the same for 15 metrics, 18 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.61.0-SNAPSHOT~072361c6b5, baseline=1.61.0-SNAPSHOT~cc122288e5
dateFormat X
axisFormat %s
section baseline
no_agent (18.263 ms) : 18072, 18454
. : milestone, 18263,
appsec (18.71 ms) : 18523, 18896
. : milestone, 18710,
code_origins (18.026 ms) : 17844, 18208
. : milestone, 18026,
iast (17.753 ms) : 17577, 17930
. : milestone, 17753,
profiling (18.869 ms) : 18682, 19057
. : milestone, 18869,
tracing (17.839 ms) : 17659, 18019
. : milestone, 17839,
section candidate
no_agent (18.036 ms) : 17851, 18221
. : milestone, 18036,
appsec (18.686 ms) : 18496, 18876
. : milestone, 18686,
code_origins (19.622 ms) : 19427, 19818
. : milestone, 19622,
iast (17.905 ms) : 17728, 18081
. : milestone, 17905,
profiling (19.75 ms) : 19548, 19953
. : milestone, 19750,
tracing (18.052 ms) : 17869, 18235
. : milestone, 18052,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.61.0-SNAPSHOT~072361c6b5, baseline=1.61.0-SNAPSHOT~cc122288e5
dateFormat X
axisFormat %s
section baseline
no_agent (1.185 ms) : 1173, 1197
. : milestone, 1185,
iast (3.265 ms) : 3225, 3306
. : milestone, 3265,
iast_FULL (6.014 ms) : 5953, 6075
. : milestone, 6014,
iast_GLOBAL (3.548 ms) : 3488, 3607
. : milestone, 3548,
profiling (2.075 ms) : 2056, 2093
. : milestone, 2075,
tracing (1.816 ms) : 1798, 1833
. : milestone, 1816,
section candidate
no_agent (1.171 ms) : 1160, 1183
. : milestone, 1171,
iast (3.207 ms) : 3166, 3247
. : milestone, 3207,
iast_FULL (6.04 ms) : 5978, 6101
. : milestone, 6040,
iast_GLOBAL (3.441 ms) : 3395, 3486
. : milestone, 3441,
profiling (1.999 ms) : 1980, 2018
. : milestone, 1999,
tracing (1.757 ms) : 1743, 1771
. : milestone, 1757,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 10 metrics, 2 unstable metrics. Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.61.0-SNAPSHOT~072361c6b5, baseline=1.61.0-SNAPSHOT~cc122288e5
dateFormat X
axisFormat %s
section baseline
no_agent (1.477 ms) : 1466, 1489
. : milestone, 1477,
appsec (2.536 ms) : 2480, 2591
. : milestone, 2536,
iast (2.27 ms) : 2201, 2339
. : milestone, 2270,
iast_GLOBAL (2.318 ms) : 2248, 2388
. : milestone, 2318,
profiling (2.118 ms) : 2061, 2175
. : milestone, 2118,
tracing (2.094 ms) : 2040, 2149
. : milestone, 2094,
section candidate
no_agent (1.477 ms) : 1465, 1488
. : milestone, 1477,
appsec (3.812 ms) : 3589, 4034
. : milestone, 3812,
iast (2.271 ms) : 2201, 2340
. : milestone, 2271,
iast_GLOBAL (2.306 ms) : 2237, 2376
. : milestone, 2306,
profiling (2.516 ms) : 2351, 2681
. : milestone, 2516,
tracing (2.074 ms) : 2021, 2128
. : milestone, 2074,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.61.0-SNAPSHOT~072361c6b5, baseline=1.61.0-SNAPSHOT~cc122288e5
dateFormat X
axisFormat %s
section baseline
no_agent (15.719 s) : 15719000, 15719000
. : milestone, 15719000,
appsec (15.082 s) : 15082000, 15082000
. : milestone, 15082000,
iast (18.158 s) : 18158000, 18158000
. : milestone, 18158000,
iast_GLOBAL (17.797 s) : 17797000, 17797000
. : milestone, 17797000,
profiling (14.999 s) : 14999000, 14999000
. : milestone, 14999000,
tracing (15.253 s) : 15253000, 15253000
. : milestone, 15253000,
section candidate
no_agent (15.344 s) : 15344000, 15344000
. : milestone, 15344000,
appsec (14.496 s) : 14496000, 14496000
. : milestone, 14496000,
iast (18.331 s) : 18331000, 18331000
. : milestone, 18331000,
iast_GLOBAL (17.864 s) : 17864000, 17864000
. : milestone, 17864000,
profiling (14.766 s) : 14766000, 14766000
. : milestone, 14766000,
tracing (15.425 s) : 15425000, 15425000
. : milestone, 15425000,
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Closes the Spring application context immediately after
blockUntilExecute()returns in theschedule trigger test according to cron expressiontest, preventing extra traces from a second cron execution from appearing before assertions complete.Also fixes a
ConditionNotSatisfiedErrorintroduced by the context close:scheduledTaskEndpoint.scheduledTasks()fails on a closed context, so the cron task list is now captured beforecontext.close()insetup:and the captured list is used in theand:assertion block.Motivation
The test
schedule trigger test according to cron expressionwas flaky (observed in CI). The root cause was a race condition: the cron fires every second, and if a second execution occurs betweenblockUntilExecute()returning andassertTraces()completing, the trace count assertion fails.Closing the context right after the first execution stops the scheduler, eliminating the race. The
scheduledTaskEndpointreference and cron task list are captured before the close so assertions still work correctly.Additional Notes
Both
src/testandsrc/latestDepTestvariants are fixed identically.Jira ticket: [N/A - flaky test fix]
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issue