I'm running into an issue with a Spring Boot service running unit tests using JUnit5 and flapdoodle's embeddedMongo. My unit tests were running fine previously, both locally and in Jenkins. I'm trying to update to Java 17 and Spring Boot 2.6.3, and that's where I'm running into issues. With the latest version of embeddedMongo, my unit tests run fine locally, but when I upload them to Jenkins, the first test always fails (with subsequent tests succeeding) with the following logs:
2022-03-15 18:45:10.445 INFO 624 --- [ Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
2022-03-15 18:45:10.472 INFO 624 --- [ Test worker] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 19 ms. Found 0 MongoDB repository interfaces.
2022-03-15 18:45:15.389 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : starting...
2022-03-15 18:45:15.707 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : DownloadSize: 87554471
2022-03-15 18:45:15.710 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : 0 %
2022-03-15 18:45:16.595 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : 10 %
2022-03-15 18:45:17.392 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : 20 %
2022-03-15 18:45:18.194 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : 30 %
2022-03-15 18:45:18.992 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : 40 %
2022-03-15 18:45:19.403 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : 50 %
2022-03-15 18:45:19.659 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : 60 %
2022-03-15 18:45:19.935 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : 70 %
2022-03-15 18:45:20.185 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : 80 %
2022-03-15 18:45:20.431 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : 90 %
2022-03-15 18:45:20.508 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : 100 %
2022-03-15 18:45:20.509 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : downloaded with 21375kb/s
2022-03-15 18:45:20.510 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Download GenericFeatureAwareVersion{3.5.5}:Platform{operatingSystem=Linux, architecture=X86_64} : finished
2022-03-15 18:45:20.576 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Extract ?/.embedmongo/linux/mongodb-linux-x86_64-3.5.5.tgz : starting...
2022-03-15 18:45:21.595 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Extract ?/.embedmongo/linux/mongodb-linux-x86_64-3.5.5.tgz : extract mongodb-linux-x86_64-3.5.5/bin/mongod
2022-03-15 18:45:21.595 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Extract ?/.embedmongo/linux/mongodb-linux-x86_64-3.5.5.tgz : nothing left
2022-03-15 18:45:21.596 INFO 624 --- [ Test worker] d.f.e.m.s.autoconfigure.EmbeddedMongo : Extract ?/.embedmongo/linux/mongodb-linux-x86_64-3.5.5.tgz : finished
2022-03-15 18:45:21.611 ERROR 624 --- [ Test worker] d.f.embed.process.runtime.Starter : prepare executable
java.nio.file.NoSuchFileException: ?/.embedmongo/extracted/Linux-B64--unknown---3.5.5/?/.embedmongo/extracted/Linux-B64--unknown---3.5.5/extractmongod
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92) ~[na:na]
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106) ~[na:na]
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[na:na]
at java.base/sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:548) ~[na:na]
at java.base/sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:258) ~[na:na]
at java.base/java.nio.file.Files.copy(Files.java:1305) ~[na:na]
at de.flapdoodle.embed.process.extract.ExtractedFileSets.copy(ExtractedFileSets.java:57) ~[de.flapdoodle.embed.process-3.1.7.jar:na]
at de.flapdoodle.embed.process.store.ExtractedArtifactStore.extractFileSet(ExtractedArtifactStore.java:110) ~[de.flapdoodle.embed.process-3.1.7.jar:na]
at de.flapdoodle.embed.process.runtime.Starter.prepare(Starter.java:59) ~[de.flapdoodle.embed.process-3.1.7.jar:na]
at de.flapdoodle.embed.process.runtime.Starter.prepare(Starter.java:52) ~[de.flapdoodle.embed.process-3.1.7.jar:na]
at de.flapdoodle.embed.mongo.spring.autoconfigure.EmbeddedMongoAutoConfiguration.embeddedMongoServer(EmbeddedMongoAutoConfiguration.java:103) ~[de.flapdoodle.embed.mongo.spring-1.0.2-spring26x.jar:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
It looks like the embedded database is still downloading while the first test is running, but is in place for later tests. I've tried changing the order of tests, but got the same behavior, so it's not the specific test that runs first, it's the timing.
My tests are WebMvcTests with mongo autoconfigured:
@ExtendWith(SpringExtension.class)
@ContextConfiguration
@AutoConfigureDataMongo
@WebMvcTest(
controllers = {
AccessorialTypeController.class,
AccessorialTypeDao.class,
ServicePermissionEvaluator.class,
MethodSecurityConfig.class,
APIExceptionHandler.class,
PatchValidator.class
},
properties = {
"spring.mongodb.embedded.version=3.5.5"
})
I've tried a number of different embedded versions, and this is the closest I've gotten it to running. Later versions result in all of the tests failing with similar but not identical file not found exceptions, not just the first.