Skip to content

Commit

Permalink
fix: make tests work on fedora (#269)
Browse files Browse the repository at this point in the history
* fix: make tests work on fedora

Signed-off-by: Alessio Pragliola <[email protected]>

* chore: add more info about contributing on fedora

Signed-off-by: Alessio Pragliola <[email protected]>

* fix: remove export to ryuk privileged as not necessary

Signed-off-by: Alessio Pragliola <[email protected]>

---------

Signed-off-by: Alessio Pragliola <[email protected]>
  • Loading branch information
Al-Pragliola authored Sep 11, 2024
1 parent a11747e commit 9e024d2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion internal/testutils/test_container_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"os"
"os/exec"
"strings"
"testing"

"github.com/docker/docker/api/types/container"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
}

0 comments on commit 9e024d2

Please sign in to comment.