Skip to content

Commit

Permalink
K8s minor cleanup (rename and -f on delete)
Browse files Browse the repository at this point in the history
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
  • Loading branch information
apostasie committed Aug 21, 2024
1 parent 0192ab3 commit 7b357fc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/test-kube.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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'
4 changes: 2 additions & 2 deletions cmd/nerdctl/container_commit_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
File renamed without changes.
24 changes: 12 additions & 12 deletions pkg/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand All @@ -567,7 +567,7 @@ func GetEnableIPv6() bool {
return flagTestIPv6
}

func GetEnableKube() bool {
func GetEnableK8s() bool {
return flagTestKube
}

Expand Down Expand Up @@ -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.
Expand All @@ -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, 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 {
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.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 {
Expand Down

0 comments on commit 7b357fc

Please sign in to comment.