Skip to content

Commit

Permalink
test: adjustments for broker and other minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Jan 29, 2025
1 parent 97eef5f commit c63fe6e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
8 changes: 8 additions & 0 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/testdata/taskqos/lagoon-task-2xpyz5m.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
\"environment\": {
\"id\": 1,
\"environmentType\": \"production\",
\"environmentType\": \"development\",
\"name\": \"dev1\",
\"project\": \"nginx-example\"
},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/testdata/taskqos/lagoon-task-3xpyz5m.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
\"environment\": {
\"id\": 1,
\"environmentType\": \"production\",
\"environmentType\": \"development\",
\"name\": \"dev2\",
\"project\": \"nginx-example\"
},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/testdata/taskqos/lagoon-task-4xpyz5m.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
\"environment\": {
\"id\": 1,
\"environmentType\": \"production\",
\"environmentType\": \"development\",
\"name\": \"dev3\",
\"project\": \"nginx-example\"
},
Expand Down
24 changes: 17 additions & 7 deletions test/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"
"os/exec"
"strings"
"time"

"github.com/onsi/ginkgo/v2"
)
Expand Down Expand Up @@ -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
}

Expand All @@ -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 }}",
Expand All @@ -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}}",
)
Expand All @@ -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 }}",
Expand All @@ -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}}",
)
Expand All @@ -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)
}
Expand Down

0 comments on commit c63fe6e

Please sign in to comment.