testcontainers / testcontainers-scala

Docker containers for testing in scala
MIT License
629 stars 126 forks source link

K3s Module #212

Open nemoo opened 2 years ago

nemoo commented 2 years ago

Not an issue but more of a question.

testcontainers-java now features a module for lightweight Kubernetes clusters called K3s: https://github.com/testcontainers/testcontainers-java/blob/master/modules/k3s/src/main/java/org/testcontainers/k3s/K3sContainer.java

The module documentation can be found here: https://www.testcontainers.org/modules/k3s/

Will this module also be wrapped in testcontainers-scala?

dimafeng commented 2 years ago

Hi @nemoo, thank you for your question! This project is driven by the community and java modules are getting added to the scala version as the community needs it.

If you'd like to contribute support for this module, it would be huge help for this project!

nemoo commented 2 years ago

Great, I will give it a go.

Is there a contribution guide? When I tried sbt publishLocal it only created the scala 2.12 versions, not the scala 2.13 version.

Edit: ok for testing I now set the scala version explicitly via ++ 2.13.6 publishLocal

dimafeng commented 2 years ago

Sorry, unfortunately I don't have a contribution guide but you can check out several recent PRs that add support for various containers: https://github.com/testcontainers/testcontainers-scala/pull/126/files https://github.com/testcontainers/testcontainers-scala/pull/211/files https://github.com/testcontainers/testcontainers-scala/pull/208/files

nemoo commented 2 years ago

This requires also a bump to testcontainers java 1.16.3. I guess that would be a different pull request?

nemoo commented 2 years ago

Also, in the original java k3s module test, a special log consumer Slf4jLogConsumer is used: https://github.com/testcontainers/testcontainers-java/blob/master/modules/k3s/src/test/java/org/testcontainers/k3s/OfficialClientK3sContainerTest.java

K3sContainer k3s = new K3sContainer(DockerImageName.parse("rancher/k3s:v1.21.3-k3s1"))
                .withLogConsumer(new Slf4jLogConsumer(log))

Do we have any examples on how the use of .withLogConsumer() should be ported over to scala?

dimafeng commented 2 years ago

This requires also a bump to testcontainers java 1.16.3. I guess that would be a different pull request?

It's fine if you bump it here

Do we have any examples on how the use of .withLogConsumer() should be ported over to scala?

I think it'd look like this:

case class K3sContainer(

  logConsumer: Slf4jLogConsumer 
) {
...
c.withLogConsumer(logConsumer)
...
}

example https://github.com/testcontainers/testcontainers-scala/pull/126/files#diff-19e736fb3cde3f8c030b9fc3639026ec28e9bd61c8caa82096dfeb69e9f918f3R29