MongoDBContainer: simplify loading and executing java script files to init DB#3869
MongoDBContainer: simplify loading and executing java script files to init DB#3869silaev wants to merge 51 commits intotestcontainers:mainfrom
Conversation
…nfiguration for consistency, Move configure() to be a part of constructors
…, use try-with-resources in test
… exception in case of any files in docker-entrypoint-initdb.d directory.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this. |
|
Hi @silaev, Thanks for your work to enhance the process of initialization data. Here is the snippet: private val container: MongoDBContainer = MongoDBContainer("mongo:latest")
.withCommand()
.withCopyFileToContainer(
MountableFile.forClasspathResource("init/init.js"),
"/docker-entrypoint-initdb.d/init.js"
)
.waitingFor(Wait.forLogMessage("(?i).*waiting for connections.*", 2))
.withStartupTimeout(Duration.ofSeconds(10)) |
Hey there, sorry for answering late. Yes, that's right. Pls, find more on it here |
|
Superseded by #11331 |
MongoDBContainerruns with the--replSetcommand-line option to support testing features available only for a replica set. At thedocker-entrypoint-initdb.d stage, a single replica set node is not yet initialised. For example, an attempt to write and read to non-initalised replica set leads toNotWritablePrimaryandNotPrimaryNoSecondaryOkerrors respectively. Therefore data manipulation might be done after initialisation stage.This PR simplifies loading and executing java script files after container start-up. It also adds the fail-fast extra check of the
docker-entrypoint-initdb.ddirectory to be empty before the initialisation of the replica set.