question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using KafkaContainer on CircleCI fails

See original GitHub issue
@DirtiesContext
@SpringBootTest
@ContextConfiguration(initializers = Intializer )
abstract class BaseIntegrationTest extends Specification {
public static KafkaContainer kafka = new KafkaContainer()
static {
    BaseIntegrationTest.kafka.start()
}
static  class Intializer implements ApplicationContextInitializer<ConfigurableApplicationContext>{
    @Override
    void initialize(ConfigurableApplicationContext applicationContext) {
        System.setProperty("kafka.consumer.endpoint", BaseIntegrationTest.kafka.bootstrapServers.replace("PLAINTEXT://", ""))
    }
}
} 

I have posted my code above I have a lot of tests that inherit this class. When I run any test class from Intellij it works fine but On circle CI the build fails with the following error.

at org.spockframework.runtime.BaseSpecRunner.createSpecInstance(BaseSpecRunner.java:113) at org.spockframework.runtime.BaseSpecRunner.run(BaseSpecRunner.java:65) at org.spockframework.runtime.Sputnik.run(Sputnik.java:63) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:116) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:59) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:39) at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) at com.sun.proxy.$Proxy1.processTestClass(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:128) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ExceptionInInitializerError at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at java.lang.Class.newInstance(Class.java:442) at org.spockframework.runtime.BaseSpecRunner.createSpecInstance(BaseSpecRunner.java:107) … 32 more Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:199) at org.testcontainers.containers.KafkaContainer.start(KafkaContainer.java:67) at org.testcontainers.containers.KafkaContainer$start.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:114) … 38 more Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:83) at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:192) … 44 more Caused by: java.lang.NullPointerException: containerId was not specified at org.testcontainers.shaded.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:228) at com.github.dockerjava.core.command.LogContainerCmdImpl.withContainerId(LogContainerCmdImpl.java:78) at com.github.dockerjava.core.command.LogContainerCmdImpl.<init>(LogContainerCmdImpl.java:38) at com.github.dockerjava.core.DockerClientImpl.logContainerCmd(DockerClientImpl.java:335) at org.testcontainers.dockerclient.AuditLoggingDockerClient.logContainerCmd(AuditLoggingDockerClient.java:22) at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:255) at org.testcontainers.containers.GenericContainer.lambda$start$0(GenericContainer.java:194) at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bsideupcommented, Jan 2, 2019

I guess you were using EmbeddedKafka? If so, it runs in the same JVM process and there is no additional memory allocation, but now you start a separate Kafka process (with Docker). But, if I am right, you can easily lower heap size for your tests because previously it was shared with embedded Kafka, and your app was not using all 2Gb if heap

1reaction
bsideupcommented, Dec 28, 2018

@umair-akram

version: 2
executorType: machine
Read more comments on GitHub >

github_iconTop Results From Across the Web

Kafka Containers - Testcontainers for Java
Testcontainers can be used to automatically instantiate and manage Apache Kafka containers. More precisely Testcontainers uses the official Docker images ...
Read more >
Highest scored 'testcontainers' questions - Stack Overflow
Test Container test cases are failing due to "Could not find a valid Docker environment" ... I am using testcontainers.org with KafkaContainer.
Read more >
Testcontainers JUnit 5, Spring-kafka-test JUnit 5, Embedded ...
Starting with version 2.5.5, this method is called, even when using manual partition assignment. onPartitionsRevoked is called when the container is stopped or ......
Read more >
Testing a Microservice Architecture with Docker and Compose
Let's begin with my assertion that this is a both hard and unsolved problem. If you disagree with that, I'd love to talk...
Read more >
org.testcontainers.utility.TestcontainersConfiguration
The following examples show how to use org.testcontainers.utility. ... return map; } catch (Exception e) { LOGGER.error("Container does not start", ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found