CAMEL-24323: Fix MongoDB TLS test-infra cert copy for Testcontainers 2.x - #25284
Conversation
Replace directory classpath mapping with per-file withCopyFileToContainer calls so MongoDbSslConnectionIT can start the TLS mongod container. Add MongoDBLocalContainerTLSServiceTest and an insert+count TLS IT case. Co-authored-by: Cursor <cursoragent@cursor.com>
|
AI-generated comment on behalf of atiaomar1978-hub InvestigationCI failure in CAMEL-24323 showed Testcontainers failing during The TLS service introduced in CAMEL-23182 (#21951) used: .withClasspathResourceMapping(CERT_RESOURCE_PATH, "/etc/mongodb/ssl", BindMode.READ_ONLY)On Testcontainers 2.x (Camel uses FixSwitched to per-file copy (Kafka JAAS pattern): .withCopyFileToContainer(MountableFile.forClasspathResource(SERVER_CERT_RESOURCE), ...)
.withCopyFileToContainer(MountableFile.forClasspathResource(CA_CERT_RESOURCE), ...)Tests (all green locally)
Ready for review once CI completes. |
gnodet
left a comment
There was a problem hiding this comment.
The core fix is correct — switching from withClasspathResourceMapping directory mount to per-file withCopyFileToContainer + MountableFile.forClasspathResource for Testcontainers 2.x compatibility. This follows the same pattern used by other test-infra services (Kafka JAAS, TensorFlow Serving).
Highlights:
- The extracted constants (
CONTAINER_SSL_DIR,SERVER_CERT_RESOURCE,CA_CERT_RESOURCE) improve readability. - The new unit test verifies TLS command configuration and resource resolution.
Minor notes (non-blocking):
MongoDbSslConnectionITclass still has thepublicmodifier — per JUnit 5 conventions it should be package-private (since you're already modifying the file).- The descriptive assertion message was removed from
assertEquals— consider keeping or using AssertJ'sas()for better failure diagnostics. - Other test-infra services still use
withClasspathResourceMappingwith directory mounts (NATS TLS, Infinispan, etc.) — they may need similar migration. - CI should be verified once checks run on this branch.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of @gnodet
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 12 tested, 29 compile-only — current: 12 all testedMaveniverse Scalpel detected 41 affected modules (current approach: 12).
|
Summary
Fixes CAMEL-24323:
MongoDbSslConnectionITfails to start the TLS MongoDB Testcontainer with:Could not find the file / in containerRoot cause:
MongoDBLocalContainerTLSServicemapped an entire classpath directory viawithClasspathResourceMapping. Testcontainers 2.x uses a copy strategy for read-only classpath mappings that breaks on directory mounts in CI.Fix: Copy TLS cert files individually with
MountableFile.forClasspathResource+withCopyFileToContainer(same approach as other Camel test-infra services, e.g. Kafka JAAS config).Changes
MongoDBLocalContainerTLSService— per-file cert copy forserver.pemandca.pemMongoDBLocalContainerTLSServiceTest— classpath resource + MountableFile + TLS command config coverage (3 tests)MongoDbSslConnectionIT— addedtestInsertAndCountOverTlsround-trip assertionTest plan
mvn test -pl test-infra/camel-test-infra-mongodb -Dtest=MongoDBLocalContainerTLSServiceTestmvn test -pl components/camel-mongodb -am -Dtest=MongoDbSslConnectionIT(Docker)AI-generated PR description on behalf of atiaomar1978-hub
Made with Cursor