Commit dbb0729
Fix flaky cron trigger test in SpringSchedulingTest (#10792)
Fix flaky cron trigger test by closing context before assertions
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>
Fix ConditionNotSatisfiedError by capturing cron tasks before context 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>
Add deterministic reproduction delay to Spring scheduling cron test
After closing the Spring context (which stops the scheduler), add a sleep
longer than the cron interval to prove that no extra traces appear even
under worst-case timing. This makes the previously-flaky race condition
fully deterministic: without context.close(), the sleep guarantees extra
cron executions; with it, the scheduler is stopped and assertions pass.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update dd-java-agent/instrumentation/spring/spring-scheduling-3.1/src/latestDepTest/groovy/SpringSchedulingTest.groovy
Update dd-java-agent/instrumentation/spring/spring-scheduling-3.1/src/test/groovy/SpringSchedulingTest.groovy
Merge branch 'master' into brian.marks/fix-spring-scheduling-flaky-test
Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>1 parent 2604968 commit dbb0729
File tree
2 files changed
+14
-8
lines changed- dd-java-agent/instrumentation/spring/spring-scheduling-3.1/src
- latestDepTest/groovy
- test/groovy
2 files changed
+14
-8
lines changedLines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
30 | 36 | | |
31 | 37 | | |
32 | 38 | | |
| |||
54 | 60 | | |
55 | 61 | | |
56 | 62 | | |
57 | | - | |
58 | 63 | | |
59 | | - | |
| 64 | + | |
60 | 65 | | |
61 | 66 | | |
62 | | - | |
63 | | - | |
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
| |||
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
30 | 36 | | |
31 | 37 | | |
32 | 38 | | |
| |||
54 | 60 | | |
55 | 61 | | |
56 | 62 | | |
57 | | - | |
58 | 63 | | |
59 | | - | |
| 64 | + | |
60 | 65 | | |
61 | 66 | | |
62 | | - | |
63 | | - | |
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
| |||
0 commit comments