From 3fb36d9f050ad5c028bea3396631eec7110da39b Mon Sep 17 00:00:00 2001 From: rhkp Date: Mon, 26 Aug 2024 17:01:38 -0400 Subject: [PATCH] Minor tweaks to e2e tests --- .gitignore | 3 ++- Makefile | 4 +++- test/e2e/clusterplatform_test.go | 4 ++-- test/e2e/helpers.go | 10 ++++++++++ test/e2e/platform_test.go | 12 ++---------- test/e2e/workflow_test.go | 8 ++++---- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index d56122269..d92a4294b 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,5 @@ Dockerfile /target/ database/index.db -e2e-test-report.xml +e2e-test-report*.xml +*.tar \ No newline at end of file diff --git a/Makefile b/Makefile index ddb2ff8b3..1401f1a50 100644 --- a/Makefile +++ b/Makefile @@ -338,7 +338,9 @@ generate-all: generate generate-deploy bundle addheaders vet fmt .PHONY: test-e2e # You will need to have a Minikube/Kind cluster up in running to run this target, and run container-builder before the test test-e2e: - go test ./test/e2e/* -v -ginkgo.v -ginkgo.no-color -ginkgo.junit-report=./e2e-test-report.xml -timeout 120m + go test ./test/e2e/e2e_suite_test.go ./test/e2e/helpers.go ./test/e2e/clusterplatform_test.go -v -ginkgo.v -ginkgo.no-color -ginkgo.junit-report=./e2e-test-report-clusterplatform_test.xml -timeout 60m; + go test ./test/e2e/e2e_suite_test.go ./test/e2e/helpers.go ./test/e2e/platform_test.go -v -ginkgo.v -ginkgo.no-color -ginkgo.junit-report=./e2e-test-report-platform_test.xml -timeout 60m; + go test ./test/e2e/e2e_suite_test.go ./test/e2e/helpers.go ./test/e2e/workflow_test.go -v -ginkgo.v -ginkgo.no-color -ginkgo.junit-report=./e2e-test-report-workflow_test.xml -timeout 60m; .PHONY: before-pr before-pr: test generate-all diff --git a/test/e2e/clusterplatform_test.go b/test/e2e/clusterplatform_test.go index a2e316eb4..507662eb3 100644 --- a/test/e2e/clusterplatform_test.go +++ b/test/e2e/clusterplatform_test.go @@ -49,12 +49,12 @@ var _ = Describe("Validate a clusterplatform", Ordered, func() { ) BeforeEach(func() { - targetNamespace = fmt.Sprintf("test-%d", rand.Intn(1024)+1) + targetNamespace = fmt.Sprintf("test-%d", rand.Intn(randomIntRange)+1) cmd := exec.Command("kubectl", "create", "namespace", targetNamespace) _, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) - targetNamespace2 = fmt.Sprintf("test-%d", rand.Intn(1024)+1) + targetNamespace2 = fmt.Sprintf("test-%d", rand.Intn(randomIntRange)+1) cmd = exec.Command("kubectl", "create", "namespace", targetNamespace2) _, err = utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) diff --git a/test/e2e/helpers.go b/test/e2e/helpers.go index 104afa315..6d4228a3c 100644 --- a/test/e2e/helpers.go +++ b/test/e2e/helpers.go @@ -44,6 +44,16 @@ type check struct { Data map[string]string `json:"data"` } +const ( + ephemeral = "ephemeral" + postgreSQL = "postgreSQL" + clusterWideEphemeral = "cluster-wide-ephemeral" + ephemeralDataIndex = "ephemeral-data-index" + ephemeralJobService = "ephemeral-job-service" +) + +const randomIntRange = 16384 //Set to large number to avoid cluster namespace name collisions + var ( upStatus string = "UP" ) diff --git a/test/e2e/platform_test.go b/test/e2e/platform_test.go index 511503be5..bd400cc60 100644 --- a/test/e2e/platform_test.go +++ b/test/e2e/platform_test.go @@ -36,14 +36,6 @@ import ( . "github.com/onsi/gomega" ) -const ( - ephemeral = "ephemeral" - postgreSQL = "postgreSQL" - clusterWideEphemeral = "cluster-wide-ephemeral" - ephemeralDataIndex = "ephemeral-data-index" - ephemeralJobService = "ephemeral-job-service" -) - var _ = Describe("Validate the persistence", Ordered, func() { var ( @@ -52,7 +44,7 @@ var _ = Describe("Validate the persistence", Ordered, func() { ) BeforeEach(func() { - targetNamespace = fmt.Sprintf("test-%d", rand.Intn(1024)+1) + targetNamespace = fmt.Sprintf("test-%d", rand.Intn(randomIntRange)+1) cmd := exec.Command("kubectl", "create", "namespace", targetNamespace) _, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) @@ -113,7 +105,7 @@ var _ = Describe("Validate the persistence", Ordered, func() { Expect(sf).NotTo(BeEmpty(), "sonataflow name is empty") EventuallyWithOffset(1, func() bool { return verifyWorkflowIsInRunningStateInNamespace(sf, targetNamespace) - }, 10*time.Minute, 5).Should(BeTrue()) + }, 15*time.Minute, 1*time.Minute).Should(BeTrue()) } }, Entry("with both Job Service and Data Index and ephemeral persistence and the workflow in a dev profile", test.GetSonataFlowE2EPlatformServicesDirectory(), metadata.DevProfile.String(), ephemeral), diff --git a/test/e2e/workflow_test.go b/test/e2e/workflow_test.go index ed8f95c4e..8b6e1c99c 100644 --- a/test/e2e/workflow_test.go +++ b/test/e2e/workflow_test.go @@ -44,7 +44,7 @@ var _ = Describe("SonataFlow Operator", Ordered, func() { var targetNamespace string BeforeEach(func() { - targetNamespace = fmt.Sprintf("test-%d", rand.Intn(1024)+1) + targetNamespace = fmt.Sprintf("test-%d", rand.Intn(randomIntRange)+1) cmd := exec.Command("kubectl", "create", "namespace", targetNamespace) _, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) @@ -153,7 +153,7 @@ var _ = Describe("Validate the persistence ", Ordered, func() { ) BeforeEach(func() { - ns = fmt.Sprintf("test-%d", rand.Intn(1024)+1) + ns = fmt.Sprintf("test-%d", rand.Intn(randomIntRange)+1) cmd := exec.Command("kubectl", "create", "namespace", ns) _, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) @@ -188,7 +188,7 @@ var _ = Describe("Validate the persistence ", Ordered, func() { out, err := utils.Run(cmd) GinkgoWriter.Printf("%s\n", string(out)) return err - }, 12*time.Minute, 5).Should(Succeed()) + }, 15*time.Minute, 1*time.Minute).Should(Succeed()) By("Evaluate status of the workflow's pod database connection health endpoint") cmd = exec.Command("kubectl", "get", "pod", "-l", "sonataflow.org/workflow-app", "-n", ns, "-ojsonpath={.items[*].metadata.name}") @@ -224,7 +224,7 @@ var _ = Describe("Validate the persistence ", Ordered, func() { } } return false - }, 1*time.Minute).Should(BeTrue()) + }, 4*time.Minute).Should(BeTrue()) // Persistence initialization checks cmd = exec.Command("kubectl", "get", "pod", "-l", "sonataflow.org/workflow-app", "-n", ns, "-ojsonpath={.items[*].metadata.name}") output, err = utils.Run(cmd)