diff --git a/.ci/jenkins/Jenkinsfile.e2e.cluster b/.ci/jenkins/Jenkinsfile.e2e.cluster index b5154523a..8657fa3e5 100644 --- a/.ci/jenkins/Jenkinsfile.e2e.cluster +++ b/.ci/jenkins/Jenkinsfile.e2e.cluster @@ -46,7 +46,7 @@ pipeline { helper.checkoutRepo() assert getTestImage(): 'Please provide a Test image' - container.pullImage(getTestImage()) // Verify image exists + container.pullImage(getTestImage()) // Verify image namespaceExists } } } diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f2b2cb20a..ec598cc88 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -86,8 +86,8 @@ jobs: make deploy IMG=${{ env.OPERATOR_IMAGE_NAME }} kubectl wait pod -A -l control-plane=sonataflow-operator --for condition=Ready - - name: Run E2E Tests for Non-Persistent Flows - run: make test-e2e label=flows-non-persistence + - name: Run E2E Tests for Ephemeral Flows + run: make test-e2e label=flows-ephemeral - name: Run E2E Tests for Persistent Flows run: make test-e2e label=flows-persistence diff --git a/Makefile b/Makefile index 147ec4489..a768f93d3 100644 --- a/Makefile +++ b/Makefile @@ -119,6 +119,9 @@ vet: ## Run go vet against code. .PHONY: test test: manifests generate envtest test-api ## Run tests. + @$(MAKE) addheaders + @$(MAKE) vet + @$(MAKE) fmt @echo "๐Ÿ” Running controller tests..." @KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \ go test $(shell go list ./... | grep -v /test/) -coverprofile cover.out > /dev/null 2>&1 @@ -399,30 +402,30 @@ generate-all: generate generate-deploy bundle @$(MAKE) fmt .PHONY: test-e2e # You will need to have a Minikube/Kind cluster up and running to run this target, and run container-builder before the test -label = "flows-non-persistence" # possible values are flows-non-persistence, flows-persistence, platform, cluster +label = "flows-ephemeral" # possible values are flows-ephemeral, flows-persistence, platform, cluster test-e2e: ifeq ($(label), cluster) @echo "๐ŸŒ Running e2e tests for cluster..." go test ./test/e2e/e2e_suite_test.go ./test/e2e/helpers.go ./test/e2e/clusterplatform_test.go \ -v -ginkgo.v -ginkgo.no-color -ginkgo.github-output -ginkgo.label-filter=$(label) \ - -ginkgo.junit-report=./e2e-test-report-clusterplatform_test.xml -timeout 60m; + -ginkgo.junit-report=./e2e-test-report-clusterplatform_test.xml -timeout 60m KUSTOMIZE=$(KUSTOMIZE); else ifeq ($(label), platform) @echo "๐Ÿ“ฆ Running e2e tests for platform..." go test ./test/e2e/e2e_suite_test.go ./test/e2e/helpers.go ./test/e2e/platform_test.go \ -v -ginkgo.v -ginkgo.no-color -ginkgo.github-output -ginkgo.label-filter=$(label) \ - -ginkgo.junit-report=./e2e-test-report-platform_test.xml -timeout 60m; -else ifeq ($(label), flows-non-persistence) - @echo "๐Ÿ”„ Running e2e tests for flows-non-persistence..." + -ginkgo.junit-report=./e2e-test-report-platform_test.xml -timeout 60m KUSTOMIZE=$(KUSTOMIZE); +else ifeq ($(label), flows-ephemeral) + @echo "๐Ÿ”„ Running e2e tests for flows-ephemeral..." go test ./test/e2e/e2e_suite_test.go ./test/e2e/helpers.go ./test/e2e/workflow_test.go \ -v -ginkgo.v -ginkgo.no-color -ginkgo.github-output -ginkgo.label-filter=$(label) \ - -ginkgo.junit-report=./e2e-test-report-workflow_test.xml -timeout 60m; + -ginkgo.junit-report=./e2e-test-report-workflow_test.xml -timeout 60m KUSTOMIZE=$(KUSTOMIZE); else ifeq ($(label), flows-persistence) @echo "๐Ÿ” Running e2e tests for flows-persistence..." go test ./test/e2e/e2e_suite_test.go ./test/e2e/helpers.go ./test/e2e/workflow_test.go \ -v -ginkgo.v -ginkgo.no-color -ginkgo.github-output -ginkgo.label-filter=$(label) \ - -ginkgo.junit-report=./e2e-test-report-workflow_test.xml -timeout 60m; + -ginkgo.junit-report=./e2e-test-report-workflow_test.xml -timeout 60m KUSTOMIZE=$(KUSTOMIZE); else - @echo "โŒ Invalid label. Please use one of: cluster, platform, flows-non-persistence, flows-persistence" + @echo "โŒ Invalid label. Please use one of: cluster, platform, flows-ephemeral, flows-persistence" endif diff --git a/hack/local/run-e2e.sh b/hack/local/run-e2e.sh index 3515b6c0a..945186133 100755 --- a/hack/local/run-e2e.sh +++ b/hack/local/run-e2e.sh @@ -20,7 +20,8 @@ # You must have minikube installed MINIKUBE_PROFILE=${1:-minikube} SKIP_IMG_BUILD=${2:-false} -TEST_LABELS=${3:-"flows-non-persistence"} # possible values are flows-non-persistence, flows-persistence, platform, cluster +TEST_LABELS=${3:-"flows-ephemeral"} # possible values are flows-ephemeral, flows-persistence, platform, cluster +SKIP_UNDEPLOY=${4:-false} # Emoticons and enhanced messages echo "๐Ÿš€ Using minikube profile ${MINIKUBE_PROFILE}" @@ -37,8 +38,13 @@ fi # clean up previous runs, hiding logs echo "๐Ÿงน Cleaning up previous test namespaces..." kubectl get namespaces -o name | awk -F/ '/^namespace\/test/ {print $2}' | xargs kubectl delete namespace &> /dev/null -echo "๐Ÿงน Undeploying previous instances..." -make undeploy ignore-not-found=true &> /dev/null + +if [ "${SKIP_UNDEPLOY}" = false ]; then + echo "๐Ÿงน Cleaning up previous test resources namespace..." + kubectl delete namespace e2e-resources &> /dev/null + echo "๐Ÿงน Undeploying previous instances..." + make undeploy ignore-not-found=true &> /dev/null +fi # Image build process if [ "${SKIP_IMG_BUILD}" = "false" ]; then diff --git a/internal/controller/platform/platformutils_test.go b/internal/controller/platform/platformutils_test.go index 2a800122b..8df0a80b3 100644 --- a/internal/controller/platform/platformutils_test.go +++ b/internal/controller/platform/platformutils_test.go @@ -37,7 +37,7 @@ const dockerFile = "FROM docker.io/apache/default-test-kie-sonataflow-builder:ma func TestSonataFlowBuildController(t *testing.T) { platform := test.GetBasePlatform() - dockerfileBytes, err := os.ReadFile("../../../test/builder/Dockerfile") + dockerfileBytes, err := os.ReadFile("testdata/platformTest.Dockerfile") if err != nil { assert.Fail(t, "Unable to read base Dockerfile") } diff --git a/test/builder/Dockerfile b/internal/controller/platform/testdata/platformTest.Dockerfile similarity index 96% rename from test/builder/Dockerfile rename to internal/controller/platform/testdata/platformTest.Dockerfile index 41dbbae39..c9b902ba3 100644 --- a/test/builder/Dockerfile +++ b/internal/controller/platform/testdata/platformTest.Dockerfile @@ -24,7 +24,7 @@ USER 1001 WORKDIR /home/kogito/kogito-base # Copy from build context to skeleton resources project -COPY --chown=1001 . ./src/main/resources +COPY --chown=1001 ../../../../test/builder ./src/main/resources # Maven vars enhirited from the base image RUN ${MAVEN_HOME}/bin/mvn -U -B ${MAVEN_ARGS_APPEND} -s ${MAVEN_SETTINGS_PATH} clean install -DskipTests diff --git a/test/builder/greetings.sw.json b/test/builder/greetings.sw.json deleted file mode 100644 index a619b3b8b..000000000 --- a/test/builder/greetings.sw.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "id": "jsongreet", - "version": "1.0", - "name": "Greeting workflow", - "description": "JSON based greeting workflow", - "start": "ChooseOnLanguage", - "functions": [ - { - "name": "greetFunction", - "type": "custom", - "operation": "sysout" - } - ], - "states": [ - { - "name": "ChooseOnLanguage", - "type": "switch", - "dataConditions": [ - { - "condition": "${ .language == \"English\" }", - "transition": "GreetInEnglish" - }, - { - "condition": "${ .language == \"Spanish\" }", - "transition": "GreetInSpanish" - } - ], - "defaultCondition": { - "transition": "GreetInEnglish" - } - }, - { - "name": "GreetInEnglish", - "type": "inject", - "data": { - "greeting": "Hello from JSON Workflow, " - }, - "transition": "GreetPerson" - }, - { - "name": "GreetInSpanish", - "type": "inject", - "data": { - "greeting": "Saludos desde JSON Workflow, " - }, - "transition": "GreetPerson" - }, - { - "name": "GreetPerson", - "type": "operation", - "actions": [ - { - "name": "greetAction", - "functionRef": { - "refName": "greetFunction", - "arguments": { - "message": ".greeting+.name" - } - } - } - ], - "end": { - "terminate": true - } - } - ] -} diff --git a/test/e2e/clusterplatform_test.go b/test/e2e/clusterplatform_test.go index 8602afab2..68bc6d066 100644 --- a/test/e2e/clusterplatform_test.go +++ b/test/e2e/clusterplatform_test.go @@ -73,6 +73,11 @@ var _ = Describe("Cluster Platform Use Cases :: ", Label("cluster"), Ordered, fu Expect(err).NotTo(HaveOccurred()) } } + + // Remove SonataFlowClusterPlatform created in the last run + cmd := exec.Command("kubectl", "delete", "sonataflowclusterplatform", "--all", "--wait") + _, err := utils.Run(cmd) + Expect(err).NotTo(HaveOccurred()) }) var _ = Context("with supporting services enabled", func() { DescribeTable("against a platform in a separate namespace", func(testcaseDir string, profile string, persistenceType string, withServices bool) { @@ -80,8 +85,8 @@ var _ = Describe("Cluster Platform Use Cases :: ", Label("cluster"), Ordered, fu var manifests []byte EventuallyWithOffset(1, func() error { var err error - cmd := exec.Command("kubectl", "kustomize", filepath.Join(projectDir, - test.GetSonataFlowE2EPlatformServicesDirectory(), profile, clusterWideEphemeral)) + cmd := exec.Command("kubectl", "kustomize", + test.GetPathFromE2EDirectory("platform", "services", profile, clusterWideEphemeral)) manifests, err = utils.Run(cmd) return err }, time.Minute, time.Second).Should(Succeed()) @@ -91,7 +96,7 @@ var _ = Describe("Cluster Platform Use Cases :: ", Label("cluster"), Ordered, fu _, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) - By("Wait for SonatatFlowPlatform CR in " + targetNamespace + " to be ready") + By("Wait for SonataFlowPlatform CR in " + targetNamespace + " to be ready") // wait for platform to be ready EventuallyWithOffset(1, func() error { cmd = exec.Command("kubectl", "wait", "sfplatform", "-n", targetNamespace, "sonataflow-platform", "--for", "condition=Succeed", "--timeout=5s") @@ -116,7 +121,7 @@ var _ = Describe("Cluster Platform Use Cases :: ", Label("cluster"), Ordered, fu }, 20*time.Minute, 5).Should(Succeed()) if withServices { - By("Deploy SonatatFlowPlatform CR with services configured in " + targetNamespace2) + By("Deploy SonataFlowPlatform CR with services configured in " + targetNamespace2) EventuallyWithOffset(1, func() error { var err error cmd := exec.Command("kubectl", "kustomize", filepath.Join(projectDir, @@ -148,18 +153,24 @@ var _ = Describe("Cluster Platform Use Cases :: ", Label("cluster"), Ordered, fu return returnedValue }, 20*time.Minute, 5).Should(Equal([]byte("''"))) + By("Replacing the image with a prebuilt one and rollout") + EventuallyWithOffset(1, func() error { + return kubectlPatchSonataFlowImageAndRollout(targetNamespace2, prebuiltWorkflows.CallBack.Name, prebuiltWorkflows.CallBack.Tag) + }, 3*time.Minute, time.Second).Should(Succeed()) + + By("Waiting for Data Index and Jobs Service URLs") dataIndexServiceUrl := services.GenerateServiceURL(constants.DefaultHTTPProtocol, targetNamespace2, "sonataflow-platform-"+constants.DataIndexServiceName) jobServiceUrl := services.GenerateServiceURL(constants.DefaultHTTPProtocol, targetNamespace2, "sonataflow-platform-"+constants.JobServiceName) EventuallyWithOffset(1, func() []byte { - cmd = exec.Command("kubectl", "get", "sf", "-n", targetNamespace2, "callbackstatetimeouts", "-o", "jsonpath='{.status.services.dataIndexRef.url}'") + cmd = exec.Command("kubectl", "get", "sf", "-n", targetNamespace2, prebuiltWorkflows.CallBack.Name, "-o", "jsonpath='{.status.services.dataIndexRef.url}'") returnedValue, _ := utils.Run(cmd) return returnedValue - }, 20*time.Minute, 5).Should(Equal([]byte("'" + dataIndexServiceUrl + "'"))) + }, 3*time.Minute, 5).Should(Equal([]byte("'" + dataIndexServiceUrl + "'"))) EventuallyWithOffset(1, func() []byte { - cmd = exec.Command("kubectl", "get", "sf", "-n", targetNamespace2, "callbackstatetimeouts", "-o", "jsonpath='{.status.services.jobServiceRef.url}'") + cmd = exec.Command("kubectl", "get", "sf", "-n", targetNamespace2, prebuiltWorkflows.CallBack.Name, "-o", "jsonpath='{.status.services.jobServiceRef.url}'") returnedValue, _ := utils.Run(cmd) return returnedValue - }, 20*time.Minute, 5).Should(Equal([]byte("'" + jobServiceUrl + "'"))) + }, 3*time.Minute, 5).Should(Equal([]byte("'" + jobServiceUrl + "'"))) } else { EventuallyWithOffset(1, func() error { var err error @@ -193,23 +204,30 @@ var _ = Describe("Cluster Platform Use Cases :: ", Label("cluster"), Ordered, fu returnedValue, _ := utils.Run(cmd) return returnedValue }, 20*time.Minute, 5).Should(Equal([]byte("'" + jobServiceUrl + "'"))) + + By("Replacing the image with a prebuilt one and rollout") + EventuallyWithOffset(1, func() error { + return kubectlPatchSonataFlowImageAndRollout(targetNamespace2, prebuiltWorkflows.CallBack.Name, prebuiltWorkflows.CallBack.Tag) + }, 3*time.Minute, time.Second).Should(Succeed()) + + By("Waiting for Data Index and Jobs Service URLs") EventuallyWithOffset(1, func() []byte { - cmd = exec.Command("kubectl", "get", "sf", "-n", targetNamespace2, "callbackstatetimeouts", "-o", "jsonpath='{.status.services.dataIndexRef.url}'") + cmd = exec.Command("kubectl", "get", "sf", "-n", targetNamespace2, prebuiltWorkflows.CallBack.Name, "-o", "jsonpath='{.status.services.dataIndexRef.url}'") returnedValue, _ := utils.Run(cmd) return returnedValue - }, 20*time.Minute, 5).Should(Equal([]byte("'" + dataIndexServiceUrl + "'"))) + }, 3*time.Minute, 5).Should(Equal([]byte("'" + dataIndexServiceUrl + "'"))) EventuallyWithOffset(1, func() []byte { - cmd = exec.Command("kubectl", "get", "sf", "-n", targetNamespace2, "callbackstatetimeouts", "-o", "jsonpath='{.status.services.jobServiceRef.url}'") + cmd = exec.Command("kubectl", "get", "sf", "-n", targetNamespace2, prebuiltWorkflows.CallBack.Name, "-o", "jsonpath='{.status.services.jobServiceRef.url}'") returnedValue, _ := utils.Run(cmd) return returnedValue - }, 20*time.Minute, 5).Should(Equal([]byte("'" + jobServiceUrl + "'"))) + }, 3*time.Minute, 5).Should(Equal([]byte("'" + jobServiceUrl + "'"))) } cmd = exec.Command("kubectl", "delete", "SonataFlowClusterPlatform", "cluster", "--wait") _, err = utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) }, - Entry("without services configured", test.GetSonataFlowE2EPlatformNoServicesDirectory(), metadata.PreviewProfile.String(), ephemeral, false), - Entry("with services configured", test.GetSonataFlowE2EPlatformServicesDirectory(), metadata.PreviewProfile.String(), "ephemeral-with-workflow", true), + Entry("without services configured", test.GetPathFromE2EDirectory("platform", "noservices"), metadata.GitOpsProfile.String(), ephemeral, false), + Entry("with services configured", test.GetPathFromE2EDirectory("platform", "services"), metadata.GitOpsProfile.String(), "ephemeral-with-workflow", true), ) DescribeTable("against a platform in a separate namespace", func(testcaseDir string, profile string, persistenceType string) { @@ -217,8 +235,7 @@ var _ = Describe("Cluster Platform Use Cases :: ", Label("cluster"), Ordered, fu var manifests []byte EventuallyWithOffset(1, func() error { var err error - cmd := exec.Command("kubectl", "kustomize", filepath.Join(projectDir, - test.GetSonataFlowE2EPlatformServicesDirectory(), profile, clusterWideEphemeral)) + cmd := exec.Command("kubectl", "kustomize", test.GetPathFromE2EDirectory("platform", "services", profile, clusterWideEphemeral)) manifests, err = utils.Run(cmd) return err }, time.Minute, time.Second).Should(Succeed()) @@ -287,8 +304,8 @@ var _ = Describe("Cluster Platform Use Cases :: ", Label("cluster"), Ordered, fu _, err = utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) }, - Entry("with only Data Index configured", test.GetSonataFlowE2EPlatformServicesDirectory(), metadata.PreviewProfile.String(), ephemeralDataIndex), - Entry("with only Job Service configured", test.GetSonataFlowE2EPlatformServicesDirectory(), metadata.PreviewProfile.String(), ephemeralJobService), + Entry("with only Data Index configured", test.GetPathFromE2EDirectory("platform", "services"), metadata.GitOpsProfile.String(), ephemeralDataIndex), + Entry("with only Job Service configured", test.GetPathFromE2EDirectory("platform", "services"), metadata.GitOpsProfile.String(), ephemeralJobService), ) }) }) diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 25113c8fb..e249d3993 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -20,8 +20,14 @@ package e2e import ( + "context" "fmt" + "os/exec" "testing" + "time" + + "github.com/apache/incubator-kie-kogito-serverless-operator/test" + "github.com/apache/incubator-kie-kogito-serverless-operator/test/utils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -30,6 +36,149 @@ import ( // Run e2e tests using the Ginkgo runner. func TestE2E(t *testing.T) { RegisterFailHandler(Fail) - fmt.Fprintf(GinkgoWriter, "Starting SonataFlow Operator suite\n") - RunSpecs(t, "SonataFlow e2e suite") + GinkgoWriter.Println("Starting SonataFlow Operator suite") + RunSpecs(t, "SonataFlow Operator e2e suite") +} + +// prebuiltWorkflows global accessor for the prebuilt workflows +var prebuiltWorkflows E2EWorkflows + +const ( + // resourcesNamespace is the global namespace used to deploy e2e resources + resourcesNamespace = "e2e-resources" + // waitForBuildTimeout is the time we should wait for the workflows to be deployed + waitForBuildTimeout = 15 * time.Minute + + flowCallbackPersistenceName = "callbackstatetimeouts-persistence" + flowCallbackName = "callbackstatetimeouts" + flowGreetingsName = "greetings" +) + +type E2EWorkflowEntry struct { + Name string + Tag string +} + +func (e *E2EWorkflowEntry) String() string { + return fmt.Sprintf("%s: %s", e.Name, e.Tag) +} + +type E2EWorkflows struct { + // CallBackPersistence is the prebuilt workflow to use on every use case that requires persistence + CallBackPersistence E2EWorkflowEntry + // CallBack is the prebuilt workflow to use on every use case that requires events or jobs services integration + CallBack E2EWorkflowEntry + // Greetings is the general usage image to use on any use case that requires a SonataFlow deployment + Greetings E2EWorkflowEntry +} + +func (e *E2EWorkflows) String() string { + return fmt.Sprintf("%s \n %s \n %s", e.CallBack, e.CallBackPersistence, e.Greetings) +} + +type DeployedWorkflow struct { + YAMLFile string + ImageTag string +} + +var _ = BeforeSuite(func() { + GinkgoWriter.Print("Checking if resources namespace is available\n") + namespaceExists, err := kubectlNamespaceExists(resourcesNamespace) + Expect(err).NotTo(HaveOccurred()) + + workflows := make(map[string]*DeployedWorkflow, 2) + workflows[flowCallbackName] = &DeployedWorkflow{YAMLFile: test.GetPathFromE2EDirectory("before-suite", "sonataflow.org_v1alpha08_sonataflow-callbackstatetimeouts.yaml")} + workflows[flowCallbackPersistenceName] = &DeployedWorkflow{YAMLFile: test.GetPathFromE2EDirectory("before-suite", "sonataflow.org_v1alpha08_sonataflow-callbackstatetimeouts-persistence.yaml")} + workflows[flowGreetingsName] = &DeployedWorkflow{YAMLFile: test.GetPathFromE2EDirectory("before-suite", "sonataflow.org_v1alpha08_sonataflow-greetings.yaml")} + if !namespaceExists { + GinkgoWriter.Println("Creating the resources namespace") + err = kubectlCreateNamespace(resourcesNamespace) + Expect(err).NotTo(HaveOccurred()) + + GinkgoWriter.Println("Pre-built workflows within the cluster") + err = deployWorkflowsAndWaitForBuild(workflows) + Expect(err).NotTo(HaveOccurred()) + } else { + GinkgoWriter.Println("Fetch pre-built workflows images in the cluster") + err = fetchImageTagsBuiltWorkflows(workflows) + Expect(err).NotTo(HaveOccurred()) + } + + // Convert to a simpler structure + prebuiltWorkflows.CallBack.Tag = workflows[flowCallbackName].ImageTag + prebuiltWorkflows.CallBack.Name = flowCallbackName + prebuiltWorkflows.CallBackPersistence.Tag = workflows[flowCallbackPersistenceName].ImageTag + prebuiltWorkflows.CallBackPersistence.Name = flowCallbackPersistenceName + prebuiltWorkflows.Greetings.Tag = workflows[flowGreetingsName].ImageTag + prebuiltWorkflows.Greetings.Name = flowGreetingsName + GinkgoWriter.Println("Images are ready for upcoming tests") + + // Delete the workflows since we already have the images in the internal registry, all gucci + for name := range workflows { + err = kubectlPatchSonataFlowScaleDown(resourcesNamespace, name) + Expect(err).NotTo(HaveOccurred()) + } +}) + +func deployWorkflows(workflows map[string]*DeployedWorkflow) error { + for _, workflow := range workflows { + if err := kubectlApplyFileOnCluster(workflow.YAMLFile, resourcesNamespace); err != nil { + return err + } + } + return nil +} + +func fetchImageTagsBuiltWorkflows(workflows map[string]*DeployedWorkflow) error { + ctx, cancel := context.WithTimeout(context.Background(), waitForBuildTimeout) + defer cancel() + + statusChan := make(chan error, len(workflows)) + for name, workflow := range workflows { + go func(w *DeployedWorkflow) { + ticker := time.NewTicker(10 * time.Second) + defer ticker.Stop() + + for { + select { + case <-ctx.Done(): + statusChan <- fmt.Errorf("timeout reached: workflow %s in namespace %s did not reach running state", name, resourcesNamespace) + return + case <-ticker.C: + if len(workflow.ImageTag) == 0 { + cmd := exec.Command("kubectl", "get", "sonataflowbuild", name, "-n", resourcesNamespace, "-o", "jsonpath={.status.imageTag}") + response, err := utils.Run(cmd) + if err != nil { + GinkgoWriter.Println(fmt.Errorf("failed to check the workflow image tag: %v", err)) + statusChan <- err + } + if len(response) > 0 { + GinkgoWriter.Printf("Got response: %s \n", response) + workflow.ImageTag = string(response) + statusChan <- nil + } + } + } + } + }(workflow) + } + + // Wait for all workflows to be in a running state or for errors to occur + for i := 0; i < len(workflows); i++ { + if err := <-statusChan; err != nil { + return err + } + } + + return nil +} + +func deployWorkflowsAndWaitForBuild(workflows map[string]*DeployedWorkflow) error { + if err := deployWorkflows(workflows); err != nil { + return err + } + if err := fetchImageTagsBuiltWorkflows(workflows); err != nil { + return err + } + return nil } diff --git a/test/e2e/helpers.go b/test/e2e/helpers.go index 83394d4f5..e6e2faca8 100644 --- a/test/e2e/helpers.go +++ b/test/e2e/helpers.go @@ -61,6 +61,55 @@ var ( upStatus string = "UP" ) +func kubectlApplyFileOnCluster(file, namespace string) error { + cmd := exec.Command("kubectl", "apply", "-f", file, "-n", namespace) + _, err := utils.Run(cmd) + return err +} + +func kubectlDeleteFileOnCluster(file, namespace string) error { + cmd := exec.Command("kubectl", "delete", "-f", file, "-n", namespace) + _, err := utils.Run(cmd) + return err +} + +func kubectlCreateNamespace(namespace string) error { + cmd := exec.Command("kubectl", "create", "namespace", namespace) + _, err := utils.Run(cmd) + return err +} + +func kubectlNamespaceExists(namespace string) (bool, error) { + cmd := exec.Command("kubectl", "get", "namespace", "-o", fmt.Sprintf(`jsonpath={.items[?(@.metadata.name=="%s")].metadata.name}`, namespace)) + output, err := utils.Run(cmd) + if err != nil { + return false, err + } + return len(output) > 0, nil +} + +func kubectlDeleteNamespace(namespace string) error { + cmd := exec.Command("kubectl", "delete", "namespace", namespace) + _, err := utils.Run(cmd) + return err +} + +func kubectlPatchSonataFlowImageAndRollout(namespace, workflowName, image string) error { + cmd := exec.Command("kubectl", "patch", "sonataflow", workflowName, + "--type", "json", "-n", namespace, + "-p", fmt.Sprintf(`[{"op": "replace", "path": "/spec/podTemplate/container/image", "value": "%s"}, {"op": "replace", "path": "/spec/podTemplate/replicas", "value": 1}]`, image)) + _, err := utils.Run(cmd) + return err +} + +func kubectlPatchSonataFlowScaleDown(namespace, workflowName string) error { + cmd := exec.Command("kubectl", "patch", "sonataflow", workflowName, + "--type", "json", "-n", namespace, + "-p", `[{"op": "replace", "path": "/spec/podTemplate/replicas", "value": 0}]`) + _, err := utils.Run(cmd) + return err +} + func getHealthFromPod(name, namespace string) (*health, error) { // iterate over all containers to find the one that responds to the HTTP health endpoint Expect(name).NotTo(BeEmpty(), "pod name is empty") @@ -127,7 +176,7 @@ func getHealthStatusInContainer(podName string, containerName string, ns string) return &h, nil } -func verifyWorkflowIsInRunningStateInNamespace(workflowName string, ns string) bool { +func verifyWorkflowIsInRunningState(workflowName string, ns string) bool { cmd := exec.Command("kubectl", "get", "workflow", workflowName, "-n", ns, "-o", "jsonpath={.status.conditions[?(@.type=='Running')].status}") response, err := utils.Run(cmd) if err != nil { @@ -148,10 +197,6 @@ func verifyWorkflowIsInRunningStateInNamespace(workflowName string, ns string) b return status } -func verifyWorkflowIsInRunningState(workflowName string, targetNamespace string) bool { - return verifyWorkflowIsInRunningStateInNamespace(workflowName, targetNamespace) -} - func verifyWorkflowIsAddressable(workflowName string, targetNamespace string) bool { cmd := exec.Command("kubectl", "get", "workflow", workflowName, "-n", targetNamespace, "-ojsonpath={.status.address.url}") if response, err := utils.Run(cmd); err != nil { @@ -193,35 +238,6 @@ func verifySchemaMigration(data, name string) bool { strings.Contains(data, fmt.Sprintf("Schema \"%s\" is up to date. No migration necessary", name))) } -func verifyKSinkInjection(label, ns string) bool { - cmd := exec.Command("kubectl", "get", "pod", "-n", ns, "-l", label, "-o", "jsonpath={.items[*].metadata.name}") - out, err := utils.Run(cmd) - if err != nil { - GinkgoWriter.Println(fmt.Errorf("failed to get pods: %v", err)) - return false - } - podNames := strings.Fields(string(out)) - if len(podNames) == 0 { - GinkgoWriter.Println("no pods found to check K_SINK") - return false // pods haven't created yet - } - GinkgoWriter.Println(fmt.Sprintf("pods found: %s", podNames)) - for _, pod := range podNames { - cmd = exec.Command("kubectl", "get", "pod", pod, "-n", ns, "-o", "json") - out, err := utils.Run(cmd) - if err != nil { - GinkgoWriter.Println(fmt.Errorf("failed to get pod: %v", err)) - return false - } - GinkgoWriter.Println(string(out)) - if !strings.Contains(string(out), "K_SINK") { // The pod does not have K_SINK injected - GinkgoWriter.Println(fmt.Sprintf("Pod does not have K_SINK injected: %s", string(out))) - return false - } - } - return true -} - func waitForPodRestartCompletion(label, ns string) { EventuallyWithOffset(1, func() bool { cmd := exec.Command("kubectl", "get", "pod", "-n", ns, "-l", label, "-o", "jsonpath={.items[*].metadata.name}") diff --git a/test/e2e/platform_test.go b/test/e2e/platform_test.go index d34e7cc79..6e75934db 100644 --- a/test/e2e/platform_test.go +++ b/test/e2e/platform_test.go @@ -76,13 +76,13 @@ var _ = Describe("Platform Use Cases :: ", Label("platform"), Ordered, func() { }) var _ = Context("with platform services", func() { - DescribeTable("when creating a simple workflow", func(testcaseDir string, profile string, persistenceType string) { + DescribeTable("when creating a simple workflow", func(testcaseDir string, profile metadata.ProfileType, persistenceType string) { By("Deploy the SonataFlowPlatform CR") var manifests []byte EventuallyWithOffset(1, func() error { var err error cmd := exec.Command("kubectl", "kustomize", filepath.Join(projectDir, - testcaseDir, profile, persistenceType)) + testcaseDir, profile.String(), persistenceType)) manifests, err = utils.Run(cmd) return err }, time.Minute, time.Second).Should(Succeed()) @@ -98,7 +98,7 @@ var _ = Describe("Platform Use Cases :: ", Label("platform"), Ordered, func() { if err != nil { return false } - if profile == metadata.PreviewProfile.String() { + if profile == metadata.GitOpsProfile { GinkgoWriter.Println("waitForPodRestartCompletion") waitForPodRestartCompletion("app.kubernetes.io/name=jobs-service", targetNamespace) GinkgoWriter.Println("waitForPodRestartCompletion done") @@ -116,7 +116,7 @@ var _ = Describe("Platform Use Cases :: ", Label("platform"), Ordered, func() { } By("Deploy the SonataFlow CR") cmd = exec.Command("kubectl", "create", "-n", targetNamespace, "-f", filepath.Join(projectDir, - testcaseDir, profile, persistenceType, "sonataflow")) + testcaseDir, profile.String(), persistenceType, "sonataflow")) manifests, err = utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) @@ -126,18 +126,29 @@ var _ = Describe("Platform Use Cases :: ", Label("platform"), Ordered, func() { Expect(err).NotTo(HaveOccurred()) sfNames := strings.TrimRight(string(output), " ") + if profile == metadata.GitOpsProfile { + workflowTag := prebuiltWorkflows.CallBack.Tag + if persistenceType == postgreSQL { + workflowTag = prebuiltWorkflows.CallBackPersistence.Tag + } + By("Replacing the image with a prebuilt one and rollout") + EventuallyWithOffset(1, func() error { + return kubectlPatchSonataFlowImageAndRollout(targetNamespace, sfNames, workflowTag) + }, 3*time.Minute, time.Second).Should(Succeed()) + } + By("Evaluate status of SonataFlow CR") - for _, sf := range strings.Split(string(sfNames), " ") { + for _, sf := range strings.Split(sfNames, " ") { Expect(sf).NotTo(BeEmpty(), "sonataflow name is empty") EventuallyWithOffset(1, func() bool { - return verifyWorkflowIsInRunningStateInNamespace(sf, targetNamespace) - }, 15*time.Minute, 1*time.Minute).Should(BeTrue()) + return verifyWorkflowIsInRunningState(sf, targetNamespace) + }, 10*time.Minute, 5*time.Second).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), - Entry("with both Job Service and Data Index and ephemeral persistence and the workflow in a preview profile", test.GetSonataFlowE2EPlatformServicesDirectory(), metadata.PreviewProfile.String(), ephemeral), - Entry("with both Job Service and Data Index and postgreSQL persistence and the workflow in a dev profile", test.GetSonataFlowE2EPlatformServicesDirectory(), metadata.DevProfile.String(), postgreSQL), - Entry("with both Job Service and Data Index and postgreSQL persistence and the workflow in a preview profile", test.GetSonataFlowE2EPlatformServicesDirectory(), metadata.PreviewProfile.String(), postgreSQL), + Entry("with both Job Service and Data Index and ephemeral persistence and the workflow in a dev profile", test.GetPathFromE2EDirectory("platform", "services"), metadata.DevProfile, ephemeral), + Entry("with both Job Service and Data Index and ephemeral persistence and the workflow in a gitops profile", test.GetPathFromE2EDirectory("platform", "services"), metadata.GitOpsProfile, ephemeral), + Entry("with both Job Service and Data Index and postgreSQL persistence and the workflow in a dev profile", test.GetPathFromE2EDirectory("platform", "services"), metadata.DevProfile, postgreSQL), + Entry("with both Job Service and Data Index and postgreSQL persistence and the workflow in a gitops profile", test.GetPathFromE2EDirectory("platform", "services"), metadata.GitOpsProfile, postgreSQL), ) }) @@ -170,8 +181,8 @@ var _ = Describe("Platform Use Cases :: ", Label("platform"), Ordered, func() { verifyHealthStatusInPod(pn, targetNamespace) } }, - Entry("and both Job Service and Data Index using the persistence from platform CR", test.GetSonataFlowE2EPlatformPersistenceSampleDataDirectory("generic_from_platform_cr")), - Entry("and both Job Service and Data Index using the one defined in each service, discarding the one from the platform CR", test.GetSonataFlowE2EPlatformPersistenceSampleDataDirectory("overwritten_by_services")), + Entry("and both Job Service and Data Index using the persistence from platform CR", test.GetPathFromE2EDirectory("platform", "persistence", "generic_from_platform_cr")), + Entry("and both Job Service and Data Index using the one defined in each service, discarding the one from the platform CR", test.GetPathFromE2EDirectory("platform", "persistence", "overwritten_by_services")), ) DescribeTable("when deploying a SonataFlowPlatform CR with brokers", func(testcaseDir string) { @@ -237,7 +248,7 @@ var _ = Describe("Platform Use Cases :: ", Label("platform"), Ordered, func() { Expect(verifyTrigger(triggers, "jobs-service-delete-job-", constants.JobServiceJobEventsPath, targetNamespace, "js-source")).NotTo(HaveOccurred()) Expect(verifySinkBinding("sonataflow-platform-jobs-service-sb", targetNamespace, "js-sink")).NotTo(HaveOccurred()) }, - Entry("and both Job Service and Data Index have service level brokers", test.GetSonataFlowE2EPlatformServicesKnativeDirectory("service-level-broker")), + Entry("and both Job Service and Data Index have service level brokers", test.GetPathFromE2EDirectory("platform", "services", "gitops", "knative", "service-level-broker")), ) DescribeTable("when deploying a SonataFlowPlatform CR with platform broker", func(testcaseDir string, brokerInAnotherNamespace bool) { @@ -317,22 +328,26 @@ var _ = Describe("Platform Use Cases :: ", Label("platform"), Ordered, func() { manifests, err = utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) - sfName := "callbackstatetimeouts" + By("Replacing the image with a prebuilt one and rollout") + EventuallyWithOffset(1, func() error { + return kubectlPatchSonataFlowImageAndRollout(targetNamespace, prebuiltWorkflows.CallBack.Name, prebuiltWorkflows.CallBack.Tag) + }, 3*time.Minute, time.Second).Should(Succeed()) + By("Evaluate status of SonataFlow CR") EventuallyWithOffset(1, func() bool { - return verifyWorkflowIsInRunningStateInNamespace(sfName, targetNamespace) - }, 10*time.Minute, 5).Should(BeTrue()) + return verifyWorkflowIsInRunningState(prebuiltWorkflows.CallBack.Name, targetNamespace) + }, 5*time.Minute, 5).Should(BeTrue()) By("Evaluate triggers and sinkbindings for the workflow") - cmd = exec.Command("kubectl", "get", "sonataflow", sfName, "-n", targetNamespace, "-ojsonpath={.status.triggers}") + cmd = exec.Command("kubectl", "get", "sonataflow", prebuiltWorkflows.CallBack.Name, "-n", targetNamespace, "-ojsonpath={.status.triggers}") output, err = utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) err = json.Unmarshal(output, &triggers) Expect(err).NotTo(HaveOccurred()) - Expect(verifyTrigger(triggers, sfName, "", brokerNamespace, brokerName)).NotTo(HaveOccurred()) - Expect(verifySinkBinding(fmt.Sprintf("%s-sb", sfName), targetNamespace, brokerName)).NotTo(HaveOccurred()) + Expect(verifyTrigger(triggers, prebuiltWorkflows.CallBack.Name, "", brokerNamespace, brokerName)).NotTo(HaveOccurred()) + Expect(verifySinkBinding(fmt.Sprintf("%s-sb", prebuiltWorkflows.CallBack.Name), targetNamespace, brokerName)).NotTo(HaveOccurred()) }, - Entry("and with broker and platform in the same namespace", test.GetSonataFlowE2EPlatformServicesKnativeDirectory("platform-level-broker"), false), - Entry("and with broker and platform in a separate namespace", test.GetSonataFlowE2EPlatformServicesKnativeDirectory("platform-level-broker"), true), + Entry("and with broker and platform in the same namespace", test.GetPathFromE2EDirectory("platform", "services", "gitops", "knative", "platform-level-broker"), false), + Entry("and with broker and platform in a separate namespace", test.GetPathFromE2EDirectory("platform", "services", "gitops", "knative", "platform-level-broker"), true), ) }) diff --git a/test/e2e/testdata/before-suite/sonataflow.org_v1alpha08_sonataflow-callbackstatetimeouts-persistence.yaml b/test/e2e/testdata/before-suite/sonataflow.org_v1alpha08_sonataflow-callbackstatetimeouts-persistence.yaml new file mode 100644 index 000000000..0bf25971d --- /dev/null +++ b/test/e2e/testdata/before-suite/sonataflow.org_v1alpha08_sonataflow-callbackstatetimeouts-persistence.yaml @@ -0,0 +1,95 @@ +# Copyright 2024 Apache Software Foundation (ASF) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: sonataflow.org/v1alpha08 +kind: SonataFlow +metadata: + name: callbackstatetimeouts-persistence + annotations: + sonataflow.org/description: Callback State Timeouts Example k8s + sonataflow.org/version: 0.0.1 + sonataflow.org/profile: preview +spec: + podTemplate: + replicas: 0 + # We need the persistence entry to build this image with the right extensions + persistence: + postgresql: + secretRef: + name: postgres-secrets + userKey: POSTGRES_USER + passwordKey: POSTGRES_PASSWORD + serviceRef: + name: postgres + port: 5432 + databaseName: sonataflow + databaseSchema: callbackstatetimeouts-persistence + flow: + start: PrintStartMessage + events: + - name: callbackEvent + source: '' + type: callback_event_type + functions: + - name: systemOut + type: custom + operation: sysout + states: + - name: PrintStartMessage + type: operation + actions: + - name: printSystemOut + functionRef: + refName: systemOut + arguments: + message: "${\"callback-state-timeouts: \" + $WORKFLOW.instanceId + \" has started.\"}" + transition: CallbackState + - name: CallbackState + type: callback + action: + name: callbackAction + functionRef: + refName: systemOut + arguments: + message: "${\"callback-state-timeouts: \" + $WORKFLOW.instanceId + \" has executed the callbackFunction.\"}" + eventRef: callbackEvent + transition: CheckEventArrival + timeouts: + eventTimeout: PT30S + - name: CheckEventArrival + type: switch + dataConditions: + - condition: "${ .eventData != null }" + transition: EventArrived + defaultCondition: + transition: EventNotArrived + - name: EventArrived + type: inject + data: + exitMessage: "The callback event has arrived." + transition: PrintExitMessage + - name: EventNotArrived + type: inject + data: + exitMessage: "The callback event has not arrived, and the timeout has overdue." + transition: PrintExitMessage + - name: PrintExitMessage + type: operation + actions: + - name: printSystemOut + functionRef: + refName: systemOut + arguments: + message: "${\"callback-state-timeouts: \" + $WORKFLOW.instanceId + \" has finalized. \" + .exitMessage + \" eventData: \" + .eventData}" + end: true diff --git a/test/testdata/platform/services/preview/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/before-suite/sonataflow.org_v1alpha08_sonataflow-callbackstatetimeouts.yaml similarity index 98% rename from test/testdata/platform/services/preview/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/before-suite/sonataflow.org_v1alpha08_sonataflow-callbackstatetimeouts.yaml index a76ac23fb..35fc887f3 100644 --- a/test/testdata/platform/services/preview/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml +++ b/test/e2e/testdata/before-suite/sonataflow.org_v1alpha08_sonataflow-callbackstatetimeouts.yaml @@ -21,6 +21,8 @@ metadata: sonataflow.org/version: 0.0.1 sonataflow.org/profile: preview spec: + podTemplate: + replicas: 0 flow: start: PrintStartMessage events: diff --git a/test/e2e/testdata/before-suite/sonataflow.org_v1alpha08_sonataflow-greetings.yaml b/test/e2e/testdata/before-suite/sonataflow.org_v1alpha08_sonataflow-greetings.yaml new file mode 100644 index 000000000..417963fca --- /dev/null +++ b/test/e2e/testdata/before-suite/sonataflow.org_v1alpha08_sonataflow-greetings.yaml @@ -0,0 +1,35 @@ +# Copyright 2023 Red Hat, Inc. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: sonataflow.org/v1alpha08 +kind: SonataFlow +metadata: + name: greetings + annotations: + sonataflow.org/description: Greetings example on k8s! + sonataflow.org/version: 0.0.1 + sonataflow.org/profile: preview + labels: + test: test +spec: + podTemplate: + replicas: 0 + flow: + start: HelloWorld + states: + - name: HelloWorld + type: inject + data: + message: Hello World + end: true diff --git a/test/testdata/order-processing/01_v1_configmap_subflows.yaml b/test/e2e/testdata/order-processing/01_v1_configmap_subflows.yaml similarity index 100% rename from test/testdata/order-processing/01_v1_configmap_subflows.yaml rename to test/e2e/testdata/order-processing/01_v1_configmap_subflows.yaml diff --git a/test/testdata/order-processing/02_appsv1_deployment_eventlistener.yaml b/test/e2e/testdata/order-processing/02_appsv1_deployment_eventlistener.yaml similarity index 100% rename from test/testdata/order-processing/02_appsv1_deployment_eventlistener.yaml rename to test/e2e/testdata/order-processing/02_appsv1_deployment_eventlistener.yaml diff --git a/test/testdata/order-processing/03_discovery_role.yaml b/test/e2e/testdata/order-processing/03_discovery_role.yaml similarity index 100% rename from test/testdata/order-processing/03_discovery_role.yaml rename to test/e2e/testdata/order-processing/03_discovery_role.yaml diff --git a/test/testdata/order-processing/04_v1_configmap_properties.yaml b/test/e2e/testdata/order-processing/04_v1_configmap_properties.yaml similarity index 100% rename from test/testdata/order-processing/04_v1_configmap_properties.yaml rename to test/e2e/testdata/order-processing/04_v1_configmap_properties.yaml diff --git a/test/testdata/order-processing/05_sonataflow.org_v1alpha08_sonataflow_devmode_orderprocessing.yaml b/test/e2e/testdata/order-processing/05_sonataflow.org_v1alpha08_sonataflow_devmode_orderprocessing.yaml similarity index 100% rename from test/testdata/order-processing/05_sonataflow.org_v1alpha08_sonataflow_devmode_orderprocessing.yaml rename to test/e2e/testdata/order-processing/05_sonataflow.org_v1alpha08_sonataflow_devmode_orderprocessing.yaml diff --git a/test/testdata/order-processing/README.md b/test/e2e/testdata/order-processing/README.md similarity index 100% rename from test/testdata/order-processing/README.md rename to test/e2e/testdata/order-processing/README.md diff --git a/test/testdata/platform/services/preview/ephemeral-with-workflow/00-broker.yaml b/test/e2e/testdata/platform/noservices/gitops/ephemeral/00-broker.yaml similarity index 100% rename from test/testdata/platform/services/preview/ephemeral-with-workflow/00-broker.yaml rename to test/e2e/testdata/platform/noservices/gitops/ephemeral/00-broker.yaml diff --git a/test/testdata/platform/noservices/preview/ephemeral/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/noservices/gitops/ephemeral/02-sonataflow_platform.yaml similarity index 88% rename from test/testdata/platform/noservices/preview/ephemeral/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/noservices/gitops/ephemeral/02-sonataflow_platform.yaml index 07f94ba3f..f004aea75 100644 --- a/test/testdata/platform/noservices/preview/ephemeral/02-sonataflow_platform.yaml +++ b/test/e2e/testdata/platform/noservices/gitops/ephemeral/02-sonataflow_platform.yaml @@ -17,6 +17,12 @@ kind: SonataFlowPlatform metadata: name: sonataflow-platform spec: + eventing: + broker: + ref: + apiVersion: eventing.knative.dev/v1 + kind: Broker + name: default build: template: buildArgs: diff --git a/test/testdata/platform/services/preview/ephemeral-with-workflow/kustomization.yaml b/test/e2e/testdata/platform/noservices/gitops/ephemeral/kustomization.yaml similarity index 91% rename from test/testdata/platform/services/preview/ephemeral-with-workflow/kustomization.yaml rename to test/e2e/testdata/platform/noservices/gitops/ephemeral/kustomization.yaml index a3a9c95f9..9d2b6d49f 100644 --- a/test/testdata/platform/services/preview/ephemeral-with-workflow/kustomization.yaml +++ b/test/e2e/testdata/platform/noservices/gitops/ephemeral/kustomization.yaml @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + resources: - 00-broker.yaml - 02-sonataflow_platform.yaml diff --git a/test/testdata/platform/services/preview/ephemeral-with-workflow/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/platform/noservices/gitops/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml similarity index 96% rename from test/testdata/platform/services/preview/ephemeral-with-workflow/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/platform/noservices/gitops/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml index 249ee2c12..5eb6e23ca 100644 --- a/test/testdata/platform/services/preview/ephemeral-with-workflow/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml +++ b/test/e2e/testdata/platform/noservices/gitops/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml @@ -19,8 +19,12 @@ metadata: annotations: sonataflow.org/description: Callback State Timeouts Example k8s sonataflow.org/version: 0.0.1 - sonataflow.org/profile: prod + sonataflow.org/profile: gitops spec: + podTemplate: + replicas: 0 + container: + image: replaceme flow: start: PrintStartMessage events: diff --git a/test/testdata/platform/persistence/generic_from_platform_cr/01-postgres.yaml b/test/e2e/testdata/platform/persistence/generic_from_platform_cr/01-postgres.yaml similarity index 100% rename from test/testdata/platform/persistence/generic_from_platform_cr/01-postgres.yaml rename to test/e2e/testdata/platform/persistence/generic_from_platform_cr/01-postgres.yaml diff --git a/test/testdata/platform/persistence/generic_from_platform_cr/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/persistence/generic_from_platform_cr/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/platform/persistence/generic_from_platform_cr/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/persistence/generic_from_platform_cr/02-sonataflow_platform.yaml diff --git a/test/testdata/platform/persistence/generic_from_platform_cr/kustomization.yaml b/test/e2e/testdata/platform/persistence/generic_from_platform_cr/kustomization.yaml similarity index 100% rename from test/testdata/platform/persistence/generic_from_platform_cr/kustomization.yaml rename to test/e2e/testdata/platform/persistence/generic_from_platform_cr/kustomization.yaml diff --git a/test/testdata/platform/persistence/overwritten_by_services/01-postgres.yaml b/test/e2e/testdata/platform/persistence/overwritten_by_services/01-postgres.yaml similarity index 100% rename from test/testdata/platform/persistence/overwritten_by_services/01-postgres.yaml rename to test/e2e/testdata/platform/persistence/overwritten_by_services/01-postgres.yaml diff --git a/test/testdata/platform/persistence/overwritten_by_services/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/persistence/overwritten_by_services/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/platform/persistence/overwritten_by_services/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/persistence/overwritten_by_services/02-sonataflow_platform.yaml diff --git a/test/testdata/platform/persistence/overwritten_by_services/kustomization.yaml b/test/e2e/testdata/platform/persistence/overwritten_by_services/kustomization.yaml similarity index 100% rename from test/testdata/platform/persistence/overwritten_by_services/kustomization.yaml rename to test/e2e/testdata/platform/persistence/overwritten_by_services/kustomization.yaml diff --git a/test/testdata/platform/services/dev/ephemeral/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/services/dev/ephemeral/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/platform/services/dev/ephemeral/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/services/dev/ephemeral/02-sonataflow_platform.yaml diff --git a/test/testdata/platform/services/dev/ephemeral/kustomization.yaml b/test/e2e/testdata/platform/services/dev/ephemeral/kustomization.yaml similarity index 100% rename from test/testdata/platform/services/dev/ephemeral/kustomization.yaml rename to test/e2e/testdata/platform/services/dev/ephemeral/kustomization.yaml diff --git a/test/testdata/platform/services/dev/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/platform/services/dev/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml similarity index 100% rename from test/testdata/platform/services/dev/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/platform/services/dev/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml diff --git a/test/testdata/platform/services/dev/postgreSQL/01-postgres.yaml b/test/e2e/testdata/platform/services/dev/postgreSQL/01-postgres.yaml similarity index 100% rename from test/testdata/platform/services/dev/postgreSQL/01-postgres.yaml rename to test/e2e/testdata/platform/services/dev/postgreSQL/01-postgres.yaml diff --git a/test/testdata/platform/services/dev/postgreSQL/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/services/dev/postgreSQL/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/platform/services/dev/postgreSQL/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/services/dev/postgreSQL/02-sonataflow_platform.yaml diff --git a/test/testdata/platform/services/dev/postgreSQL/kustomization.yaml b/test/e2e/testdata/platform/services/dev/postgreSQL/kustomization.yaml similarity index 100% rename from test/testdata/platform/services/dev/postgreSQL/kustomization.yaml rename to test/e2e/testdata/platform/services/dev/postgreSQL/kustomization.yaml diff --git a/test/testdata/platform/services/dev/postgreSQL/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/platform/services/dev/postgreSQL/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml similarity index 100% rename from test/testdata/platform/services/dev/postgreSQL/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/platform/services/dev/postgreSQL/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml diff --git a/test/testdata/platform/services/preview/cluster-wide-ephemeral/01-sonataflow_clusterplatform.yaml b/test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/01-sonataflow_clusterplatform.yaml similarity index 100% rename from test/testdata/platform/services/preview/cluster-wide-ephemeral/01-sonataflow_clusterplatform.yaml rename to test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/01-sonataflow_clusterplatform.yaml diff --git a/test/testdata/platform/services/preview/cluster-wide-ephemeral/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/platform/services/preview/cluster-wide-ephemeral/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/02-sonataflow_platform.yaml diff --git a/test/testdata/platform/services/preview/cluster-wide-ephemeral/kustomization.yaml b/test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/kustomization.yaml similarity index 100% rename from test/testdata/platform/services/preview/cluster-wide-ephemeral/kustomization.yaml rename to test/e2e/testdata/platform/services/gitops/cluster-wide-ephemeral/kustomization.yaml diff --git a/test/testdata/platform/services/preview/ephemeral-data-index/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/platform/services/preview/ephemeral-data-index/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral-data-index/02-sonataflow_platform.yaml diff --git a/test/testdata/platform/services/preview/ephemeral-job-service/kustomization.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/kustomization.yaml similarity index 91% rename from test/testdata/platform/services/preview/ephemeral-job-service/kustomization.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral-data-index/kustomization.yaml index 20286ada0..dddcd9ea0 100644 --- a/test/testdata/platform/services/preview/ephemeral-job-service/kustomization.yaml +++ b/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/kustomization.yaml @@ -12,10 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + resources: - 02-sonataflow_platform.yaml - sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml sortOptions: order: fifo - diff --git a/test/testdata/platform/services/preview/ephemeral-data-index/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml similarity index 96% rename from test/testdata/platform/services/preview/ephemeral-data-index/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral-data-index/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml index 249ee2c12..5eb6e23ca 100644 --- a/test/testdata/platform/services/preview/ephemeral-data-index/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml +++ b/test/e2e/testdata/platform/services/gitops/ephemeral-data-index/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml @@ -19,8 +19,12 @@ metadata: annotations: sonataflow.org/description: Callback State Timeouts Example k8s sonataflow.org/version: 0.0.1 - sonataflow.org/profile: prod + sonataflow.org/profile: gitops spec: + podTemplate: + replicas: 0 + container: + image: replaceme flow: start: PrintStartMessage events: diff --git a/test/testdata/platform/services/preview/ephemeral-job-service/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/platform/services/preview/ephemeral-job-service/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral-job-service/02-sonataflow_platform.yaml diff --git a/test/testdata/platform/noservices/preview/ephemeral/kustomization.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/kustomization.yaml similarity index 91% rename from test/testdata/platform/noservices/preview/ephemeral/kustomization.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral-job-service/kustomization.yaml index 20286ada0..c17b7dd4d 100644 --- a/test/testdata/platform/noservices/preview/ephemeral/kustomization.yaml +++ b/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/kustomization.yaml @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + resources: - 02-sonataflow_platform.yaml - sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml diff --git a/test/testdata/platform/services/preview/ephemeral-job-service/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml similarity index 96% rename from test/testdata/platform/services/preview/ephemeral-job-service/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral-job-service/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml index 249ee2c12..5eb6e23ca 100644 --- a/test/testdata/platform/services/preview/ephemeral-job-service/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml +++ b/test/e2e/testdata/platform/services/gitops/ephemeral-job-service/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml @@ -19,8 +19,12 @@ metadata: annotations: sonataflow.org/description: Callback State Timeouts Example k8s sonataflow.org/version: 0.0.1 - sonataflow.org/profile: prod + sonataflow.org/profile: gitops spec: + podTemplate: + replicas: 0 + container: + image: replaceme flow: start: PrintStartMessage events: diff --git a/test/testdata/platform/services/preview/ephemeral/00-broker.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral-with-workflow/00-broker.yaml similarity index 100% rename from test/testdata/platform/services/preview/ephemeral/00-broker.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral-with-workflow/00-broker.yaml diff --git a/test/testdata/platform/services/preview/ephemeral-with-workflow/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral-with-workflow/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/platform/services/preview/ephemeral-with-workflow/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral-with-workflow/02-sonataflow_platform.yaml diff --git a/test/testdata/platform/services/preview/ephemeral-data-index/kustomization.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral-with-workflow/kustomization.yaml similarity index 89% rename from test/testdata/platform/services/preview/ephemeral-data-index/kustomization.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral-with-workflow/kustomization.yaml index a6807fcf5..9d2b6d49f 100644 --- a/test/testdata/platform/services/preview/ephemeral-data-index/kustomization.yaml +++ b/test/e2e/testdata/platform/services/gitops/ephemeral-with-workflow/kustomization.yaml @@ -12,9 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + resources: +- 00-broker.yaml - 02-sonataflow_platform.yaml - sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml sortOptions: order: fifo + diff --git a/test/testdata/platform/noservices/preview/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral-with-workflow/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml similarity index 96% rename from test/testdata/platform/noservices/preview/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral-with-workflow/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml index a76ac23fb..5eb6e23ca 100644 --- a/test/testdata/platform/noservices/preview/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml +++ b/test/e2e/testdata/platform/services/gitops/ephemeral-with-workflow/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml @@ -19,8 +19,12 @@ metadata: annotations: sonataflow.org/description: Callback State Timeouts Example k8s sonataflow.org/version: 0.0.1 - sonataflow.org/profile: preview + sonataflow.org/profile: gitops spec: + podTemplate: + replicas: 0 + container: + image: replaceme flow: start: PrintStartMessage events: diff --git a/test/testdata/platform/services/preview/postgreSQL/00-broker.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral/00-broker.yaml similarity index 100% rename from test/testdata/platform/services/preview/postgreSQL/00-broker.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral/00-broker.yaml diff --git a/test/testdata/platform/services/preview/ephemeral/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/platform/services/preview/ephemeral/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral/02-sonataflow_platform.yaml diff --git a/test/testdata/platform/services/preview/ephemeral/kustomization.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral/kustomization.yaml similarity index 91% rename from test/testdata/platform/services/preview/ephemeral/kustomization.yaml rename to test/e2e/testdata/platform/services/gitops/ephemeral/kustomization.yaml index bb1fcd0e2..d890becb9 100644 --- a/test/testdata/platform/services/preview/ephemeral/kustomization.yaml +++ b/test/e2e/testdata/platform/services/gitops/ephemeral/kustomization.yaml @@ -11,6 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization resources: - 00-broker.yaml diff --git a/test/e2e/testdata/platform/services/gitops/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/platform/services/gitops/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml new file mode 100644 index 000000000..5eb6e23ca --- /dev/null +++ b/test/e2e/testdata/platform/services/gitops/ephemeral/sonataflow/03-sonataflow_callbackstatetimeouts.sw.yaml @@ -0,0 +1,85 @@ +# Copyright 2024 Apache Software Foundation (ASF) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: sonataflow.org/v1alpha08 +kind: SonataFlow +metadata: + name: callbackstatetimeouts + annotations: + sonataflow.org/description: Callback State Timeouts Example k8s + sonataflow.org/version: 0.0.1 + sonataflow.org/profile: gitops +spec: + podTemplate: + replicas: 0 + container: + image: replaceme + flow: + start: PrintStartMessage + events: + - name: callbackEvent + source: '' + type: callback_event_type + functions: + - name: systemOut + type: custom + operation: sysout + states: + - name: PrintStartMessage + type: operation + actions: + - name: printSystemOut + functionRef: + refName: systemOut + arguments: + message: "${\"callback-state-timeouts: \" + $WORKFLOW.instanceId + \" has started.\"}" + transition: CallbackState + - name: CallbackState + type: callback + action: + name: callbackAction + functionRef: + refName: systemOut + arguments: + message: "${\"callback-state-timeouts: \" + $WORKFLOW.instanceId + \" has executed the callbackFunction.\"}" + eventRef: callbackEvent + transition: CheckEventArrival + timeouts: + eventTimeout: PT30S + - name: CheckEventArrival + type: switch + dataConditions: + - condition: "${ .eventData != null }" + transition: EventArrived + defaultCondition: + transition: EventNotArrived + - name: EventArrived + type: inject + data: + exitMessage: "The callback event has arrived." + transition: PrintExitMessage + - name: EventNotArrived + type: inject + data: + exitMessage: "The callback event has not arrived, and the timeout has overdue." + transition: PrintExitMessage + - name: PrintExitMessage + type: operation + actions: + - name: printSystemOut + functionRef: + refName: systemOut + arguments: + message: "${\"callback-state-timeouts: \" + $WORKFLOW.instanceId + \" has finalized. \" + .exitMessage + \" eventData: \" + .eventData}" + end: true diff --git a/test/testdata/platform/services/preview/knative/platform-level-broker/01-postgres.yaml b/test/e2e/testdata/platform/services/gitops/knative/platform-level-broker/01-postgres.yaml similarity index 100% rename from test/testdata/platform/services/preview/knative/platform-level-broker/01-postgres.yaml rename to test/e2e/testdata/platform/services/gitops/knative/platform-level-broker/01-postgres.yaml diff --git a/test/testdata/platform/services/preview/knative/platform-level-broker/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/services/gitops/knative/platform-level-broker/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/platform/services/preview/knative/platform-level-broker/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/services/gitops/knative/platform-level-broker/02-sonataflow_platform.yaml diff --git a/test/testdata/platform/services/preview/knative/platform-level-broker/broker/broker.yaml b/test/e2e/testdata/platform/services/gitops/knative/platform-level-broker/broker/broker.yaml similarity index 100% rename from test/testdata/platform/services/preview/knative/platform-level-broker/broker/broker.yaml rename to test/e2e/testdata/platform/services/gitops/knative/platform-level-broker/broker/broker.yaml diff --git a/test/testdata/platform/services/preview/knative/platform-level-broker/kustomization.yaml b/test/e2e/testdata/platform/services/gitops/knative/platform-level-broker/kustomization.yaml similarity index 93% rename from test/testdata/platform/services/preview/knative/platform-level-broker/kustomization.yaml rename to test/e2e/testdata/platform/services/gitops/knative/platform-level-broker/kustomization.yaml index d3fd127c7..75c71d159 100644 --- a/test/testdata/platform/services/preview/knative/platform-level-broker/kustomization.yaml +++ b/test/e2e/testdata/platform/services/gitops/knative/platform-level-broker/kustomization.yaml @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + resources: - 01-postgres.yaml - 02-sonataflow_platform.yaml @@ -29,4 +32,3 @@ secretGenerator: sortOptions: order: fifo - diff --git a/test/testdata/platform/services/preview/knative/platform-level-broker/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/platform/services/gitops/knative/platform-level-broker/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml similarity index 96% rename from test/testdata/platform/services/preview/knative/platform-level-broker/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/platform/services/gitops/knative/platform-level-broker/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml index a76ac23fb..5eb6e23ca 100644 --- a/test/testdata/platform/services/preview/knative/platform-level-broker/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml +++ b/test/e2e/testdata/platform/services/gitops/knative/platform-level-broker/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml @@ -19,8 +19,12 @@ metadata: annotations: sonataflow.org/description: Callback State Timeouts Example k8s sonataflow.org/version: 0.0.1 - sonataflow.org/profile: preview + sonataflow.org/profile: gitops spec: + podTemplate: + replicas: 0 + container: + image: replaceme flow: start: PrintStartMessage events: diff --git a/test/testdata/platform/services/preview/knative/service-level-broker/01-postgres.yaml b/test/e2e/testdata/platform/services/gitops/knative/service-level-broker/01-postgres.yaml similarity index 100% rename from test/testdata/platform/services/preview/knative/service-level-broker/01-postgres.yaml rename to test/e2e/testdata/platform/services/gitops/knative/service-level-broker/01-postgres.yaml diff --git a/test/testdata/platform/services/preview/knative/service-level-broker/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/services/gitops/knative/service-level-broker/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/platform/services/preview/knative/service-level-broker/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/services/gitops/knative/service-level-broker/02-sonataflow_platform.yaml diff --git a/test/testdata/platform/services/preview/knative/service-level-broker/broker/00-broker.yaml b/test/e2e/testdata/platform/services/gitops/knative/service-level-broker/broker/00-broker.yaml similarity index 100% rename from test/testdata/platform/services/preview/knative/service-level-broker/broker/00-broker.yaml rename to test/e2e/testdata/platform/services/gitops/knative/service-level-broker/broker/00-broker.yaml diff --git a/test/testdata/platform/services/preview/knative/service-level-broker/kustomization.yaml b/test/e2e/testdata/platform/services/gitops/knative/service-level-broker/kustomization.yaml similarity index 93% rename from test/testdata/platform/services/preview/knative/service-level-broker/kustomization.yaml rename to test/e2e/testdata/platform/services/gitops/knative/service-level-broker/kustomization.yaml index d3fd127c7..803d201c8 100644 --- a/test/testdata/platform/services/preview/knative/service-level-broker/kustomization.yaml +++ b/test/e2e/testdata/platform/services/gitops/knative/service-level-broker/kustomization.yaml @@ -11,6 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization resources: - 01-postgres.yaml diff --git a/test/testdata/workflow/persistence/from_platform_with_di_and_js_services/00-broker.yaml b/test/e2e/testdata/platform/services/gitops/postgreSQL/00-broker.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_with_di_and_js_services/00-broker.yaml rename to test/e2e/testdata/platform/services/gitops/postgreSQL/00-broker.yaml diff --git a/test/testdata/platform/services/preview/postgreSQL/01-postgres.yaml b/test/e2e/testdata/platform/services/gitops/postgreSQL/01-postgres.yaml similarity index 100% rename from test/testdata/platform/services/preview/postgreSQL/01-postgres.yaml rename to test/e2e/testdata/platform/services/gitops/postgreSQL/01-postgres.yaml diff --git a/test/testdata/platform/services/preview/postgreSQL/02-sonataflow_platform.yaml b/test/e2e/testdata/platform/services/gitops/postgreSQL/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/platform/services/preview/postgreSQL/02-sonataflow_platform.yaml rename to test/e2e/testdata/platform/services/gitops/postgreSQL/02-sonataflow_platform.yaml diff --git a/test/testdata/platform/services/preview/postgreSQL/kustomization.yaml b/test/e2e/testdata/platform/services/gitops/postgreSQL/kustomization.yaml similarity index 93% rename from test/testdata/platform/services/preview/postgreSQL/kustomization.yaml rename to test/e2e/testdata/platform/services/gitops/postgreSQL/kustomization.yaml index cb33c50ae..6f0c7bec9 100644 --- a/test/testdata/platform/services/preview/postgreSQL/kustomization.yaml +++ b/test/e2e/testdata/platform/services/gitops/postgreSQL/kustomization.yaml @@ -11,6 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization resources: - 00-broker.yaml @@ -30,4 +32,3 @@ secretGenerator: sortOptions: order: fifo - diff --git a/test/testdata/platform/services/preview/postgreSQL/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/platform/services/gitops/postgreSQL/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml similarity index 94% rename from test/testdata/platform/services/preview/postgreSQL/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/platform/services/gitops/postgreSQL/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml index a76ac23fb..a2de416a0 100644 --- a/test/testdata/platform/services/preview/postgreSQL/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml +++ b/test/e2e/testdata/platform/services/gitops/postgreSQL/sonataflow/04-sonataflow_callbackstatetimeouts.sw.yaml @@ -15,12 +15,16 @@ apiVersion: sonataflow.org/v1alpha08 kind: SonataFlow metadata: - name: callbackstatetimeouts + name: callbackstatetimeouts-persistence annotations: sonataflow.org/description: Callback State Timeouts Example k8s sonataflow.org/version: 0.0.1 - sonataflow.org/profile: preview + sonataflow.org/profile: gitops spec: + podTemplate: + replicas: 0 + container: + image: replaceme flow: start: PrintStartMessage events: diff --git a/test/e2e/testdata/workflows/greetings/01-sonataflow.org_v1alpha08_sonataflow.yaml b/test/e2e/testdata/workflows/greetings/01-sonataflow.org_v1alpha08_sonataflow.yaml new file mode 100644 index 000000000..31c5096d0 --- /dev/null +++ b/test/e2e/testdata/workflows/greetings/01-sonataflow.org_v1alpha08_sonataflow.yaml @@ -0,0 +1,37 @@ +# Copyright 2023 Red Hat, Inc. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: sonataflow.org/v1alpha08 +kind: SonataFlow +metadata: + name: greetings + annotations: + sonataflow.org/description: Greetings example on k8s! + sonataflow.org/version: 0.0.1 + sonataflow.org/profile: gitops + labels: + test: test +spec: + podTemplate: + replicas: 0 + container: + image: replaceme + flow: + start: HelloWorld + states: + - name: HelloWorld + type: inject + data: + message: Hello World + end: true diff --git a/test/testdata/workflow/persistence/by_service/01-postgres.yaml b/test/e2e/testdata/workflows/persistence/by_service/01-postgres.yaml similarity index 100% rename from test/testdata/workflow/persistence/by_service/01-postgres.yaml rename to test/e2e/testdata/workflows/persistence/by_service/01-postgres.yaml diff --git a/test/testdata/workflow/persistence/by_service/02-sonataflow_platform.yaml b/test/e2e/testdata/workflows/persistence/by_service/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/workflow/persistence/by_service/02-sonataflow_platform.yaml rename to test/e2e/testdata/workflows/persistence/by_service/02-sonataflow_platform.yaml diff --git a/test/testdata/workflow/persistence/by_service/03-configmap_callbackstatetimeouts-props.yaml b/test/e2e/testdata/workflows/persistence/by_service/03-configmap_callbackstatetimeouts-props.yaml similarity index 89% rename from test/testdata/workflow/persistence/by_service/03-configmap_callbackstatetimeouts-props.yaml rename to test/e2e/testdata/workflows/persistence/by_service/03-configmap_callbackstatetimeouts-props.yaml index 85d3ac6ac..358fda63d 100644 --- a/test/testdata/workflow/persistence/by_service/03-configmap_callbackstatetimeouts-props.yaml +++ b/test/e2e/testdata/workflows/persistence/by_service/03-configmap_callbackstatetimeouts-props.yaml @@ -20,5 +20,5 @@ data: kind: ConfigMap metadata: labels: - app: callbackstatetimeouts - name: callbackstatetimeouts-props + app: callbackstatetimeouts-persistence + name: callbackstatetimeouts-persistence-props diff --git a/test/testdata/workflow/persistence/by_service/04-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/workflows/persistence/by_service/04-sonataflow_callbackstatetimeouts.sw.yaml similarity index 94% rename from test/testdata/workflow/persistence/by_service/04-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/workflows/persistence/by_service/04-sonataflow_callbackstatetimeouts.sw.yaml index ec738e946..528be97cf 100644 --- a/test/testdata/workflow/persistence/by_service/04-sonataflow_callbackstatetimeouts.sw.yaml +++ b/test/e2e/testdata/workflows/persistence/by_service/04-sonataflow_callbackstatetimeouts.sw.yaml @@ -15,10 +15,11 @@ apiVersion: sonataflow.org/v1alpha08 kind: SonataFlow metadata: - name: callbackstatetimeouts + name: callbackstatetimeouts-persistence annotations: sonataflow.org/description: Callback State Timeouts Example k8s sonataflow.org/version: 0.0.1 + sonataflow.org/profile: gitops spec: persistence: postgresql: @@ -30,8 +31,11 @@ spec: name: postgres port: 5432 databaseName: sonataflow - databaseSchema: callbackstatetimeouts + databaseSchema: callbackstatetimeouts-persistence podTemplate: + container: + image: replaceme + replicas: 0 initContainers: - name: init-postgres image: registry.access.redhat.com/ubi9/ubi-micro:latest diff --git a/test/testdata/workflow/persistence/by_service/kustomization.yaml b/test/e2e/testdata/workflows/persistence/by_service/kustomization.yaml similarity index 100% rename from test/testdata/workflow/persistence/by_service/kustomization.yaml rename to test/e2e/testdata/workflows/persistence/by_service/kustomization.yaml diff --git a/test/testdata/workflow/persistence/from_platform_overwritten_by_service/01-postgres.yaml b/test/e2e/testdata/workflows/persistence/from_platform_overwritten_by_service/01-postgres.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_overwritten_by_service/01-postgres.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_overwritten_by_service/01-postgres.yaml diff --git a/test/testdata/workflow/persistence/from_platform_overwritten_by_service/02-sonataflow_platform.yaml b/test/e2e/testdata/workflows/persistence/from_platform_overwritten_by_service/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_overwritten_by_service/02-sonataflow_platform.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_overwritten_by_service/02-sonataflow_platform.yaml diff --git a/test/testdata/workflow/persistence/from_platform_overwritten_by_service/03-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/workflows/persistence/from_platform_overwritten_by_service/03-sonataflow_callbackstatetimeouts.sw.yaml similarity index 95% rename from test/testdata/workflow/persistence/from_platform_overwritten_by_service/03-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_overwritten_by_service/03-sonataflow_callbackstatetimeouts.sw.yaml index fb696bff4..ae3fc977b 100644 --- a/test/testdata/workflow/persistence/from_platform_overwritten_by_service/03-sonataflow_callbackstatetimeouts.sw.yaml +++ b/test/e2e/testdata/workflows/persistence/from_platform_overwritten_by_service/03-sonataflow_callbackstatetimeouts.sw.yaml @@ -15,10 +15,11 @@ apiVersion: sonataflow.org/v1alpha08 kind: SonataFlow metadata: - name: callbackstatetimeouts + name: callbackstatetimeouts-persistence annotations: sonataflow.org/description: Callback State Timeouts Example k8s sonataflow.org/version: 0.0.1 + sonataflow.org/profile: gitops spec: persistence: postgresql: @@ -30,9 +31,11 @@ spec: name: postgres port: 5432 databaseName: sonataflow - databaseSchema: callbackstatetimeouts + databaseSchema: callbackstatetimeouts-persistence podTemplate: + replicas: 0 container: + image: replaceme env: # set the flyway initialization in the WF container env - name: QUARKUS_FLYWAY_MIGRATE_AT_START diff --git a/test/testdata/workflow/persistence/from_platform_overwritten_by_service/kustomization.yaml b/test/e2e/testdata/workflows/persistence/from_platform_overwritten_by_service/kustomization.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_overwritten_by_service/kustomization.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_overwritten_by_service/kustomization.yaml diff --git a/test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/00-broker.yaml b/test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/00-broker.yaml new file mode 100644 index 000000000..6152f24d7 --- /dev/null +++ b/test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/00-broker.yaml @@ -0,0 +1,20 @@ +# Copyright 2024 Apache Software Foundation (ASF) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: eventing.knative.dev/v1 +kind: Broker +metadata: + name: default +spec: {} + diff --git a/test/testdata/workflow/persistence/from_platform_with_di_and_js_services/01-postgres.yaml b/test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/01-postgres.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_with_di_and_js_services/01-postgres.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/01-postgres.yaml diff --git a/test/testdata/workflow/persistence/from_platform_with_di_and_js_services/02-sonataflow_platform.yaml b/test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_with_di_and_js_services/02-sonataflow_platform.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/02-sonataflow_platform.yaml diff --git a/test/testdata/workflow/persistence/from_platform_with_di_and_js_services/03-configmap_callbackstatetimeouts-props.yaml b/test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/03-configmap_callbackstatetimeouts-props.yaml similarity index 89% rename from test/testdata/workflow/persistence/from_platform_with_di_and_js_services/03-configmap_callbackstatetimeouts-props.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/03-configmap_callbackstatetimeouts-props.yaml index d866ff7c9..c823ae22c 100644 --- a/test/testdata/workflow/persistence/from_platform_with_di_and_js_services/03-configmap_callbackstatetimeouts-props.yaml +++ b/test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/03-configmap_callbackstatetimeouts-props.yaml @@ -20,5 +20,5 @@ data: kind: ConfigMap metadata: labels: - app: callbackstatetimeouts - name: callbackstatetimeouts-props + app: callbackstatetimeouts-persistence + name: callbackstatetimeouts-persistence-props diff --git a/test/testdata/workflow/persistence/from_platform_with_di_and_js_services/04-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/04-sonataflow_callbackstatetimeouts.sw.yaml similarity index 94% rename from test/testdata/workflow/persistence/from_platform_with_di_and_js_services/04-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/04-sonataflow_callbackstatetimeouts.sw.yaml index b1d3f5ef0..b564f0aa5 100644 --- a/test/testdata/workflow/persistence/from_platform_with_di_and_js_services/04-sonataflow_callbackstatetimeouts.sw.yaml +++ b/test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/04-sonataflow_callbackstatetimeouts.sw.yaml @@ -15,11 +15,16 @@ apiVersion: sonataflow.org/v1alpha08 kind: SonataFlow metadata: - name: callbackstatetimeouts + name: callbackstatetimeouts-persistence annotations: sonataflow.org/description: Callback State Timeouts Example k8s sonataflow.org/version: 0.0.1 + sonataflow.org/profile: gitops spec: + podTemplate: + container: + image: replaceme + replicas: 0 flow: start: PrintStartMessage events: diff --git a/test/testdata/workflow/persistence/from_platform_with_di_and_js_services/kustomization.yaml b/test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/kustomization.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_with_di_and_js_services/kustomization.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_with_di_and_js_services/kustomization.yaml diff --git a/test/testdata/workflow/persistence/from_platform_with_no_persistence_required/01-postgres.yaml b/test/e2e/testdata/workflows/persistence/from_platform_with_no_persistence_required/01-postgres.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_with_no_persistence_required/01-postgres.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_with_no_persistence_required/01-postgres.yaml diff --git a/test/testdata/workflow/persistence/from_platform_with_no_persistence_required/02-sonataflow_platform.yaml b/test/e2e/testdata/workflows/persistence/from_platform_with_no_persistence_required/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_with_no_persistence_required/02-sonataflow_platform.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_with_no_persistence_required/02-sonataflow_platform.yaml diff --git a/test/testdata/workflow/persistence/from_platform_with_no_persistence_required/03-sonataflow_callbackstatetimeouts-no-persistence.sw.yaml b/test/e2e/testdata/workflows/persistence/from_platform_with_no_persistence_required/03-sonataflow_callbackstatetimeouts-no-persistence.sw.yaml similarity index 96% rename from test/testdata/workflow/persistence/from_platform_with_no_persistence_required/03-sonataflow_callbackstatetimeouts-no-persistence.sw.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_with_no_persistence_required/03-sonataflow_callbackstatetimeouts-no-persistence.sw.yaml index f7f4720fa..98bb7d5c4 100644 --- a/test/testdata/workflow/persistence/from_platform_with_no_persistence_required/03-sonataflow_callbackstatetimeouts-no-persistence.sw.yaml +++ b/test/e2e/testdata/workflows/persistence/from_platform_with_no_persistence_required/03-sonataflow_callbackstatetimeouts-no-persistence.sw.yaml @@ -15,16 +15,19 @@ apiVersion: sonataflow.org/v1alpha08 kind: SonataFlow metadata: - name: callbackstatetimeouts-no-persistence + name: callbackstatetimeouts annotations: sonataflow.org/description: Callback State Timeouts Example k8s sonataflow.org/version: 0.0.1 + sonataflow.org/profile: gitops spec: persistence: { migrateDBOnStartUp: true } podTemplate: + replicas: 0 container: + image: replaceme env: - name: QUARKUS_FLYWAY_MIGRATE_AT_START value: "true" diff --git a/test/testdata/workflow/persistence/from_platform_with_no_persistence_required/kustomization.yaml b/test/e2e/testdata/workflows/persistence/from_platform_with_no_persistence_required/kustomization.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_with_no_persistence_required/kustomization.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_with_no_persistence_required/kustomization.yaml diff --git a/test/testdata/workflow/persistence/from_platform_without_di_and_js_services/01-postgres.yaml b/test/e2e/testdata/workflows/persistence/from_platform_without_di_and_js_services/01-postgres.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_without_di_and_js_services/01-postgres.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_without_di_and_js_services/01-postgres.yaml diff --git a/test/testdata/workflow/persistence/from_platform_without_di_and_js_services/02-sonataflow_platform.yaml b/test/e2e/testdata/workflows/persistence/from_platform_without_di_and_js_services/02-sonataflow_platform.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_without_di_and_js_services/02-sonataflow_platform.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_without_di_and_js_services/02-sonataflow_platform.yaml diff --git a/test/testdata/workflow/persistence/from_platform_without_di_and_js_services/03-sonataflow_callbackstatetimeouts.sw.yaml b/test/e2e/testdata/workflows/persistence/from_platform_without_di_and_js_services/03-sonataflow_callbackstatetimeouts.sw.yaml similarity index 96% rename from test/testdata/workflow/persistence/from_platform_without_di_and_js_services/03-sonataflow_callbackstatetimeouts.sw.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_without_di_and_js_services/03-sonataflow_callbackstatetimeouts.sw.yaml index 307f85b61..36cf39420 100644 --- a/test/testdata/workflow/persistence/from_platform_without_di_and_js_services/03-sonataflow_callbackstatetimeouts.sw.yaml +++ b/test/e2e/testdata/workflows/persistence/from_platform_without_di_and_js_services/03-sonataflow_callbackstatetimeouts.sw.yaml @@ -15,13 +15,16 @@ apiVersion: sonataflow.org/v1alpha08 kind: SonataFlow metadata: - name: callbackstatetimeouts + name: callbackstatetimeouts-persistence annotations: sonataflow.org/description: Callback State Timeouts Example k8s sonataflow.org/version: 0.0.1 + sonataflow.org/profile: gitops spec: podTemplate: + replicas: 0 container: + image: replaceme env: # set the flyway initialization in the WF container env - name: QUARKUS_FLYWAY_MIGRATE_AT_START diff --git a/test/testdata/workflow/persistence/from_platform_without_di_and_js_services/kustomization.yaml b/test/e2e/testdata/workflows/persistence/from_platform_without_di_and_js_services/kustomization.yaml similarity index 100% rename from test/testdata/workflow/persistence/from_platform_without_di_and_js_services/kustomization.yaml rename to test/e2e/testdata/workflows/persistence/from_platform_without_di_and_js_services/kustomization.yaml diff --git a/test/e2e/workflow_test.go b/test/e2e/workflow_test.go index 9d7b5c93b..e7e0a1aa4 100644 --- a/test/e2e/workflow_test.go +++ b/test/e2e/workflow_test.go @@ -24,7 +24,6 @@ import ( "fmt" "math/rand" "os/exec" - "path/filepath" "strings" "time" @@ -44,13 +43,12 @@ const ( workflowAppLabel = "sonataflow.org/workflow-app" ) -var _ = Describe("Workflow Non-Persistence Use Cases :: ", Label("flows-non-persistence"), Ordered, func() { +var _ = Describe("Workflow Non-Persistence Use Cases :: ", Label("flows-ephemeral"), Ordered, func() { var targetNamespace string BeforeEach(func() { targetNamespace = fmt.Sprintf("test-%d", rand.Intn(randomIntRange)+1) - cmd := exec.Command("kubectl", "create", "namespace", targetNamespace) - _, err := utils.Run(cmd) + err := kubectlCreateNamespace(targetNamespace) Expect(err).NotTo(HaveOccurred()) }) AfterEach(func() { @@ -59,48 +57,45 @@ var _ = Describe("Workflow Non-Persistence Use Cases :: ", Label("flows-non-pers cmd := exec.Command("kubectl", "delete", "sonataflow", "--all", "-n", targetNamespace, "--wait") _, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) - cmd = exec.Command("kubectl", "delete", "namespace", targetNamespace, "--wait") - _, err = utils.Run(cmd) + err = kubectlDeleteNamespace(targetNamespace) Expect(err).NotTo(HaveOccurred()) } }) - Describe("ensure basic workflow deployments", func() { - projectDir, _ := utils.GetProjectDir() + Describe("Ensure basic workflow deployments", func() { - It("should successfully deploy the Simple Workflow in GitOps mode and verify if it's running", func() { + It("should successfully deploy the Simple Workflow in GitOps profile and verify if it's running", func() { By("creating an instance of the SonataFlow Operand(CR)") + sonataFlowCrFile := test.GetPathFromE2EDirectory("workflows", prebuiltWorkflows.Greetings.Name, "01-sonataflow.org_v1alpha08_sonataflow.yaml") EventuallyWithOffset(1, func() error { - cmd := exec.Command("kubectl", "apply", "-f", filepath.Join(projectDir, - "test/testdata/"+test.SonataFlowSimpleOpsYamlCR), "-n", targetNamespace) - _, err := utils.Run(cmd) - return err + return kubectlApplyFileOnCluster(sonataFlowCrFile, targetNamespace) + }, 3*time.Minute, time.Second).Should(Succeed()) + + By("Replacing the image with a prebuilt one and rollout") + EventuallyWithOffset(1, func() error { + return kubectlPatchSonataFlowImageAndRollout(targetNamespace, prebuiltWorkflows.Greetings.Name, prebuiltWorkflows.Greetings.Tag) }, 3*time.Minute, time.Second).Should(Succeed()) By("check the workflow is in running state") - EventuallyWithOffset(1, func() bool { return verifyWorkflowIsInRunningState("simple", targetNamespace) }, 15*time.Minute, 30*time.Second).Should(BeTrue()) + EventuallyWithOffset(1, func() bool { return verifyWorkflowIsInRunningState(prebuiltWorkflows.Greetings.Name, targetNamespace) }, 15*time.Minute, 30*time.Second).Should(BeTrue()) EventuallyWithOffset(1, func() error { - cmd := exec.Command("kubectl", "delete", "-f", filepath.Join(projectDir, - "test/testdata/"+test.SonataFlowSimpleOpsYamlCR), "-n", targetNamespace) - _, err := utils.Run(cmd) - return err + return kubectlDeleteFileOnCluster(sonataFlowCrFile, targetNamespace) }, 3*time.Minute, time.Second).Should(Succeed()) }) - It("should successfully deploy the Greeting Workflow in preview mode and verify if it's running", func() { + It("should successfully deploy the Greeting Workflow in preview profile and verify if it's running", func() { By("creating external resources DataInputSchema configMap") EventuallyWithOffset(1, func() error { - cmd := exec.Command("kubectl", "apply", "-f", filepath.Join(projectDir, - "test/testdata/"+test.SonataFlowGreetingsDataInputSchemaConfig), "-n", targetNamespace) + cmd := exec.Command("kubectl", "apply", "-f", test.GetPathFromDataDirectory(test.SonataFlowGreetingsDataInputSchemaConfig), "-n", targetNamespace) _, err := utils.Run(cmd) return err }, 3*time.Minute, time.Second).Should(Succeed()) + sonataFlowYaml := test.GetPathFromDataDirectory(test.SonataFlowGreetingsWithDataInputSchemaCR) By("creating an instance of the SonataFlow Operand(CR)") EventuallyWithOffset(1, func() error { - cmd := exec.Command("kubectl", "apply", "-f", filepath.Join(projectDir, - "test/testdata/"+test.SonataFlowGreetingsWithDataInputSchemaCR), "-n", targetNamespace) + cmd := exec.Command("kubectl", "apply", "-f", sonataFlowYaml, "-n", targetNamespace) _, err := utils.Run(cmd) return err }, 3*time.Minute, time.Second).Should(Succeed()) @@ -109,19 +104,17 @@ var _ = Describe("Workflow Non-Persistence Use Cases :: ", Label("flows-non-pers EventuallyWithOffset(1, func() bool { return verifyWorkflowIsInRunningState("greeting", targetNamespace) }, 15*time.Minute, 30*time.Second).Should(BeTrue()) EventuallyWithOffset(1, func() error { - cmd := exec.Command("kubectl", "delete", "-f", filepath.Join(projectDir, - "test/testdata/"+test.SonataFlowGreetingsWithDataInputSchemaCR), "-n", targetNamespace) + cmd := exec.Command("kubectl", "delete", "-f", sonataFlowYaml, "-n", targetNamespace) _, err := utils.Run(cmd) return err }, 3*time.Minute, time.Second).Should(Succeed()) }) It("should successfully deploy the orderprocessing workflow in devmode and verify if it's running", func() { - + orderProcessingFolder := test.GetPathFromE2EDirectory("order-processing") By("creating an instance of the SonataFlow Workflow in DevMode") EventuallyWithOffset(1, func() error { - cmd := exec.Command("kubectl", "apply", "-f", filepath.Join(projectDir, - test.GetSonataFlowE2eOrderProcessingFolder()), "-n", targetNamespace) + cmd := exec.Command("kubectl", "apply", "-f", orderProcessingFolder, "-n", targetNamespace) _, err := utils.Run(cmd) return err }, 3*time.Minute, time.Second).Should(Succeed()) @@ -138,8 +131,7 @@ var _ = Describe("Workflow Non-Persistence Use Cases :: ", Label("flows-non-pers EventuallyWithOffset(1, func() bool { return verifyWorkflowIsAddressable("orderprocessing", targetNamespace) }, 10*time.Minute, 30*time.Second).Should(BeTrue()) EventuallyWithOffset(1, func() error { - cmd := exec.Command("kubectl", "delete", "-f", filepath.Join(projectDir, - test.GetSonataFlowE2eOrderProcessingFolder()), "-n", targetNamespace) + cmd := exec.Command("kubectl", "delete", "-f", orderProcessingFolder, "-n", targetNamespace) _, err := utils.Run(cmd) return err }, 3*time.Minute, time.Second).Should(Succeed()) @@ -190,7 +182,16 @@ var _ = Describe("Workflow Persistence Use Cases :: ", Label("flows-persistence" cmd.Stdin = bytes.NewBuffer(manifests) _, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred()) - By("Wait for SonatatFlow CR to complete deployment") + + By("Replacing the image with a prebuilt one and rollout") + EventuallyWithOffset(1, func() error { + if withPersistence { + return kubectlPatchSonataFlowImageAndRollout(ns, prebuiltWorkflows.CallBackPersistence.Name, prebuiltWorkflows.CallBackPersistence.Tag) + } + return kubectlPatchSonataFlowImageAndRollout(ns, prebuiltWorkflows.CallBack.Name, prebuiltWorkflows.CallBack.Tag) + }, 3*time.Minute, time.Second).Should(Succeed()) + + By("Wait for SonataFlow CR to complete deployment") // wait for service deployments to be ready EventuallyWithOffset(1, func() bool { cmd = exec.Command("kubectl", "wait", "pod", "-n", ns, "-l", workflowAppLabel, "--for", "condition=Ready", "--timeout=5s") @@ -206,7 +207,7 @@ var _ = Describe("Workflow Persistence Use Cases :: ", Label("flows-persistence" waitForPodRestartCompletion(workflowAppLabel, ns) GinkgoWriter.Println("waitForPodRestartCompletion done") return true - }, 25*time.Minute, 5).Should(BeTrue()) + }, 5*time.Minute, 5*time.Second).Should(BeTrue()) By("Evaluate status of the workflow's pod database connection health endpoint") cmd = exec.Command("kubectl", "get", "pod", "-l", workflowAppLabel, "-n", ns, "-ojsonpath={.items[*].metadata.name}") @@ -256,22 +257,22 @@ var _ = Describe("Workflow Persistence Use Cases :: ", Label("flows-persistence" By("Validate that the workflow persistence was properly initialized") Expect(logs).Should(ContainSubstring("Flyway Community Edition")) Expect(logs).Should(ContainSubstring("Database: jdbc:postgresql://postgres.%s:5432", ns)) - result := verifySchemaMigration(logs, "callbackstatetimeouts") + result := verifySchemaMigration(logs, prebuiltWorkflows.CallBackPersistence.Name) GinkgoWriter.Println(fmt.Sprintf("verifySchemaMigration: %v", result)) Expect(result).Should(BeTrue()) Expect(logs).Should(ContainSubstring("Profile prod activated")) } else { By("Validate that the workflow has no persistence") Expect(logs).ShouldNot(ContainSubstring("Flyway Community Edition")) - Expect(logs).ShouldNot(ContainSubstring("Creating schema \"callbackstatetimeouts\"")) + Expect(logs).ShouldNot(ContainSubstring(fmt.Sprintf(`Creating schema "%s"`, prebuiltWorkflows.CallBack.Name))) Expect(logs).Should(ContainSubstring("Profile prod activated")) } }, - Entry("defined in the workflow from an existing kubernetes service as a reference", test.GetSonataFlowE2EWorkflowPersistenceSampleDataDirectory("by_service"), true, false), - Entry("defined in the workflow and from the sonataflow platform", test.GetSonataFlowE2EWorkflowPersistenceSampleDataDirectory("from_platform_overwritten_by_service"), true, false), - Entry("defined from the sonataflow platform as reference and with DI and JS", test.GetSonataFlowE2EWorkflowPersistenceSampleDataDirectory("from_platform_with_di_and_js_services"), true, true), - Entry("defined from the sonataflow platform as reference and without DI and JS", test.GetSonataFlowE2EWorkflowPersistenceSampleDataDirectory("from_platform_without_di_and_js_services"), true, false), - Entry("defined from the sonataflow platform as reference but not required by the workflow", test.GetSonataFlowE2EWorkflowPersistenceSampleDataDirectory("from_platform_with_no_persistence_required"), false, false), + Entry("defined in the workflow from an existing kubernetes service as a reference", test.GetPathFromE2EDirectory("workflows", "persistence", "by_service"), true, false), + Entry("defined in the workflow and from the sonataflow platform", test.GetPathFromE2EDirectory("workflows", "persistence", "from_platform_overwritten_by_service"), true, false), + Entry("defined from the sonataflow platform as reference and with DI and JS", test.GetPathFromE2EDirectory("workflows", "persistence", "from_platform_with_di_and_js_services"), true, true), + Entry("defined from the sonataflow platform as reference and without DI and JS", test.GetPathFromE2EDirectory("workflows", "persistence", "from_platform_without_di_and_js_services"), true, false), + Entry("defined from the sonataflow platform as reference but not required by the workflow", test.GetPathFromE2EDirectory("workflows", "persistence", "from_platform_with_no_persistence_required"), false, false), ) }) diff --git a/test/utils/utils.go b/test/utils/utils.go index 25a58df0d..90e7dfecf 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -59,17 +59,15 @@ func OutputDeployment(namespace, deployName string) error { func Run(cmd *exec.Cmd) ([]byte, error) { dir, _ := GetProjectDir() cmd.Dir = dir - fmt.Fprintf(GinkgoWriter, "running dir: %s\n", cmd.Dir) // To allow make commands be executed from the project directory which is subdir on SDK repo // TODO:(user) You might does not need the following code if err := os.Chdir(cmd.Dir); err != nil { - fmt.Fprintf(GinkgoWriter, "chdir dir: %s\n", err) + GinkgoWriter.Printf("chdir dir: %s\n", err) } cmd.Env = append(os.Environ(), "GO111MODULE=on") command := strings.Join(cmd.Args, " ") - fmt.Fprintf(GinkgoWriter, "running: %s\n", command) output, err := cmd.CombinedOutput() if err != nil { return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) diff --git a/test/yaml.go b/test/yaml.go index a0fbd8bb6..276f9b9b7 100644 --- a/test/yaml.go +++ b/test/yaml.go @@ -278,27 +278,15 @@ func GetPlatformOpenshiftE2eTest() string { } func GetSonataFlowE2eOrderProcessingFolder() string { - return e2eSamples + sonataFlowOrderProcessingFolder + return GetPathFromE2EDirectory("order-processing") } -func GetSonataFlowE2EPlatformServicesDirectory() string { - return filepath.Join(getTestDataDir(), "platform", "services") +func GetPathFromDataDirectory(join ...string) string { + return filepath.Join(append([]string{getTestDataDir()}, join...)...) } -func GetSonataFlowE2EPlatformServicesKnativeDirectory(subdir string) string { - return filepath.Join(getTestDataDir(), "platform", "services", "preview", "knative", subdir) -} - -func GetSonataFlowE2EPlatformNoServicesDirectory() string { - return filepath.Join(getTestDataDir(), "platform", "noservices") -} - -func GetSonataFlowE2EPlatformPersistenceSampleDataDirectory(subdir string) string { - return filepath.Join(getTestDataDir(), "platform", "persistence", subdir) -} - -func GetSonataFlowE2EWorkflowPersistenceSampleDataDirectory(subdir string) string { - return filepath.Join(getTestDataDir(), "workflow", "persistence", subdir) +func GetPathFromE2EDirectory(join ...string) string { + return filepath.Join(append([]string{getProjectDir(), "test", "e2e", "testdata"}, join...)...) } // getTestDataDir gets the testdata directory containing every sample out there from test/testdata.