Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with web tests and DockerComposeContainer #305

Closed
alexrodriguez opened this issue Apr 8, 2023 · 2 comments
Closed

Problems with web tests and DockerComposeContainer #305

alexrodriguez opened this issue Apr 8, 2023 · 2 comments

Comments

@alexrodriguez
Copy link

Hello,

First let me thank you for the course content. I enjoyed it very much. I'm having an issue with DockerComposeContainer and I hope you can help me.

My environment:

  • OSX 13.1 (Ventura)
  • Docker version 20.10.23, build 7155243
  • Docker Compose version v2.15.1
  • Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
    Maven home: /Users/alex/.m2/wrapper/dists/apache-maven-3.8.4-bin/52ccbt68d252mdldqsfsn03jlf/apache-maven-3.8.4
    Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: /Users/alex/.sdkman/candidates/java/17.0.6-tem
    Default locale: en_US, platform encoding: UTF-8
    OS name: "mac os x", version: "13.1", arch: "x86_64", family: "mac"

The issue is while running web-tests both ReviewCreationWT and ReviewCreationPageObjectsWT fail with the following error:

17:16:18.365 [Thread-46] INFO  🐳 [docker-compose] - Container de8cbjkxk6bq-database-1  Starting
17:16:18.373 [Thread-46] INFO  🐳 [docker-compose] - Container de8cbjkxk6bq-keycloak-1  Starting
17:16:18.982 [Thread-46] INFO  🐳 [docker-compose] - Container de8cbjkxk6bq-database-1  Started
17:16:19.130 [Thread-46] INFO  🐳 [docker-compose] - Container de8cbjkxk6bq-keycloak-1  Started
17:16:19.136 [Thread-46] INFO  🐳 [docker-compose] - Container de8cbjkxk6bq-sqs-1  Started
17:16:19.149 [main] INFO  🐳 [docker-compose] - Docker Compose has finished running
17:16:19.150 [main] INFO  🐳 [alpine/socat:1.7.4.3-r0] - Creating container for image: alpine/socat:1.7.4.3-r0
17:16:19.201 [main] ERROR 🐳 [alpine/socat:1.7.4.3-r0] - Could not start container
org.testcontainers.containers.ContainerLaunchException: Aborting attempt to link to container de8cbjkxk6bq_database_1 as it is not running
        at org.testcontainers.containers.GenericContainer.applyConfiguration(GenericContainer.java:828)
        at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:378)
        at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
        at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
        at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:334)
        at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322)
        at org.testcontainers.containers.DockerComposeContainer.startAmbassadorContainers(DockerComposeContainer.java:359)
        at org.testcontainers.containers.DockerComposeContainer.start(DockerComposeContainer.java:190)
        at de.rieckpil.courses.AbstractWebTest.<clinit>(AbstractWebTest.java:50)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1155)
        at java.base/jdk.internal.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:42)
        at java.base/jdk.internal.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:185)
        at java.base/java.lang.reflect.Field.acquireFieldAccessor(Field.java:1132)
        at java.base/java.lang.reflect.Field.getFieldAccessor(Field.java:1113)
        at java.base/java.lang.reflect.Field.get(Field.java:425)
        at org.junit.platform.commons.util.ReflectionUtils.lambda$tryToReadFieldValue$5(ReflectionUtils.java:671)
        at org.junit.platform.commons.function.Try.lambda$call$0(Try.java:57)
        at org.junit.platform.commons.function.Try.of(Try.java:93)
        at org.junit.platform.commons.function.Try.call(Try.java:57)
        at org.junit.platform.commons.util.ReflectionUtils.tryToReadFieldValue(ReflectionUtils.java:671)
        at org.junit.jupiter.engine.descriptor.ExtensionUtils.lambda$registerExtensionsFromFields$4(ExtensionUtils.java:106)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at org.junit.jupiter.engine.descriptor.ExtensionUtils.registerExtensionsFromFields(ExtensionUtils.java:98)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.prepare(ClassBasedTestDescriptor.java:150)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.prepare(ClassBasedTestDescriptor.java:80)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
        at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
        at org.apache.maven.surefire.junitplatform.LazyLauncher.execute(LazyLauncher.java:55)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:223)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:175)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:139)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:456)
        at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:169)
        at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:595)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:581)
[INFO] Running de.rieckpil.courses.book.review.ReviewCreationWT
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 s <<< FAILURE! - in de.rieckpil.courses.book.review.ReviewCreationWT
[ERROR] de.rieckpil.courses.book.review.ReviewCreationWT  Time elapsed: 0 s  <<< ERROR!

Thanks for your help!

@rieckpil
Copy link
Owner

rieckpil commented Apr 9, 2023

Hey Alex 👋 thanks for reaching out :)

That issue might be a pending Testcontainers issue to support Compose v2, see:

I assume the underscore de8cbjkxk6bq_database_1 may be the issue here.

Are you using the latest state on the main branch? I've added there .withOptions("--compatibility") to the AbstractWebTest class and the DockerCompose setup, which should do the trick.

@alexrodriguez
Copy link
Author

Hey,
Thanks for the assist... I was working of the master branch... changing to main solves the problem. Thanks again, and keep the good content coming. I appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants