From 9e024d27f24b50371fd8466bf2ebe35f7dc06349 Mon Sep 17 00:00:00 2001 From: Alessio Pragliola <83355398+Al-Pragliola@users.noreply.github.com> Date: Wed, 11 Sep 2024 19:25:21 +0200 Subject: [PATCH] fix: make tests work on fedora (#269) * fix: make tests work on fedora Signed-off-by: Alessio Pragliola * chore: add more info about contributing on fedora Signed-off-by: Alessio Pragliola * fix: remove export to ryuk privileged as not necessary Signed-off-by: Alessio Pragliola --------- Signed-off-by: Alessio Pragliola --- CONTRIBUTING.md | 18 ++++++++++++++++++ internal/testutils/test_container_utils.go | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 94bcbc8f..4f4ac85e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,6 +84,24 @@ export TESTCONTAINERS_RYUK_PRIVILEGED=true when running TestContainer-based Model Registry Python tests (for more information, see [here](https://pypi.org/project/testcontainers/#:~:text=TESTCONTAINERS_RYUK_PRIVILEGED)). +#### Fedora + +Fedora requires further setup to make testcontainers work with Podman, the following steps are required: + +- start the podman socket service + +```sh +systemctl --user start podman.socket +``` + +- set the environment variable + +```sh +export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock +``` + +If you need more information, please refer to the [Testcontainers using Podman](https://golang.testcontainers.org/system_requirements/using_podman/). + ### Colima Colima offers Rosetta (Apple specific) emulation which is handy since the Google MLMD project dependency is x86 specific. diff --git a/internal/testutils/test_container_utils.go b/internal/testutils/test_container_utils.go index 0a1c21c3..6601a875 100644 --- a/internal/testutils/test_container_utils.go +++ b/internal/testutils/test_container_utils.go @@ -8,6 +8,7 @@ import ( "fmt" "os" "os/exec" + "strings" "testing" "github.com/docker/docker/api/types/container" @@ -90,6 +91,7 @@ func SetupMLMetadataTestContainer(t *testing.T) (*grpc.ClientConn, proto.Metadat hc.Binds = []string{wd + ":/tmp/shared"} }, WaitingFor: wait.ForLog("Server listening on"), + Privileged: true, } useProvider := defaultProvider @@ -164,5 +166,5 @@ func tryDetectPodmanRunning() bool { if err != nil { return false } - return info.Host.MachineState == "Running" + return info.Host.MachineState == "Running" || strings.Contains(os.Getenv("DOCKER_HOST"), "podman.sock") }