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

Allow testing against different Kafka Versions with Testcontainers #783

Closed
miguelpuyol opened this issue May 3, 2019 · 7 comments

Comments

Projects
None yet
3 participants
@miguelpuyol
Copy link

commented May 3, 2019

Short description

Currently the trait TestcontainersKafkaLike fetches the latest Kafka version. However, not everyone is using the latest version.

Details

Change the setup to allow a custom version as described in the Testcontainers documentation.

Now:

 override def setUp(): Unit = {
    if (kafkaPortInternal == -1) {
      val kafkaContainer = new KafkaContainer()
      kafkaContainer.start()
      kafkaBootstrapServersInternal = kafkaContainer.getBootstrapServers
      kafkaPortInternal =
        kafkaBootstrapServersInternal.substring(kafkaBootstrapServersInternal.lastIndexOf(":") + 1).toInt
    }
    super.setUp()
  }

Possible solution:

val kafkaVersion: Option[String] = None

 override def setUp(): Unit = {
    if (kafkaPortInternal == -1) {
      val kafkaContainer = kafkaVersion match {
              case None => new KafkaContainer()
             case Some(version) => new KafkaContainer(version)
      }
      kafkaContainer.start()
      kafkaBootstrapServersInternal = kafkaContainer.getBootstrapServers
      kafkaPortInternal =
        kafkaBootstrapServersInternal.substring(kafkaBootstrapServersInternal.lastIndexOf(":") + 1).toInt
    }
    super.setUp()
  }
@miguelpuyol

This comment has been minimized.

Copy link
Author

commented May 3, 2019

If you are ok, I can provide with a PR

@2m

This comment has been minimized.

Copy link
Member

commented May 6, 2019

Good suggestion! The default value could be derived using sbt-buildinfo from the version of Kafka client that is configured in the build.

@ennru ennru referenced this issue May 6, 2019

Closed

Alpakka team sprint plan 2019-04-11 #99

3 of 7 tasks complete
@ennru

This comment has been minimized.

Copy link
Member

commented May 8, 2019

The version number in there is the version of "Confluent Platform" not Kafka version https://hub.docker.com/r/confluentinc/cp-kafka/tags

@ennru

This comment has been minimized.

Copy link
Member

commented May 8, 2019

@ennru

This comment has been minimized.

Copy link
Member

commented May 8, 2019

@miguelpuyol We would have loved your contribution, I just did it to make it into the upcoming patch release.

Fixed with #783.

@ennru ennru closed this May 8, 2019

@miguelpuyol

This comment has been minimized.

Copy link
Author

commented May 8, 2019

No problem @ennru . I tried but I am not so familiar with sbt-buildinfo so I could not provide a good solution. Thanks for the quick feedback.

@ennru

This comment has been minimized.

Copy link
Member

commented May 8, 2019

I ended up hard-coding the default it as it is not the Kafka version, but the Confluent Platform version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.