From aa48e32d9be4061489c759f28c08ad4e0d6faca3 Mon Sep 17 00:00:00 2001 From: Roy Golan Date: Thu, 18 Jul 2024 19:58:45 +0300 Subject: [PATCH] e2e: Use fake notifications service as a workaround Right now the upstream notification service exported at https://github.com/redhat-developer/rhdh-plugin-export-backstage-backstage/releases is not working due to some compatibility issues with upstream RHDH backstage version. Till we solve this problem the e2e test will use a fake notifications pod that would log all the requests to the container log. We can examine the container logs and make sure the notifications were sent in the right format, for now. Signed-off-by: Roy Golan --- .github/workflows/move2kube-e2e.yaml | 7 ++++++- .github/workflows/mta-e2e.yaml | 16 ++++++++-------- .github/workflows/mta-v6.x-e2e.yaml | 9 +++++++-- e2e/helper-functions.sh | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 e2e/helper-functions.sh diff --git a/.github/workflows/move2kube-e2e.yaml b/.github/workflows/move2kube-e2e.yaml index 7bd96933..eae1b684 100644 --- a/.github/workflows/move2kube-e2e.yaml +++ b/.github/workflows/move2kube-e2e.yaml @@ -90,6 +90,11 @@ jobs: kubectl get pods -o wide kubectl wait --for=condition=Ready=true pods -l "app=sonataflow-platform" --timeout=180s + - name: Deploy fake notifications service + run: | + source e2e/helper-functions.sh + create-fake-notifications-service + - name: Deploy Move2kube serverless workflow run: | kubectl patch configmap/config-features \ @@ -122,7 +127,7 @@ jobs: kubectl patch configmap/m2k-props \ --type merge \ - -p '{"data": {"application.properties" :"move2kube_url=http://move2kube-instance-svc.default.svc.cluster.local:8080\nquarkus.rest-client.move2kube_yaml.url=http://move2kube-instance-svc.default.svc.cluster.local:8080\nquarkus.rest-client.notifications.url=http://janus-idp-workflows-backstage.default.svc.cluster.local:7007/api/notifications/"}}' + -p '{"data": {"application.properties" :"move2kube_url=http://move2kube-instance-svc.default.svc.cluster.local:8080\nquarkus.rest-client.move2kube_yaml.url=http://move2kube-instance-svc.default.svc.cluster.local:8080\nquarkus.rest-client.notifications.url=http://fake-notifications-service.default.svc.cluster.local:8080/api/notifications/"}}' kubectl delete pod -l "app=m2k" kubectl get pods -o wide kubectl wait --for=condition=Ready=true pods -l "app=m2k" --timeout=1m diff --git a/.github/workflows/mta-e2e.yaml b/.github/workflows/mta-e2e.yaml index 4b48874b..f9502b7d 100644 --- a/.github/workflows/mta-e2e.yaml +++ b/.github/workflows/mta-e2e.yaml @@ -24,6 +24,7 @@ jobs: runs-on: ubuntu-latest needs: build steps: + - uses: actions/checkout@v4 - name: Create k8s Kind Cluster uses: helm/kind-action@v1.10.0 with: @@ -68,7 +69,7 @@ jobs: kubectl wait --for=condition=Ready=true pods -l "app.kubernetes.io/name=tackle-ui" -n my-konveyor-operator --timeout=120s # now MTA workflow can execute agains tackle-ui.my-konveyor-operator.svc:8080 - - name: Deploy Janus-idp-workflow-helm (janus + sonataflow-opertor) + - name: Deploy Orchestrator-k8s helm chart run: | helm repo add orchestrator https://parodos-dev.github.io/orchestrator-helm-chart helm install orchestrator orchestrator/orchestrator-k8s @@ -81,6 +82,11 @@ jobs: kubectl get pods -o wide kubectl wait --for=condition=Ready=true pods -l "app=sonataflow-platform" --timeout=120s + - name: Deploy fake notifications service + run: | + source e2e/helper-functions.sh + create-fake-notifications-service + - name: Download sonataflow artifacts generated manifests uses: actions/download-artifact@v4 with: @@ -100,7 +106,7 @@ jobs: - name: Deploy MTA serverless workflow run: | # Set the endpoint to the tackle-ui service - yq --inplace '.spec.podTemplate.container.env |= ( . + [{"name": "QUARKUS_REST_CLIENT_MTA_JSON_URL", "value": "http://tackle-ui.my-konveyor-operator.svc:8080/hub"}, {"name": "BACKSTAGE_NOTIFICATIONS_URL", "value": "http://janus-idp-workflows-backstage.default.svc.cluster.local:7007/api/notifications/"}] )' manifests/01-sonataflow_mtaanalysis.yaml + yq --inplace '.spec.podTemplate.container.env |= ( . + [{"name": "QUARKUS_REST_CLIENT_MTA_JSON_URL", "value": "http://tackle-ui.my-konveyor-operator.svc:8080/hub"}, {"name": "BACKSTAGE_NOTIFICATIONS_URL", "value": "http://fake-notifications-service.default.svc.cluster.local:8080/api/notifications/"}] )' manifests/01-sonataflow_mtaanalysis.yaml # Disable persistence for e2e tests yq e '.spec.persistence = {}' -i manifests/01-sonataflow_mtaanalysis.yaml @@ -114,11 +120,6 @@ jobs: cat manifests/01-sonataflow_mtaanalysis.yaml echo "---" - # Set notification external access token - echo " Set notification external access token" - yq --inplace '.data."NOTIFICATIONS_BEARER_TOKEN" = "ZTJldG9rZW4="' manifests/01-secret_mtaanalysis.yaml # notsecret - cat manifests/01-secret_mtaanalysis.yaml - # deploy the manifests created by the ${{ steps.build-image.outputs.image }} image kubectl apply -f manifests/ sleep 5 @@ -128,7 +129,6 @@ jobs: kubectl get pods -o wide kubectl wait --for=condition=Ready=true pods -l "app=mtaanalysis" --timeout=5m - - uses: actions/checkout@v4 - name: Run e2e script run: | e2e/mta.sh diff --git a/.github/workflows/mta-v6.x-e2e.yaml b/.github/workflows/mta-v6.x-e2e.yaml index 7422b38d..f639d59e 100644 --- a/.github/workflows/mta-v6.x-e2e.yaml +++ b/.github/workflows/mta-v6.x-e2e.yaml @@ -24,6 +24,7 @@ jobs: runs-on: ubuntu-latest needs: build steps: + - uses: actions/checkout@v4 - name: Create k8s Kind Cluster uses: helm/kind-action@v1.10.0 with: @@ -81,6 +82,11 @@ jobs: kubectl get pods -o wide kubectl wait --for=condition=Ready=true pods -l "app=sonataflow-platform" --timeout=600s + - name: Deploy fake notifications service + run: | + source e2e/helper-functions.sh + create-fake-notifications-service + - name: Download sonataflow artifacts generated manifests uses: actions/download-artifact@v4 with: @@ -100,7 +106,7 @@ jobs: - name: Deploy MTA serverless workflow run: | # Set the endpoint to the tackle-ui service - yq --inplace '.spec.podTemplate.container.env |= ( . + [{"name": "QUARKUS_REST_CLIENT_MTA_JSON_URL", "value": "http://tackle-ui.my-konveyor-operator.svc:8080"}, {"name": "BACKSTAGE_NOTIFICATIONS_URL", "value": "http://janus-idp-workflows-backstage.default.svc.cluster.local:7007/api/notifications/"}] )' manifests/01-sonataflow_mta-analysis-v6.yaml + yq --inplace '.spec.podTemplate.container.env |= ( . + [{"name": "QUARKUS_REST_CLIENT_MTA_JSON_URL", "value": "http://tackle-ui.my-konveyor-operator.svc:8080"}, {"name": "BACKSTAGE_NOTIFICATIONS_URL", "value": "http://fake-notifications-service.default.svc.cluster.local:8080/api/notifications/"}] )' manifests/01-sonataflow_mta-analysis-v6.yaml # Disable persistence for e2e tests yq e '.spec.persistence = {}' -i manifests/01-sonataflow_mta-analysis-v6.yaml @@ -123,7 +129,6 @@ jobs: kubectl get pods -o wide kubectl wait --for=condition=Ready=true pods -l "app=mta-analysis-v6" --timeout=10m - - uses: actions/checkout@v4 - name: Run e2e script run: | e2e/mta-v6.x.sh diff --git a/e2e/helper-functions.sh b/e2e/helper-functions.sh new file mode 100644 index 00000000..84f57512 --- /dev/null +++ b/e2e/helper-functions.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +function create-fake-notifications-service() { + oc run fake-notifications-service --image=docker.io/golang:1.21 --port=8080 -- bash -c 'cat < main.go && go run main.go +package main + +import ( + "fmt" + "log" + "net/http" +) +func main() { + log.Fatal(http.ListenAndServe(":8080", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Println(r) }))) +} +EOF +' + kubectl wait --for=condition=Ready=true pods fake-notifications-service --timeout=5m + kubectl expose pods/fake-notifications-service +}