From 3ddb499adfd8ff50684226c1170a93f8d7dd7f4b Mon Sep 17 00:00:00 2001 From: Luca Di Maio Date: Fri, 1 Dec 2023 10:42:37 +0100 Subject: [PATCH 1/2] tests: add regression tests for nil pointer on invalid kubeconfig Signed-off-by: Luca Di Maio --- e2e/tests/pipelines/pipelines.go | 27 +++++++++++++++++++ .../testdata/invalid_kubeconfig/dep1.yaml | 6 +++++ .../testdata/invalid_kubeconfig/devspace.yaml | 10 +++++++ 3 files changed, 43 insertions(+) create mode 100644 e2e/tests/pipelines/testdata/invalid_kubeconfig/dep1.yaml create mode 100644 e2e/tests/pipelines/testdata/invalid_kubeconfig/devspace.yaml diff --git a/e2e/tests/pipelines/pipelines.go b/e2e/tests/pipelines/pipelines.go index f6fd111702..6476bc0dbb 100644 --- a/e2e/tests/pipelines/pipelines.go +++ b/e2e/tests/pipelines/pipelines.go @@ -418,3 +418,30 @@ var _ = DevSpaceDescribe("pipelines", func() { framework.ExpectNoError(err) }) }) + +var _ = DevSpaceDescribe("pipelines_without_kubeconfig", func() { + initialDir, err := os.Getwd() + if err != nil { + panic(err) + } + + // create a new factory + var ( + f factory.Factory + ) + ginkgo.It("should not panic on inalid kubeconfig", func() { + f = framework.NewDefaultFactory() + tempDir, err := framework.CopyToTempDir("tests/pipelines/testdata/invalid_kubeconfig") + framework.ExpectNoError(err) + defer framework.CleanupTempDir(initialDir, tempDir) + + devCmd := &cmd.RunPipelineCmd{ + GlobalFlags: &flags.GlobalFlags{ + NoWarn: true, + }, + Pipeline: "deploy", + } + err = devCmd.RunDefault(f) + framework.ExpectNoError(err) + }) +}) diff --git a/e2e/tests/pipelines/testdata/invalid_kubeconfig/dep1.yaml b/e2e/tests/pipelines/testdata/invalid_kubeconfig/dep1.yaml new file mode 100644 index 0000000000..6e45e1cb5e --- /dev/null +++ b/e2e/tests/pipelines/testdata/invalid_kubeconfig/dep1.yaml @@ -0,0 +1,6 @@ +version: v2beta1 +name: dep1 + +pipelines: + deploy: |- + echo "Hello World" diff --git a/e2e/tests/pipelines/testdata/invalid_kubeconfig/devspace.yaml b/e2e/tests/pipelines/testdata/invalid_kubeconfig/devspace.yaml new file mode 100644 index 0000000000..dc5e3933f6 --- /dev/null +++ b/e2e/tests/pipelines/testdata/invalid_kubeconfig/devspace.yaml @@ -0,0 +1,10 @@ +version: v2beta1 +name: wait + +dependencies: + dep1: + path: dep1.yaml + +pipelines: + deploy: |- + run_dependencies --all From fefb7d0992e963acd4c470bfb7c8e53ed3cedd2d Mon Sep 17 00:00:00 2001 From: Luca Di Maio Date: Fri, 1 Dec 2023 14:51:27 +0100 Subject: [PATCH 2/2] fix: try to resolve test flaking Signed-off-by: Luca Di Maio --- e2e/tests/pipelines/pipelines.go | 19 +++++++------------ e2e/tests/ssh/ssh.go | 4 ++-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/e2e/tests/pipelines/pipelines.go b/e2e/tests/pipelines/pipelines.go index 6476bc0dbb..d373a2a636 100644 --- a/e2e/tests/pipelines/pipelines.go +++ b/e2e/tests/pipelines/pipelines.go @@ -417,24 +417,19 @@ var _ = DevSpaceDescribe("pipelines", func() { err = devCmd.RunDefault(f) framework.ExpectNoError(err) }) -}) - -var _ = DevSpaceDescribe("pipelines_without_kubeconfig", func() { - initialDir, err := os.Getwd() - if err != nil { - panic(err) - } - // create a new factory - var ( - f factory.Factory - ) ginkgo.It("should not panic on inalid kubeconfig", func() { - f = framework.NewDefaultFactory() tempDir, err := framework.CopyToTempDir("tests/pipelines/testdata/invalid_kubeconfig") framework.ExpectNoError(err) defer framework.CleanupTempDir(initialDir, tempDir) + origEnv := os.Getenv("KUBE_CONFIG") + defer os.Setenv("KUBE_CONFIG", origEnv) + + os.Setenv("KUBE_CONFIG", "nonexistent.yaml") + newEnv := os.Getenv("KUBE_CONFIG") + framework.ExpectEqual(newEnv, "nonexistent.yaml") + devCmd := &cmd.RunPipelineCmd{ GlobalFlags: &flags.GlobalFlags{ NoWarn: true, diff --git a/e2e/tests/ssh/ssh.go b/e2e/tests/ssh/ssh.go index ebe32666cd..623cd94b55 100644 --- a/e2e/tests/ssh/ssh.go +++ b/e2e/tests/ssh/ssh.go @@ -84,7 +84,7 @@ var _ = DevSpaceDescribe("ssh", func() { framework.ExpectNoError(err) ginkgo.DeferCleanup(framework.CleanupTempDir, initialDir, tempDir) - ns, err := kubeClient.CreateNamespace("ssh") + ns, err := kubeClient.CreateNamespace("ssh-without-service") framework.ExpectNoError(err) ginkgo.DeferCleanup(framework.ExpectDeleteNamespace, kubeClient, ns) @@ -137,7 +137,7 @@ var _ = DevSpaceDescribe("ssh", func() { framework.ExpectNoError(err) ginkgo.DeferCleanup(framework.CleanupTempDir, initialDir, tempDir) - ns, err := kubeClient.CreateNamespace("ssh") + ns, err := kubeClient.CreateNamespace("ssh-with-service") framework.ExpectNoError(err) ginkgo.DeferCleanup(framework.ExpectDeleteNamespace, kubeClient, ns)