From 031aa1d47db08b5b34b06aa8d7963a9194709b9d 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 +- ...ube.sh => build-integration-kubernetes.sh} | 0 pkg/testutil/testutil.go | 52 +++++++++---------- 4 files changed, 33 insertions(+), 33 deletions(-) rename hack/{build-integration-kube.sh => build-integration-kubernetes.sh} (100%) diff --git a/.github/workflows/test-kube.yml b/.github/workflows/test-kube.yml index 593cc5b4511..c8696a38b32 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 Kubernetes 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-kubernetes.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-kubernetes' diff --git a/cmd/nerdctl/container_commit_linux_test.go b/cmd/nerdctl/container_commit_linux_test.go index a26c3b1eff6..a18f57a5150 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.NewBaseForKubernetes(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-kubernetes.sh similarity index 100% rename from hack/build-integration-kube.sh rename to hack/build-integration-kubernetes.sh diff --git a/pkg/testutil/testutil.go b/pkg/testutil/testutil.go index 4d93fc4c915..717a2949221 100644 --- a/pkg/testutil/testutil.go +++ b/pkg/testutil/testutil.go @@ -48,16 +48,16 @@ import ( ) type Base struct { - T testing.TB - Target Target - DaemonIsKillable bool - EnableIPv6 bool - IPv6Compatible bool - EnableKube bool - KubeCompatible bool - Binary string - Args []string - Env []string + T testing.TB + Target Target + DaemonIsKillable bool + EnableIPv6 bool + IPv6Compatible bool + EnableKubernetes bool + KubernetesCompatible bool + Binary string + Args []string + Env []string } // WithStdin sets the standard input of Cmd to the specified reader @@ -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-kubernetes", 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 GetEnableKubernetes() 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 NewBaseForKubernetes(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,26 +709,26 @@ 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, kubernetesCompatible bool) *Base { base := &Base{ - T: t, - Target: GetTarget(), - DaemonIsKillable: GetDaemonIsKillable(), - EnableIPv6: GetEnableIPv6(), - IPv6Compatible: ipv6Compatible, - EnableKube: GetEnableKube(), - KubeCompatible: kubeCompatible, - Env: os.Environ(), + T: t, + Target: GetTarget(), + DaemonIsKillable: GetDaemonIsKillable(), + EnableIPv6: GetEnableIPv6(), + IPv6Compatible: ipv6Compatible, + EnableKubernetes: GetEnableKubernetes(), + KubernetesCompatible: kubernetesCompatible, + Env: os.Environ(), } if base.EnableIPv6 && !base.IPv6Compatible { t.Skip("runner skips non-IPv6 compatible tests in the IPv6 environment") } 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.EnableKubernetes && !base.KubernetesCompatible { + t.Skip("runner skips non-Kubernetes compatible tests in the Kubernetes environment") + } else if !base.EnableKubernetes && base.KubernetesCompatible { + t.Skip("runner skips Kubernetes compatible tests in the non-Kubernetes environment") } var err error switch base.Target {