Skip to content

CAMEL-23431: Migrate AS2 tests from AvailablePortFinder to port-0 binding#22990

Merged
gnodet merged 1 commit intoapache:mainfrom
gnodet:CAMEL-23431-port0-binding
May 6, 2026
Merged

CAMEL-23431: Migrate AS2 tests from AvailablePortFinder to port-0 binding#22990
gnodet merged 1 commit intoapache:mainfrom
gnodet:CAMEL-23431-port0-binding

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 6, 2026

CAMEL-23431

Summary

Migrate AS2 test infrastructure from AvailablePortFinder to direct port-0 ServerSocket binding to eliminate the TOCTOU (time-of-check-to-time-of-use) race condition that causes flaky BindException failures in CI.

Production code changes:

  • Add getLocalPort() to AS2ServerConnection and AS2AsyncMDNServerConnection to expose the OS-assigned port after binding

Test changes (10 files):

  • AS2MessageTestBase, AS2MessageTest, AS2UnencryptedMessageTest: API tests now create servers with port 0 and read back the actual port
  • AS2AsyncMDNServerConnectionTest: Uses port 0 directly
  • AS2ServerManagerITBase, AS2ServerManagerIT, AS2ServerManagerEncryptedIT: Component tests use port 0 in configuration, read back actual port via doPostSetup()
  • AS2ServerSecTestBase: Same pattern for security test base class

Not migrated yet (follow-up):

  • 8 component tests that create their own "partner" servers require lifecycle restructuring (the port must be known before the Camel context starts). These still use AvailablePortFinder.find() with @RegisterExtension.

Test plan

  • mvn test in camel-as2-api — 94 tests pass
  • mvn test in camel-as2-component — 12 tests pass
  • CI green

…ding

Add getLocalPort() to AS2ServerConnection and AS2AsyncMDNServerConnection
to expose the OS-assigned port after binding. Migrate AS2 API tests and
component server tests to bind to port 0 and read back the actual port,
eliminating the TOCTOU race condition inherent in AvailablePortFinder.

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🧪 CI tested the following changed modules:

  • components/camel-as2/camel-as2-api
  • components/camel-as2/camel-as2-component
All tested modules (9 modules)
  • Camel :: AS2 :: API
  • Camel :: AS2 :: Component
  • Camel :: JBang :: 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

⚙️ View full build and test results

@gnodet gnodet marked this pull request as ready for review May 6, 2026 08:49
@gnodet gnodet requested review from davsclaus and oscerd May 6, 2026 08:49
@gnodet gnodet merged commit 10c8980 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants