Skip to content

Commit 89ba031

Browse files
committed
MYSQLCLUSTER-8607 Support tests in rootless podman
Podman allows running tests without requiring root access which improves security and usability. Rootless podman requires, at least, version 1.23 of kind to run correctly. Supporting rootless podman required: - Using systemd-run to run the test suite as a transient service with cgroups delegation enabled; - Using fully qualified names for local images. Since podman implicitly assumes that non-qualified image names refer to Docker repository, it tries to pull local images from there causing failures during tests. This situation can be prevented by using the 'localhost' prefix in local image names. - Adding 'list' to the available verbs of Persistent Volumes resource. Change-Id: I2304ad9811aadcb15a123bb5427fd01f2651494a
1 parent 28b1143 commit 89ba031

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ DOCKER_CMD := DOCKER_BUILDKIT=1 docker
5454
# Build NDB Operator container image
5555
.PHONY: operator-image
5656
operator-image: build
57-
$(DOCKER_CMD) build -t mysql/ndb-operator:$(shell cat VERSION) -f docker/ndb-operator/Dockerfile .
57+
$(DOCKER_CMD) build -t localhost/mysql/ndb-operator:$(shell cat VERSION) -f docker/ndb-operator/Dockerfile .
5858

5959
# Build args to be passed to release docker build
6060
BUILD_ARGS := --build-arg gitCommit=$(GIT_COMMIT_ID)

e2e-tests/_config/k8s-deployment/01-e2e-tests-rbac.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ rules:
3030
- create
3131
- delete
3232
- get
33+
- list
3334

3435
- apiGroups:
3536
- ""

e2e-tests/run-e2e-test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2024, Oracle and/or its affiliates.
22
//
33
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
44

@@ -67,7 +67,7 @@ var kindK8sNodeImages = map[string]string{
6767
}
6868

6969
var (
70-
kindCmd = []string{"go", "run", "sigs.k8s.io/kind"}
70+
kindCmd = []string{"systemd-run", "--scope", "--user", "-p", "Delegate=yes", "go", "run", "sigs.k8s.io/kind"}
7171
)
7272

7373
// shortUUID returns a short UUID to be used by the methods
@@ -344,7 +344,7 @@ func (t *testRunner) init(ctx context.Context) {
344344
t.testDir = filepath.Dir(currentFilePath)
345345

346346
// By default, use the latest e2e-tests image
347-
t.e2eTestImageName = "e2e-tests"
347+
t.e2eTestImageName = "localhost/e2e-tests"
348348

349349
// Run the pod in the default namespace
350350
t.e2eTestPodNamespace = "default"
@@ -766,7 +766,7 @@ func (t *testRunner) loadImagesIntoK8sCluster() bool {
766766
versionNumber := string(versionBytes)
767767
// trim the newline from version
768768
versionNumber = versionNumber[:len(versionNumber)-1]
769-
options.ndbOperatorImage = "mysql/ndb-operator:" + versionNumber
769+
options.ndbOperatorImage = "localhost/mysql/ndb-operator:" + versionNumber
770770
}
771771
if !t.p.loadImageIntoK8sCluster(t, options.ndbOperatorImage) {
772772
return false
@@ -884,10 +884,10 @@ func init() {
884884
"Enable this to run tests from outside the K8s cluster.\n"+
885885
"By default, this is not enabled and the tests will be run as a pod from inside K8s Cluster.")
886886

887-
// use v1.21 as default kind k8s version
888-
flag.StringVar(&options.kindK8sVersion, "kind-k8s-version", "1.21",
887+
// use v1.23 as default kind k8s version
888+
flag.StringVar(&options.kindK8sVersion, "kind-k8s-version", "1.23",
889889
"Kind k8s version used to run tests.\n"+
890-
"Example usage: -kind-k8s-version=1.20")
890+
"Example usage: -kind-k8s-version=1.23")
891891

892892
// test suites to be run.
893893
flag.StringVar(&options.suites, "suites", "",

0 commit comments

Comments
 (0)