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

Kafka container not waiting for full startup #134

Open
AvaPL opened this issue Oct 18, 2020 · 1 comment
Open

Kafka container not waiting for full startup #134

AvaPL opened this issue Oct 18, 2020 · 1 comment

Comments

@AvaPL
Copy link

AvaPL commented Oct 18, 2020

Minimal test to reproduce the issue:

import com.dimafeng.testcontainers.{ForAllTestContainer, KafkaContainer}
import org.scalatest.flatspec.AnyFlatSpec

class KafkaExampleTest extends AnyFlatSpec with ForAllTestContainer {
  override def container: KafkaContainer = KafkaContainer()

  "Kafka container" should "be started" in {
    container.bootstrapServers
  }
}

This code throws

java.lang.IllegalStateException: You should start Kafka container first
	at org.testcontainers.containers.KafkaContainer.getBootstrapServers(KafkaContainer.java:89)
	at com.dimafeng.testcontainers.KafkaContainer.bootstrapServers(KafkaContainer.scala:25)
	at links.kafka.KafkaExampleTest.$anonfun$new$1(KafkaExampleTest.scala:10)

It happens only with ForAllTestContainer trait. When using new TestContainerForAll from experimental API it works as expected. Tested on Ubuntu 18.04 and Docker Toolbox for Windows using testcontainsers-scala v0.38.4, same results.

@markarasev
Copy link
Contributor

Had a similar issue with Postgresql as linked by Mithunatri.
In my case changing override def container = PostgreSQLContainer() by an override val solved the problem (actually the examples use a val but IntelliJ overrides with a def by default).

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