diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 3001478..902a247 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -108,6 +108,14 @@ var _ = Describe("controller", Ordered, func() { if err == nil { fmt.Fprintf(GinkgoWriter, "info: %s\n", podlogs) } + // cmd = exec.Command(utils.Kubectl(), "logs", + // controllerPodName, "-c", "manager", + // "-n", namespace, "--previous", + // ) + // podlogs, err = utils.Run(cmd) + // if err == nil { + // fmt.Fprintf(GinkgoWriter, "info: previous %s\n", podlogs) + // } } By("stop metrics consumer") diff --git a/test/e2e/testdata/taskqos/lagoon-task-2xpyz5m.json b/test/e2e/testdata/taskqos/lagoon-task-2xpyz5m.json index 1434436..41f1c75 100644 --- a/test/e2e/testdata/taskqos/lagoon-task-2xpyz5m.json +++ b/test/e2e/testdata/taskqos/lagoon-task-2xpyz5m.json @@ -18,7 +18,7 @@ }, \"environment\": { \"id\": 1, - \"environmentType\": \"production\", + \"environmentType\": \"development\", \"name\": \"dev1\", \"project\": \"nginx-example\" }, diff --git a/test/e2e/testdata/taskqos/lagoon-task-3xpyz5m.json b/test/e2e/testdata/taskqos/lagoon-task-3xpyz5m.json index 756275c..8d9b490 100644 --- a/test/e2e/testdata/taskqos/lagoon-task-3xpyz5m.json +++ b/test/e2e/testdata/taskqos/lagoon-task-3xpyz5m.json @@ -18,7 +18,7 @@ }, \"environment\": { \"id\": 1, - \"environmentType\": \"production\", + \"environmentType\": \"development\", \"name\": \"dev2\", \"project\": \"nginx-example\" }, diff --git a/test/e2e/testdata/taskqos/lagoon-task-4xpyz5m.json b/test/e2e/testdata/taskqos/lagoon-task-4xpyz5m.json index 22976dd..e3f5d90 100644 --- a/test/e2e/testdata/taskqos/lagoon-task-4xpyz5m.json +++ b/test/e2e/testdata/taskqos/lagoon-task-4xpyz5m.json @@ -18,7 +18,7 @@ }, \"environment\": { \"id\": 1, - \"environmentType\": \"production\", + \"environmentType\": \"development\", \"name\": \"dev3\", \"project\": \"nginx-example\" }, diff --git a/test/utils/utils.go b/test/utils/utils.go index d118c61..6bb041c 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -21,6 +21,7 @@ import ( "os" "os/exec" "strings" + "time" "github.com/onsi/ginkgo/v2" ) @@ -62,6 +63,12 @@ func Kubectl() string { func StartLocalServices() error { cmd := exec.Command("docker", "compose", "up", "-d") _, err := Run(cmd) + if err != nil { + return err + } + time.Sleep(10 * time.Second) + cmd = exec.Command("docker", "compose", "exec", "local-broker", "rabbitmqadmin", "declare", "exchange", "--vhost=/", "name=lagoon-logs", "type=direct") + _, err = Run(cmd) return err } @@ -75,12 +82,15 @@ func StopLocalServices() { // CleanupNamespace cleans up a namespace and all potentially stuck resources func CleanupNamespace(namespace string) { - cmd := exec.Command("kubectl", "delete", "ns", namespace, "--timeout=30s") + cmd := exec.Command(kubectlPath, "delete", "ns", namespace, "--timeout=30s") if _, err := Run(cmd); err != nil { + if strings.Contains(err.Error(), "not found") { + return + } infoError(err) } // check for builds - cmd = exec.Command("kubectl", "-n", namespace, "get", "lagoonbuilds", + cmd = exec.Command(kubectlPath, "-n", namespace, "get", "lagoonbuilds", "-o", "go-template={{ range .items }}"+ "{{ .metadata.name }}"+ "{{ \"\\n\" }}{{ end }}", @@ -93,7 +103,7 @@ func CleanupNamespace(namespace string) { if len(builds) > 0 { for _, build := range builds { fmt.Fprintf(ginkgo.GinkgoWriter, "info: %v\n", "patching stuck builds for removal") - cmd = exec.Command("kubectl", "-n", namespace, "patch", "lagoonbuild", + cmd = exec.Command(kubectlPath, "-n", namespace, "patch", "lagoonbuild", build, "--type", "merge", "-p", "{\"metadata\":{\"finalizers\":null}}", ) @@ -102,13 +112,13 @@ func CleanupNamespace(namespace string) { infoError(err) } } - cmd = exec.Command("kubectl", "delete", "ns", namespace) + cmd = exec.Command(kubectlPath, "delete", "ns", namespace) if _, err := Run(cmd); err != nil { infoError(err) } } // check for tasks - cmd = exec.Command("kubectl", "-n", namespace, "get", "lagoontasks", + cmd = exec.Command(kubectlPath, "-n", namespace, "get", "lagoontasks", "-o", "go-template={{ range .items }}"+ "{{ .metadata.name }}"+ "{{ \"\\n\" }}{{ end }}", @@ -121,7 +131,7 @@ func CleanupNamespace(namespace string) { if len(tasks) > 0 { for _, task := range tasks { fmt.Fprintf(ginkgo.GinkgoWriter, "info: %v\n", "patching stuck tasks for removal") - cmd = exec.Command("kubectl", "-n", namespace, "patch", "lagoontask", + cmd = exec.Command(kubectlPath, "-n", namespace, "patch", "lagoontask", task, "--type", "merge", "-p", "{\"metadata\":{\"finalizers\":null}}", ) @@ -130,7 +140,7 @@ func CleanupNamespace(namespace string) { infoError(err) } } - cmd = exec.Command("kubectl", "delete", "ns", namespace) + cmd = exec.Command(kubectlPath, "delete", "ns", namespace) if _, err := Run(cmd); err != nil { infoError(err) }