Skip to content

CAMEL-23899: Fix flaky test LogWriterRollOverUpdateAsyncWithContentionTest#24416

Merged
gnodet merged 3 commits into
apache:mainfrom
gnodet:camel-23899-fix-flaky-test-logwriterrolloverupdat
Jul 4, 2026
Merged

CAMEL-23899: Fix flaky test LogWriterRollOverUpdateAsyncWithContentionTest#24416
gnodet merged 3 commits into
apache:mainfrom
gnodet:camel-23899-fix-flaky-test-logwriterrolloverupdat

Conversation

@gnodet

@gnodet gnodet commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the flaky test LogWriterRollOverUpdateAsyncWithContentionTest.testReadWriteUpdateRecordsWithRollOver in camel-wal.

Root cause: runTest() only waited for the generate task to complete (via a CountDownLatch) before reading the log file and asserting all entries were in PROCESSED state. The update task — which marks records as committed — could still be running, causing assertions to fail on entries still in NEW state. This was especially pronounced with larger queue capacities (3000, 4000) where the producer finishes quickly while the consumer is still draining the queue.

Fix:

  • Replace the insufficient latch-based synchronization with Awaitility to wait for both the generate and update tasks to complete via ExecutorService termination
  • Flush the LogWriter before reading to ensure all data is persisted to disk before verification
  • Wrap the test body in a try-finally to ensure executor shutdown and prevent thread leaks on failure
  • Remove the now-unused CountDownLatch field and latch.countDown() calls from both subclass tests

Test plan

  • LogWriterRollOverUpdateAsyncWithContentionTest passes all 8 parameterized cases
  • Ran the flaky test 6 times (48 total cases) with 0 failures
  • LogWriterRollOverUpdateAsyncTest (sibling test) passes without regression
  • Full camel-wal test suite passes (23 tests, 0 failures)

Claude Code on behalf of Guillaume Nodet

🤖 Generated with Claude Code

…nTest

The test was flaky because runTest() only waited for the generate task
to complete (via a CountDownLatch) before reading the log file and
asserting all entries were PROCESSED. The update task, which marks
records as committed, could still be running - causing assertions to
fail on entries still in NEW state.

Fix: Replace the insufficient latch-based synchronization with
Awaitility to wait for both the generate and update tasks to complete
via ExecutorService termination. Also flush the LogWriter before
reading to ensure all data is persisted to disk.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet requested review from davsclaus and orpiske July 4, 2026 15:17
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

🌟 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 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-wal

🔬 Scalpel shadow comparison — Scalpel: 1 tested, 0 compile-only — current: 9 all tested

Maveniverse Scalpel detected 1 affected modules (current approach: 9).

Modules only in current approach (8)
  • 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

Skip-tests mode would test 1 modules (1 direct + 0 downstream), skip tests for 0 (generated code, meta-modules)

Modules Scalpel would test (1)
  • camel-wal

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (9 modules)
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Launcher :: Container
  • Camel :: WAL
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@gnodet gnodet requested a review from Copilot July 4, 2026 15:41
@gnodet gnodet marked this pull request as ready for review July 4, 2026 15:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR stabilizes the camel-wal async rollover/update tests by ensuring verification only starts after both the record-generation and record-update tasks have completed, preventing races where entries are still in NEW state.

Changes:

  • Remove the latch-based “generate-only” synchronization from the async test subclasses.
  • In the shared base test, wait for executor termination using Awaitility and propagate task failures via Future.get().
  • Flush LogWriter before reading back the file to verify persisted entry states.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
components/camel-wal/src/test/java/org/apache/camel/component/wal/LogWriterRollOverUpdateAsyncWithContentionTest.java Removes latch countdown from async generation path to rely on base-class task completion waiting.
components/camel-wal/src/test/java/org/apache/camel/component/wal/LogWriterRollOverUpdateAsyncTest.java Removes latch countdown from async generation path to rely on base-class task completion waiting.
components/camel-wal/src/test/java/org/apache/camel/component/wal/LogWriterRollOverUpdateAsyncBase.java Replaces latch wait with Awaitility-based executor termination wait, propagates async exceptions, and flushes before verification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

gnodet and others added 2 commits July 4, 2026 17:57
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Wrap the test body in a try-finally to ensure the executor service
is always forcefully shut down, preventing thread leaks if Awaitility
times out or another runtime failure occurs before termination.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet merged commit 64ce213 into apache:main Jul 4, 2026
5 checks passed
@gnodet gnodet deleted the camel-23899-fix-flaky-test-logwriterrolloverupdat branch July 4, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants