You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/07/27 09:07:56 UTC

[PR] CAMEL-22000: Fix flaky EventBridge LocalStack integration tests [camel]

gnodet opened a new pull request, #25148:
URL: https://github.com/apache/camel/pull/25148

   ## Summary
   
   _Claude Code on behalf of gnodet_
   
   All EventBridge IT tests share a singleton LocalStack container but use the same hardcoded rule name `"firstrule"` without consistent cleanup. This causes ~40% CI failure rate across 5 tests:
   - `EventbridgeEnableRuleIT`
   - `EventbridgeListRulesIT`
   - `EventbridgeListTargetsByRuleIT`
   - `EventbridgePutRuleIT`
   - `EventbridgeRemoveTargetsIT`
   
   ### Root cause
   
   | Factor | EventBridge (flaky) | SQS/SNS/S3 (stable) |
   |--------|-------------------|---------------------|
   | Container | Singleton | Singleton or per-class |
   | Resource names | Hardcoded `"firstrule"` | Unique per test (`SharedNameGenerator`) |
   | Cleanup hooks | None | `@AfterEach` in base or scoped by unique names |
   | Count assertions | Global `assertEquals(1, resp.rules().size())` | Scoped to own resources |
   
   When tests run in an unfavorable order, a prior test's leftover `"firstrule"` rule (with potentially different state — DISABLED, targets removed, etc.) causes the next test's assertions to fail. The NPE (`resp is null`) happens when a prerequisite operation fails silently (exchange exception not checked) and the response body can't be converted to the expected type.
   
   ### Fix
   
   Add `@BeforeEach cleanUpEventBridgeRules()` in `Aws2EventbridgeBase` that:
   1. Lists all rules on the default event bus
   2. For each rule: removes its targets, then deletes the rule
   3. Wraps each step in try-catch to avoid failing the test on cleanup errors
   
   This ensures every test class starts with a clean EventBridge state, regardless of what the previous test left behind — matching the isolation patterns used by stable AWS IT tests.
   
   ## Test plan
   
   - [x] Unit tests pass (`mvn test` — 25/25)
   - [x] Source format check passes (`mvn -Psourcecheck validate`)
   - [ ] IT tests pass with Docker (CI will verify this)
   - [ ] Run CI multiple times to confirm flakiness is resolved
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22000: Fix flaky EventBridge integration tests [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25148:
URL: https://github.com/apache/camel/pull/25148#issuecomment-5089992406

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `components/camel-aws/camel-aws2-eventbridge`
   
   ---
   
   <details><summary>:microscope: Scalpel shadow comparison — Scalpel: 1 tested, 0 compile-only — current: 9 all tested</summary>
   
   [Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **1 affected modules** (current approach: 9).
   
   <details><summary>Modules only in current approach (8)</summary>
   
   - `camel-jbang-mcp`
   - `camel-jbang-plugin-mcp`
   - `camel-jbang-plugin-route-parser`
   - `camel-jbang-plugin-tui`
   - `camel-jbang-plugin-validate`
   - `camel-launcher-container`
   - `camel-yaml-dsl-validator`
   - `camel-yaml-dsl-validator-maven-plugin`
   
   </details>
   
   **Skip-tests mode would test 1 modules** (1 direct + 0 downstream), **skip tests for 0** (generated code, meta-modules)
   
   <details><summary>Modules Scalpel would test (1)</summary>
   
   - `camel-aws2-eventbridge`
   
   </details>
   
   > :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
   
   </details>
   
   <details><summary>All tested modules (9 modules)</summary>
   
   - Camel :: AWS2 Eventbridge
   - Camel :: JBang :: MCP
   - Camel :: JBang :: Plugin :: MCP
   - Camel :: JBang :: Plugin :: Route Parser
   - Camel :: JBang :: Plugin :: TUI
   - Camel :: JBang :: Plugin :: Validate
   - Camel :: Launcher :: Container
   - Camel :: YAML DSL :: Validator
   - Camel :: YAML DSL :: Validator Maven Plugin
   
   </details>
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/30254528615)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22000: Fix flaky EventBridge integration tests [camel]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on PR #25148:
URL: https://github.com/apache/camel/pull/25148#issuecomment-5114875444

   We can notice that the eventbridge tests started to be flaky recently. it was very stable before that.
   
   https://develocity.apache.org/scans/tests?search.query=project:camel%20tag:main&search.relativeStartTime=P90D&search.timeZoneId=Europe%2FParis&tests.container=*eventbridge*&tests.sortField=FLAKY
   <img width="1852" height="814" alt="image" src="https://github.com/user-attachments/assets/4b5ad94f-9574-45f9-bf34-d5ad373a2082" />
   I think we should search for the root cause
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22000: Fix flaky EventBridge integration tests [camel]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet closed pull request #25148: CAMEL-22000: Fix flaky EventBridge integration tests
URL: https://github.com/apache/camel/pull/25148


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22000: Fix flaky EventBridge integration tests [camel]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #25148:
URL: https://github.com/apache/camel/pull/25148#issuecomment-5115283554

   _Claude Code on behalf of forgebot-oss_
   
   Great detective work @apupier — the Develocity data pinpoints the root cause precisely.
   
   ## Root Cause
   
   The flakiness was introduced by **36fc371f30d** (CAMEL-21933, July 23) which re-enabled 3 previously-`@Disabled` tests: `EventbridgePutRuleIT`, `EventbridgePutEventsIT`, `EventbridgeRemoveTargetsIT`.
   
   Before that commit, only 5 EventBridge tests ran. After it, 8 tests run — all sharing:
   - The **same singleton floci container**
   - The **same hardcoded rule name** `"firstrule"`
   - **No `@BeforeEach` cleanup** between test classes
   
   When JUnit picks a different execution order, leftover rules from one test class cause assertions in subsequent test classes to fail (wrong rule count, wrong rule state, etc.). The `apache5-client` migration (85b160636e3, July 22) is **not** the cause — the Develocity chart shows tests were still stable that day.
   
   ## Why our fix addresses the root cause
   
   The `@BeforeEach` cleanup + write-based readiness probe in `Aws2EventbridgeBase` directly solves the shared-state interference introduced by running more test classes against the same container:
   
   1. **Write-based readiness probe** — confirms `putRule` works (not just `listRules`) before tests run, addressing the service initialization timing gap
   2. **Pre-test cleanup** — removes all rules from the default event bus before each test class, isolating tests from leftover state regardless of execution order
   
   This is the standard pattern used by other stable AWS tests in this project (e.g., SQS, SNS, S3 all have cleanup in their base classes).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22000: Fix flaky EventBridge LocalStack integration tests [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25148:
URL: https://github.com/apache/camel/pull/25148#issuecomment-5089614225

   :star2: Thank you for your contribution to the Apache Camel project! :star2:
     :robot: CI automation will test this PR automatically.
   
     :camel: 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](https://camel.apache.org/community/team/#committers) have access to the summary.
     
     :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22000: Fix flaky EventBridge integration tests [camel]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #25148:
URL: https://github.com/apache/camel/pull/25148#issuecomment-5092364717

   _Claude Code on behalf of gnodet_
   
   Thanks for the local test results @apupier — that pinpointed the issue. The `listRules` readiness check was too weak: the container health check passes and reads succeed **before write operations like `putRule` are ready**.
   
   Pushed a46ac59: the readiness probe now does a real `putRule` + `deleteRule` cycle (Awaitility, 30s timeout) to confirm the service accepts writes before any test runs. The read-only `listRules` check is replaced entirely.
   
   Locally verified: **5/5 runs, 40 tests, zero failures** over 5 minutes with the singleton container.
   
   Could you please re-test on your machine with this latest change?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22000: Fix flaky EventBridge integration tests [camel]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on PR #25148:
URL: https://github.com/apache/camel/pull/25148#issuecomment-5114899455

   some commits related to aws close to this date:
   * https://github.com/apache/camel/commit/85b160636e3a379dbbb418355c56ab8bd17b82e4
   * https://github.com/apache/camel/commit/36fc371f30d9876bd42a487e9d10176ac8b79170
   * https://github.com/apache/camel/commit/a96c384a2bfae3fcd55bef99eb9405aaa8a560a6
   * https://github.com/apache/camel/commit/6dd43e0e8b846322afaba2a9a6d7dd8b347440fc
   * https://github.com/apache/camel/commit/ba83ac2009168c1d8a214dd738d9478300e23b51


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22000: Fix flaky EventBridge integration tests [camel]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on PR #25148:
URL: https://github.com/apache/camel/pull/25148#issuecomment-5115488227

   this is nto working because tests are runn in // too. We need to modify ids and check for correct ones, potentially isolate some of them. i started to work on it


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22000: Fix flaky EventBridge integration tests [camel]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on PR #25148:
URL: https://github.com/apache/camel/pull/25148#issuecomment-5117106676

   see https://github.com/apache/camel/pull/25219


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22000: Fix flaky EventBridge integration tests [camel]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #25148:
URL: https://github.com/apache/camel/pull/25148#issuecomment-5090164495

   @apupier Thank you for running the tests locally — that's really helpful since CI doesn't exercise the EventBridge IT tests.
   
   The failures you reported (`mock://result Received message count. Expected: <1> but was: <0>`) point to a **service readiness issue**: the container health check passes before the EventBridge service is fully initialized, so the first `putRule` calls fail silently (exchange exception not checked by the tests → mock never receives a message).
   
   I've pushed a fix that adds an **Awaitility-based readiness check** in the `@BeforeEach` method. Before cleaning up rules and running the test, it now polls `listRules` for up to 30 seconds (with 2-second intervals) until the EventBridge service actually accepts requests. This ensures the service is ready before any test operation.
   
   Could you try running the tests again with this latest commit? The combination of readiness check + cleanup should address both the service initialization flakiness and the shared-state interference.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22000: Fix flaky EventBridge integration tests [camel]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #25148:
URL: https://github.com/apache/camel/pull/25148#issuecomment-5089699144

   @apupier Thanks for the correction! You're right — the test infrastructure now uses floci (`mirror.gcr.io/floci/floci`) instead of LocalStack. I've updated the Javadoc comment and the PR title/description to reflect this.
   
   The fix itself is container-agnostic — it adds `@BeforeEach` cleanup of EventBridge rules via the AWS SDK client, which works the same regardless of whether the backing service is floci or LocalStack.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org