Skip to content

CAMEL-22539: Fix and re-enable 13 flaky tests in camel-core#23020

Merged
gnodet merged 1 commit intoapache:mainfrom
gnodet:CAMEL-22539-fix-flaky-camel-core-tests
May 6, 2026
Merged

CAMEL-22539: Fix and re-enable 13 flaky tests in camel-core#23020
gnodet merged 1 commit intoapache:mainfrom
gnodet:CAMEL-22539-fix-flaky-camel-core-tests

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 6, 2026

CAMEL-22539

Summary

Fix and re-enable 13 flaky tests in core/camel-core that were disabled on CI via @DisabledIfSystemProperty(named = "ci.env.name"). Each test's root cause was analyzed and a structural fix applied rather than just increasing timeouts.

Fixes by category

Replace Thread.sleep with Awaitility:

  • AggregateProcessorTest: replaced Thread.sleep(5/10/150/250) with Awaitility.await().untilAsserted() to wait for completion timeout to fire before sending next message; increased completion timeouts 100→500ms
  • DefaultTimeoutMapTest: replaced Thread.sleep(50) with Awaitility poll loop in testDefaultTimeoutMapForcePurge
  • ConcurrentRequestsThrottlerTest: replaced Thread.sleep(INTERVAL) between throttle phases with Awaitility
  • ThrottlerTest: replaced Thread.sleep(INTERVAL + TOLERANCE) with Awaitility; increased timing slack 1000→3000ms; clean executor shutdown

Add synchronization for race conditions:

  • StopTimeoutRouteTest: added processingStarted CountDownLatch so test waits for async processing to begin before calling stopRoute

Replace timer with controlled sending:

  • AggregateLostGroupIssueTest: replaced fragile timer://foo?period=10 route with direct message sending loop — timer scheduling on slow CI caused completionTimeout to fire partial groups

Increase timeouts for synchronous processing:

  • AlbertoAggregatorTest: increased completionTimeout 100→2000ms and checker interval 10→100ms — the timeout is just a flush mechanism after synchronous split processing
  • AsyncProcessorAwaitManagerInterruptWithRedeliveryTest: increased redelivery delay 750→1500ms

Fix test isolation and ordering:

  • AggregatorWithBatchConsumingIssueTest: added @Isolated to prevent parallel test interference
  • CamelPostProcessorHelperSedaConsumePredicateTest: changed to expectedBodiesReceivedInAnyOrder — competing SEDA consumers have non-deterministic delivery order
  • FileConsumerPollStrategyStopOnRollbackTest: reset static mutable fields (counter, event) in @BeforeEach

Fix file consumer timing:

  • FileConsumerMoveFailureTest: increased initialDelay/delay to 100ms; replaced expectedFileExists with explicit Awaitility file existence checks

Fix resource leaks:

  • TrustManagersParametersTest: added @BeforeEach/@AfterEach to properly create and close CamelContext — leaked contexts left background threads running

Test plan

  • All 13 test classes (50 test methods) pass locally
  • 10 consecutive iterations (500 test executions) with zero failures
  • CI passes with all tests re-enabled

- AggregateProcessorTest: replace Thread.sleep with Awaitility, increase completion timeouts
- DefaultTimeoutMapTest: replace Thread.sleep with Awaitility poll loop
- StopTimeoutRouteTest: add CountDownLatch to synchronize async send with route stop
- AggregateLostGroupIssueTest: replace fragile timer with direct message sending
- AlbertoAggregatorTest: increase completionTimeout from 100ms to 2000ms
- AggregatorWithBatchConsumingIssueTest: add @isolated
- FileConsumerMoveFailureTest: increase polling delays, use Awaitility for file checks
- FileConsumerPollStrategyStopOnRollbackTest: reset static fields in @beforeeach
- ConcurrentRequestsThrottlerTest: replace Thread.sleep with Awaitility between phases
- ThrottlerTest: increase timing slack, replace Thread.sleep, clean executor shutdown
- AsyncProcessorAwaitManagerInterruptWithRedeliveryTest: increase redelivery delay
- CamelPostProcessorHelperSedaConsumePredicateTest: use expectedBodiesReceivedInAnyOrder
- TrustManagersParametersTest: properly create/close CamelContext per test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions github-actions Bot added the core label May 6, 2026
@gnodet gnodet marked this pull request as ready for review May 6, 2026 16:48
@gnodet gnodet requested review from davsclaus and oscerd May 6, 2026 16:49
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🧪 CI tested the following changed modules:

  • core/camel-core

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • core/camel-core: 2 test(s) disabled on GitHub Actions

⚙️ View full build and test results

@gnodet gnodet merged commit 9e5c829 into apache:main May 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants