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

Add rootless podman support

Open SoMuchForSubtlety opened this issue 3 years ago • 4 comments

Follow-up for #5822 with a new CI check for podman.

I had to modify some tests slightly to make them work for podman. Please let me know if you want me to clarify any changes or are unhappy with them.

All tests except those for docker compose pass. I had to disable them because podman does not fully support compose, but I think they could be enabled in the future with a bit of work.

Open Issues

  • [ ] macvlan networks don't work with netavark backend (need subnet specified)
    • NetworkTest::testBuilder
    • NetworkTest::testModifiers
  • [ ] network reuse test fails with CNI backend because network IDs are deterministic
    • NetworkTest::testReusability
  • [x] pulling from local http registry does not work (see https://github.com/containers/podman/issues/16486)
    • ImagePullPolicyTest::pullsByDefault
    • ImagePullPolicyTest::shouldAlwaysPull
    • ImagePullPolicyTest::shouldSupportCustomPolicies
    • ImagePullPolicyTest::shouldCheckPolicy
    • AmbiguousImagePullTest::testNotUsingParse
    • DockerClientFactoryTest::runCommandInsideDockerShouldNotFailIfImageDoesNotExistsLocally
    • AuthenticatedImagePullTest::testThatAuthLocatorIsUsedForDockerfileBuild
    • AuthenticatedImagePullTest::testThatAuthLocatorIsUsedForContainerCreation
  • [ ] setting swappiness is not supported by cgroups V2 ({"cause":"OCI runtime error","message":"crun: cannot set memory swappiness with cgroupv2: OCI runtime error","response":500})
    • GenericContainerTest::shouldReportOOMAfterWait
  • [x] Port bindings in inspect response are slightly different (map value is null vs map key is absent)
    • GenericContainerTest::shouldOnlyPublishExposedPorts

SoMuchForSubtlety avatar Nov 09 '22 12:11 SoMuchForSubtlety

@SoMuchForSubtlety thanks again for submitting a PR! However, Podman support should not alter the current tests.

eddumelendez avatar Nov 09 '22 14:11 eddumelendez

@SoMuchForSubtlety thanks again for submitting a PR! However, Podman support should not alter the current tests.

I reverted the test changes and skip them instead.

SoMuchForSubtlety avatar Nov 09 '22 15:11 SoMuchForSubtlety

I'll try to get the outstanding compatibility issues fixed in podman. I would be grateful if this PR could stay open to track the progress.

Would it be OK to fix a (probable) bug in the tests?

https://github.com/testcontainers/testcontainers-java/blob/98ddbb845583ff07e622077522c49122908c40b6/core/src/test/java/org/testcontainers/DockerRegistryContainer.java#L102-L103

imageName.asCanonicalNameString() returns the image name with the tag, so for example localhost:123/my-image:1.0.0, but tagImageCmd takes the image tag as a separate parameter, so the end result would be localhost:123/my-image:1.0.0:1.0.0. This should probably be client.tagImageCmd(dummyImageId, imageName.getUnversionedPart(), tag).exec();.

According to the docker API spec, the repo parameter should not contain a tag.

SoMuchForSubtlety avatar Nov 10 '22 21:11 SoMuchForSubtlety

Thanks a lot for your work on this PR and your openness to collaboration @SoMuchForSubtlety, this is much appreciated. We can of course keep the PR open to track the progress.

Regarding:

Would it be OK to fix a (probable) bug in the tests?

Of course, maybe even better as a small distinct PR, to decouple it from the Podman development work (since it is indeed independent of it).

kiview avatar Nov 11 '22 08:11 kiview

Podman 4.5.0 with the last required fix landed today, this is ready for review :slightly_smiling_face:

SoMuchForSubtlety avatar Apr 14 '23 17:04 SoMuchForSubtlety

Does it work w/ docker compose?

pan3793 avatar Apr 18 '23 02:04 pan3793

Does it work w/ docker compose?

No, because testcontainers currently uses the deprecated link feature for the compose ambassador container. If/when the implementation is changed to not use links, it should work, but that is out of scope for this PR.

SoMuchForSubtlety avatar Apr 18 '23 13:04 SoMuchForSubtlety

Got it, thanks @SoMuchForSubtlety

pan3793 avatar Apr 19 '23 01:04 pan3793

This PR has been ready for a while now, any change of getting a review?

SoMuchForSubtlety avatar Nov 10 '23 13:11 SoMuchForSubtlety