diff --git a/test/e2e/kwokctl/kind-podman/kubectl_test.go b/test/e2e/kwokctl/kind-podman/kubectl_test.go index bcea997b6..0a3e24b1e 100644 --- a/test/e2e/kwokctl/kind-podman/kubectl_test.go +++ b/test/e2e/kwokctl/kind-podman/kubectl_test.go @@ -73,11 +73,13 @@ func TestExec(t *testing.T) { testEnv.Test(t, f0) } -func TestRestart(t *testing.T) { - f0 := e2e.CaseRestart(kwokctlPath, clusterName). - Feature() - testEnv.Test(t, f0) -} +// Kind failed to start Load Kernel Modules +// https://github.com/kubernetes-sigs/kind/issues/3283 +// func TestRestart(t *testing.T) { +// f0 := e2e.CaseRestart(kwokctlPath, clusterName). +// Feature() +// testEnv.Test(t, f0) +// } func TestSnapshot(t *testing.T) { f0 := e2e.CaseSnapshot(kwokctlPath, clusterName, pwd). diff --git a/test/e2e/kwokctl/kind-podman/main_test.go b/test/e2e/kwokctl/kind-podman/main_test.go index 8f9c6709c..11f76d7ed 100644 --- a/test/e2e/kwokctl/kind-podman/main_test.go +++ b/test/e2e/kwokctl/kind-podman/main_test.go @@ -18,6 +18,7 @@ limitations under the License. package kind_podman_test import ( + "context" "os" "runtime" "testing" @@ -27,6 +28,8 @@ import ( "sigs.k8s.io/e2e-framework/support/kwok" "sigs.k8s.io/kwok/pkg/consts" + "sigs.k8s.io/kwok/pkg/log" + "sigs.k8s.io/kwok/pkg/utils/exec" "sigs.k8s.io/kwok/pkg/utils/path" "sigs.k8s.io/kwok/test/e2e/helper" ) @@ -62,14 +65,26 @@ func TestMain(m *testing.M) { testEnv.Setup( helper.BuildKwokImage(rootDir, testImage, consts.RuntimeTypePodman), helper.BuildKwokctlBinary(rootDir), - helper.CreateCluster(k, append(baseArgs, - "--config="+path.Join(rootDir, "test/e2e/port_forward.yaml"), - "--config="+path.Join(rootDir, "test/e2e/logs.yaml"), - "--config="+path.Join(rootDir, "test/e2e/attach.yaml"), - "--config="+path.Join(rootDir, "test/e2e/exec.yaml"), - "--config="+path.Join(rootDir, "kustomize/metrics/usage/usage-from-annotation.yaml"), - "--config="+path.Join(rootDir, "kustomize/metrics/resource/metrics-resource.yaml"), - )...), + func(ctx context.Context, cfg *envconf.Config) (context.Context, error) { + ctx, err := helper.CreateCluster(k, append(baseArgs, + "--config="+path.Join(rootDir, "test/e2e/port_forward.yaml"), + "--config="+path.Join(rootDir, "test/e2e/logs.yaml"), + "--config="+path.Join(rootDir, "test/e2e/attach.yaml"), + "--config="+path.Join(rootDir, "test/e2e/exec.yaml"), + "--config="+path.Join(rootDir, "kustomize/metrics/usage/usage-from-annotation.yaml"), + "--config="+path.Join(rootDir, "kustomize/metrics/resource/metrics-resource.yaml"), + )...)(ctx, cfg) + if err != nil { + logger := log.FromContext(ctx) + + logger.Info("exporting logs for control plane") + err := exec.Exec(ctx, "docker", "logs", "kwok-"+clusterName+"-control-plane") + if err != nil { + logger.Error("failed to export logs for control plane", err) + } + } + return ctx, err + }, helper.CreateNamespace(namespace), ) testEnv.Finish( diff --git a/test/e2e/kwokctl/kind/kubectl_test.go b/test/e2e/kwokctl/kind/kubectl_test.go index 66b59f6a6..ecb464c05 100644 --- a/test/e2e/kwokctl/kind/kubectl_test.go +++ b/test/e2e/kwokctl/kind/kubectl_test.go @@ -73,11 +73,13 @@ func TestExec(t *testing.T) { testEnv.Test(t, f0) } -func TestRestart(t *testing.T) { - f0 := e2e.CaseRestart(kwokctlPath, clusterName). - Feature() - testEnv.Test(t, f0) -} +// Kind failed to start Load Kernel Modules +// https://github.com/kubernetes-sigs/kind/issues/3283 +// func TestRestart(t *testing.T) { +// f0 := e2e.CaseRestart(kwokctlPath, clusterName). +// Feature() +// testEnv.Test(t, f0) +// } func TestSnapshot(t *testing.T) { f0 := e2e.CaseSnapshot(kwokctlPath, clusterName, pwd). diff --git a/test/e2e/kwokctl/kind/main_test.go b/test/e2e/kwokctl/kind/main_test.go index 53eacd791..0300364b5 100644 --- a/test/e2e/kwokctl/kind/main_test.go +++ b/test/e2e/kwokctl/kind/main_test.go @@ -18,6 +18,7 @@ limitations under the License. package kind_test import ( + "context" "os" "runtime" "testing" @@ -27,6 +28,8 @@ import ( "sigs.k8s.io/e2e-framework/support/kwok" "sigs.k8s.io/kwok/pkg/consts" + "sigs.k8s.io/kwok/pkg/log" + "sigs.k8s.io/kwok/pkg/utils/exec" "sigs.k8s.io/kwok/pkg/utils/path" "sigs.k8s.io/kwok/test/e2e/helper" ) @@ -62,14 +65,26 @@ func TestMain(m *testing.M) { testEnv.Setup( helper.BuildKwokImage(rootDir, testImage, consts.RuntimeTypeDocker), helper.BuildKwokctlBinary(rootDir), - helper.CreateCluster(k, append(baseArgs, - "--config="+path.Join(rootDir, "test/e2e/port_forward.yaml"), - "--config="+path.Join(rootDir, "test/e2e/logs.yaml"), - "--config="+path.Join(rootDir, "test/e2e/attach.yaml"), - "--config="+path.Join(rootDir, "test/e2e/exec.yaml"), - "--config="+path.Join(rootDir, "kustomize/metrics/usage/usage-from-annotation.yaml"), - "--config="+path.Join(rootDir, "kustomize/metrics/resource/metrics-resource.yaml"), - )...), + func(ctx context.Context, cfg *envconf.Config) (context.Context, error) { + ctx, err := helper.CreateCluster(k, append(baseArgs, + "--config="+path.Join(rootDir, "test/e2e/port_forward.yaml"), + "--config="+path.Join(rootDir, "test/e2e/logs.yaml"), + "--config="+path.Join(rootDir, "test/e2e/attach.yaml"), + "--config="+path.Join(rootDir, "test/e2e/exec.yaml"), + "--config="+path.Join(rootDir, "kustomize/metrics/usage/usage-from-annotation.yaml"), + "--config="+path.Join(rootDir, "kustomize/metrics/resource/metrics-resource.yaml"), + )...)(ctx, cfg) + if err != nil { + logger := log.FromContext(ctx) + + logger.Info("exporting logs for control plane") + err := exec.Exec(ctx, "docker", "logs", "kwok-"+clusterName+"-control-plane") + if err != nil { + logger.Error("failed to export logs for control plane", err) + } + } + return ctx, err + }, helper.CreateNamespace(namespace), ) testEnv.Finish( diff --git a/test/kwok-with-cni/kwok-with-cni.test.sh b/test/kwok-with-cni/kwok-with-cni.test.sh index d9ac4c393..2aea65cc8 100755 --- a/test/kwok-with-cni/kwok-with-cni.test.sh +++ b/test/kwok-with-cni/kwok-with-cni.test.sh @@ -19,7 +19,7 @@ DIR="$(realpath "${DIR}")" ROOT_DIR="$(realpath "${DIR}/../..")" -BASH_IMAGE=registry.k8s.io/build-image/distroless-iptables:v0.2.4 +BASH_IMAGE=registry.k8s.io/build-image/distroless-iptables:v0.5.1 CLUSTER_NAME=kwok-test KWOK_IMAGE="kwok-with-cni" KWOK_VERSION="test"