testcontainers-scala icon indicating copy to clipboard operation
testcontainers-scala copied to clipboard

K3s Module

Open nemoo opened this issue 2 years ago • 6 comments

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?

nemoo avatar Feb 20 '22 09:02 nemoo

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!

dimafeng avatar Feb 20 '22 15:02 dimafeng

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

nemoo avatar Feb 21 '22 09:02 nemoo

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

dimafeng avatar Feb 22 '22 02:02 dimafeng

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

nemoo avatar Mar 03 '22 07:03 nemoo

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?

nemoo avatar Mar 03 '22 09:03 nemoo

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

dimafeng avatar Mar 03 '22 15:03 dimafeng