From 7b357fce0bd88d422478c700127ab6207b2c5ce1 Mon Sep 17 00:00:00 2001 From: apostasie Date: Wed, 21 Aug 2024 11:00:00 -0700 Subject: [PATCH] K8s minor cleanup (rename and -f on delete) Signed-off-by: apostasie --- .github/workflows/test-kube.yml | 10 ++++---- cmd/nerdctl/container_commit_linux_test.go | 4 ++-- ...ation-kube.sh => build-integration-k8s.sh} | 0 pkg/testutil/testutil.go | 24 +++++++++---------- 4 files changed, 19 insertions(+), 19 deletions(-) rename hack/{build-integration-kube.sh => build-integration-k8s.sh} (100%) diff --git a/.github/workflows/test-kube.yml b/.github/workflows/test-kube.yml index 593cc5b4511..06dae4f9d12 100644 --- a/.github/workflows/test-kube.yml +++ b/.github/workflows/test-kube.yml @@ -1,5 +1,5 @@ -# This pipeline purpose is solely meant to run a subset of our test suites against a kube cluster -name: kube +# This pipeline purpose is solely meant to run a subset of our test suites against a kubernetes cluster +name: kubernetes on: push: @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v4.1.7 with: fetch-depth: 1 - - name: "Run Kube integration tests" + - name: "Run K8s integration tests" run: | - ./hack/build-integration-kube.sh - sudo ./_output/nerdctl exec nerdctl-test-control-plane bash -c -- 'export TMPDIR="$HOME"/tmp; mkdir -p "$TMPDIR"; cd /nerdctl-source; /usr/local/go/bin/go test ./cmd/nerdctl/ -test.only-kube' + ./hack/build-integration-k8s.sh + sudo ./_output/nerdctl exec nerdctl-test-control-plane bash -c -- 'export TMPDIR="$HOME"/tmp; mkdir -p "$TMPDIR"; cd /nerdctl-source; /usr/local/go/bin/go test ./cmd/nerdctl/ -test.only-k8s' diff --git a/cmd/nerdctl/container_commit_linux_test.go b/cmd/nerdctl/container_commit_linux_test.go index a26c3b1eff6..9c63ffb1670 100644 --- a/cmd/nerdctl/container_commit_linux_test.go +++ b/cmd/nerdctl/container_commit_linux_test.go @@ -28,7 +28,7 @@ import ( func TestKubeCommitPush(t *testing.T) { t.Parallel() - base := testutil.NewBaseForKube(t) + base := testutil.NewBaseForK8s(t) tID := testutil.Identifier(t) var containerID string @@ -49,7 +49,7 @@ func TestKubeCommitPush(t *testing.T) { } tearDown := func() { - testutil.KubectlHelper(base, "delete", "pod", tID).Run() + testutil.KubectlHelper(base, "delete", "pod", "-f", tID).Run() } tearDown() diff --git a/hack/build-integration-kube.sh b/hack/build-integration-k8s.sh similarity index 100% rename from hack/build-integration-kube.sh rename to hack/build-integration-k8s.sh diff --git a/pkg/testutil/testutil.go b/pkg/testutil/testutil.go index 4d93fc4c915..163c89230d5 100644 --- a/pkg/testutil/testutil.go +++ b/pkg/testutil/testutil.go @@ -53,8 +53,8 @@ type Base struct { DaemonIsKillable bool EnableIPv6 bool IPv6Compatible bool - EnableKube bool - KubeCompatible bool + EnableK8s bool + K8sCompatible bool Binary string Args []string Env []string @@ -550,7 +550,7 @@ func M(m *testing.M) { flag.StringVar(&flagTestTarget, "test.target", Nerdctl, "target to test") flag.BoolVar(&flagTestKillDaemon, "test.allow-kill-daemon", false, "enable tests that kill the daemon") flag.BoolVar(&flagTestIPv6, "test.only-ipv6", false, "enable tests on IPv6") - flag.BoolVar(&flagTestKube, "test.only-kube", false, "enable tests on Kube") + flag.BoolVar(&flagTestKube, "test.only-k8s", false, "enable tests on Kubernetes") flag.Parse() fmt.Fprintf(os.Stderr, "test target: %q\n", flagTestTarget) os.Exit(m.Run()) @@ -567,7 +567,7 @@ func GetEnableIPv6() bool { return flagTestIPv6 } -func GetEnableKube() bool { +func GetEnableK8s() bool { return flagTestKube } @@ -697,7 +697,7 @@ func NewBaseWithIPv6Compatible(t *testing.T) *Base { return newBase(t, Namespace, true, false) } -func NewBaseForKube(t *testing.T) *Base { +func NewBaseForK8s(t *testing.T) *Base { base := newBase(t, "k8s.io", false, true) // NOTE: kubectl namespaces are not the same as containerd namespaces. // We still want kube test objects segregated in their own Kube API namespace. @@ -709,15 +709,15 @@ func NewBase(t *testing.T) *Base { return newBase(t, Namespace, false, false) } -func newBase(t *testing.T, ns string, ipv6Compatible bool, kubeCompatible bool) *Base { +func newBase(t *testing.T, ns string, ipv6Compatible bool, k8sCompatible bool) *Base { base := &Base{ T: t, Target: GetTarget(), DaemonIsKillable: GetDaemonIsKillable(), EnableIPv6: GetEnableIPv6(), IPv6Compatible: ipv6Compatible, - EnableKube: GetEnableKube(), - KubeCompatible: kubeCompatible, + EnableK8s: GetEnableK8s(), + K8sCompatible: k8sCompatible, Env: os.Environ(), } if base.EnableIPv6 && !base.IPv6Compatible { @@ -725,10 +725,10 @@ func newBase(t *testing.T, ns string, ipv6Compatible bool, kubeCompatible bool) } else if !base.EnableIPv6 && base.IPv6Compatible { t.Skip("runner skips IPv6 compatible tests in the non-IPv6 environment") } - if base.EnableKube && !base.KubeCompatible { - t.Skip("runner skips non-kube compatible tests in the kube environment") - } else if !base.EnableKube && base.KubeCompatible { - t.Skip("runner skips kube compatible tests in the non-kube environment") + if base.EnableK8s && !base.K8sCompatible { + t.Skip("runner skips non-K8s compatible tests in the K8s environment") + } else if !base.EnableK8s && base.K8sCompatible { + t.Skip("runner skips K8s compatible tests in the non-K8s environment") } var err error switch base.Target {