From f0280b8019cf2f5d5138106f41133d83e18413d6 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Thu, 14 Sep 2023 10:39:54 +0200 Subject: [PATCH 1/9] Added documentation for e2e tests --- README.md | 4 ++++ hack/e2e/.env.template | 4 ++++ hack/e2e/README.md | 53 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 hack/e2e/.env.template create mode 100644 hack/e2e/README.md diff --git a/README.md b/README.md index 89392df9..45e940cc 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,10 @@ kubectl get pods -n eventing-manager-system kubectl get -n kyma-system eventing ``` +## End-to-End Tests + +See [hack/e2e/README.md](hack/e2e/README.md) + ## Contributing See [CONTRIBUTING.md](CONTRIBUTING.md) diff --git a/hack/e2e/.env.template b/hack/e2e/.env.template new file mode 100644 index 00000000..23bffb9e --- /dev/null +++ b/hack/e2e/.env.template @@ -0,0 +1,4 @@ +KUBECONFIG= +BACKEND_TYPE=NATS +MANAGER_IMAGE= +EVENTMESH_NAMESPACE="/default/sap.kyma/tunas-develop" diff --git a/hack/e2e/README.md b/hack/e2e/README.md new file mode 100644 index 00000000..7cedb4cc --- /dev/null +++ b/hack/e2e/README.md @@ -0,0 +1,53 @@ +[![REUSE status](https://api.reuse.software/badge/github.com/kyma-project/eventing-manager)](https://api.reuse.software/info/github.com/kyma-project/eventing-manager) + +# Eventing End-to-End Tests +Tests the end-to-end flow for eventing-manager. + +## Overview + +This test covers the end-to-end flow for Eventing. It is divided in three parts: +1. `setup` - prepares an Eventing CR and verifies that all the required resources are being provisioned by the eventing-manager. +2. `eventing` - prepares Subscription CR(s) and tests the end-to-end delivery of events for different event types. +3. `cleanup` - removes the test resources and namespaces from the cluster. + +## Usage +You’ll need a Kubernetes cluster to run against. You can use [k3d](https://k3d.io/) to get a local cluster for testing, or run against a remote cluster. +**Note:** Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster `kubectl cluster-info` shows). + +### Pre-requisites + +- [Go](https://go.dev/) +- [kubectl](https://kubernetes.io/docs/tasks/tools/) +- Access to Kubernetes cluster ([k3d](https://k3d.io/) / k8s) with eventing-manager deployed. +- For EventMesh backend, the following secrets should exist in the cluster: + - Event Mesh credentials secret by name: `eventing-backend` in namespace: `kyma-system`. + - OAuth client secret by name: `eventing-webhook-auth` in namespace: `kyma-system`. + +### How to run end-to-end tests + +1. Prepare the `.env` file based on the `.env.template`. + +``` +KUBECONFIG= # Kyma cluster kubeconfig file path +BACKEND_TYPE=NATS # NATS or EventMesh +MANAGER_IMAGE= # [Optional] Container image of eventing-manager +EVENTMESH_NAMESPACE= # [Optional] Default is: "/default/sap.kyma/tunas-develop" +``` + +2. Run the following command to set up the environment variables in your system: +```bash +export $(xargs < .env) +``` + +3. Run the following make target to run the whole ent-to-end test suite. +```bash +make e2e +``` + +### Make targets + +- `make e2e-setup` - creates an Eventing CR and verifies that all the required resources are being provisioned by the eventing-manager. If an Eventing CR already exists in the cluster, then it will only update the CR if the `spec.backend.type` is different from the backend configured for tests. +- `make e2e-eventing-setup` - prepares Subscription CR(s) and deploys a subscriber to be used in subscriptions as a sink. It will not update the Subscription CR(s) if they already exists. +- `make e2e-eventing` - tests the end-to-end delivery of events for different event types. +- `make e2e-eventing-cleanup` - removes the subscriber and the Subscription CR(s) from the cluster. +- `make e2e-cleanup` - removes all the test resources and namespaces from the cluster. From 11a3d624d5a4188cd9f9f2016f46c92dd889ae02 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Thu, 14 Sep 2023 10:41:24 +0200 Subject: [PATCH 2/9] updated doc --- hack/e2e/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/hack/e2e/README.md b/hack/e2e/README.md index 7cedb4cc..e53c9378 100644 --- a/hack/e2e/README.md +++ b/hack/e2e/README.md @@ -1,5 +1,3 @@ -[![REUSE status](https://api.reuse.software/badge/github.com/kyma-project/eventing-manager)](https://api.reuse.software/info/github.com/kyma-project/eventing-manager) - # Eventing End-to-End Tests Tests the end-to-end flow for eventing-manager. From a6bbad240ddd43ddd9f2a002012067e3333afc3d Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Thu, 14 Sep 2023 10:42:34 +0200 Subject: [PATCH 3/9] updated doc --- hack/e2e/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/hack/e2e/README.md b/hack/e2e/README.md index e53c9378..b7471243 100644 --- a/hack/e2e/README.md +++ b/hack/e2e/README.md @@ -9,8 +9,6 @@ This test covers the end-to-end flow for Eventing. It is divided in three parts: 3. `cleanup` - removes the test resources and namespaces from the cluster. ## Usage -You’ll need a Kubernetes cluster to run against. You can use [k3d](https://k3d.io/) to get a local cluster for testing, or run against a remote cluster. -**Note:** Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster `kubectl cluster-info` shows). ### Pre-requisites From 74aa66895207f76a3813a62467cb8249695c5bd9 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Thu, 14 Sep 2023 10:45:34 +0200 Subject: [PATCH 4/9] updated doc --- hack/e2e/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hack/e2e/README.md b/hack/e2e/README.md index b7471243..eb6dc91c 100644 --- a/hack/e2e/README.md +++ b/hack/e2e/README.md @@ -14,7 +14,8 @@ This test covers the end-to-end flow for Eventing. It is divided in three parts: - [Go](https://go.dev/) - [kubectl](https://kubernetes.io/docs/tasks/tools/) -- Access to Kubernetes cluster ([k3d](https://k3d.io/) / k8s) with eventing-manager deployed. +- Access to Kubernetes cluster ([k3d](https://k3d.io/) / k8s) +- Eventing-manager deployed to the cluster without any Eventing CR. - For EventMesh backend, the following secrets should exist in the cluster: - Event Mesh credentials secret by name: `eventing-backend` in namespace: `kyma-system`. - OAuth client secret by name: `eventing-webhook-auth` in namespace: `kyma-system`. @@ -24,7 +25,7 @@ This test covers the end-to-end flow for Eventing. It is divided in three parts: 1. Prepare the `.env` file based on the `.env.template`. ``` -KUBECONFIG= # Kyma cluster kubeconfig file path +KUBECONFIG= # Kubernetes cluster kubeconfig file path BACKEND_TYPE=NATS # NATS or EventMesh MANAGER_IMAGE= # [Optional] Container image of eventing-manager EVENTMESH_NAMESPACE= # [Optional] Default is: "/default/sap.kyma/tunas-develop" @@ -35,7 +36,7 @@ EVENTMESH_NAMESPACE= # [Optional] Default is: "/default/sap.kyma/tunas-d export $(xargs < .env) ``` -3. Run the following make target to run the whole ent-to-end test suite. +3. Run the following make target to run the whole end-to-end test suite. ```bash make e2e ``` From c9a3ce33afdfa7da07922d8d6f7f84b705e98d5e Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Thu, 14 Sep 2023 10:59:55 +0200 Subject: [PATCH 5/9] Apply suggestions from code review Co-authored-by: Nina Hingerl <76950046+NHingerl@users.noreply.github.com> --- hack/e2e/README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hack/e2e/README.md b/hack/e2e/README.md index eb6dc91c..a7a6df7f 100644 --- a/hack/e2e/README.md +++ b/hack/e2e/README.md @@ -1,10 +1,10 @@ # Eventing End-to-End Tests -Tests the end-to-end flow for eventing-manager. +Tests the end-to-end flow for Eventing manager. ## Overview This test covers the end-to-end flow for Eventing. It is divided in three parts: -1. `setup` - prepares an Eventing CR and verifies that all the required resources are being provisioned by the eventing-manager. +1. `setup` - prepares an Eventing CR and verifies that all the required resources are provisioned by the Eventing manager. 2. `eventing` - prepares Subscription CR(s) and tests the end-to-end delivery of events for different event types. 3. `cleanup` - removes the test resources and namespaces from the cluster. @@ -15,8 +15,8 @@ This test covers the end-to-end flow for Eventing. It is divided in three parts: - [Go](https://go.dev/) - [kubectl](https://kubernetes.io/docs/tasks/tools/) - Access to Kubernetes cluster ([k3d](https://k3d.io/) / k8s) -- Eventing-manager deployed to the cluster without any Eventing CR. -- For EventMesh backend, the following secrets should exist in the cluster: +- Eventing manager deployed to the cluster without any Eventing CR. +- For EventMesh backend, the following secrets must exist in the cluster: - Event Mesh credentials secret by name: `eventing-backend` in namespace: `kyma-system`. - OAuth client secret by name: `eventing-webhook-auth` in namespace: `kyma-system`. @@ -31,20 +31,20 @@ MANAGER_IMAGE= # [Optional] Container image of eventing-manager EVENTMESH_NAMESPACE= # [Optional] Default is: "/default/sap.kyma/tunas-develop" ``` -2. Run the following command to set up the environment variables in your system: +2. To set up the environment variables in your system, run: ```bash export $(xargs < .env) ``` -3. Run the following make target to run the whole end-to-end test suite. +3. To run the whole end-to-end test suite, run: ```bash make e2e ``` ### Make targets -- `make e2e-setup` - creates an Eventing CR and verifies that all the required resources are being provisioned by the eventing-manager. If an Eventing CR already exists in the cluster, then it will only update the CR if the `spec.backend.type` is different from the backend configured for tests. -- `make e2e-eventing-setup` - prepares Subscription CR(s) and deploys a subscriber to be used in subscriptions as a sink. It will not update the Subscription CR(s) if they already exists. +- `make e2e-setup` - creates an Eventing CR and verifies that all the required resources are provisioned by the eventing-manager. If an Eventing CR already exists in the cluster, then it will only update the CR if the `spec.backend.type` is different from the backend configured for tests. +- `make e2e-eventing-setup` - prepares Subscription CR(s) and deploys a subscriber to be used in subscriptions as a sink. It does not update the Subscription CR(s) if they already exist. - `make e2e-eventing` - tests the end-to-end delivery of events for different event types. - `make e2e-eventing-cleanup` - removes the subscriber and the Subscription CR(s) from the cluster. - `make e2e-cleanup` - removes all the test resources and namespaces from the cluster. From 830907d582c087bd0d89ed74835e96628c6be3af Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Thu, 14 Sep 2023 11:25:39 +0200 Subject: [PATCH 6/9] updated doc --- hack/e2e/README.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/hack/e2e/README.md b/hack/e2e/README.md index a7a6df7f..c7eca89c 100644 --- a/hack/e2e/README.md +++ b/hack/e2e/README.md @@ -3,10 +3,7 @@ Tests the end-to-end flow for Eventing manager. ## Overview -This test covers the end-to-end flow for Eventing. It is divided in three parts: -1. `setup` - prepares an Eventing CR and verifies that all the required resources are provisioned by the Eventing manager. -2. `eventing` - prepares Subscription CR(s) and tests the end-to-end delivery of events for different event types. -3. `cleanup` - removes the test resources and namespaces from the cluster. +This test covers the end-to-end flow for Eventing. It tests the creation of an Eventing CR and verifies that all the required resources are provisioned by the Eventing manager. It also tests the end-to-end delivery of events for different event types. ## Usage @@ -24,25 +21,29 @@ This test covers the end-to-end flow for Eventing. It is divided in three parts: 1. Prepare the `.env` file based on the `.env.template`. -``` -KUBECONFIG= # Kubernetes cluster kubeconfig file path -BACKEND_TYPE=NATS # NATS or EventMesh -MANAGER_IMAGE= # [Optional] Container image of eventing-manager -EVENTMESH_NAMESPACE= # [Optional] Default is: "/default/sap.kyma/tunas-develop" -``` + ``` + KUBECONFIG= # Kubernetes cluster kubeconfig file path + BACKEND_TYPE=NATS # NATS or EventMesh + MANAGER_IMAGE= # [Optional] Container image of eventing-manager + EVENTMESH_NAMESPACE= # [Optional] Default is: "/default/sap.kyma/tunas-develop" + ``` 2. To set up the environment variables in your system, run: -```bash -export $(xargs < .env) -``` + + ```bash + export $(xargs < .env) + ``` 3. To run the whole end-to-end test suite, run: -```bash -make e2e -``` + + ```bash + make e2e + ``` ### Make targets +The following make targets are also available to run a single test phase: + - `make e2e-setup` - creates an Eventing CR and verifies that all the required resources are provisioned by the eventing-manager. If an Eventing CR already exists in the cluster, then it will only update the CR if the `spec.backend.type` is different from the backend configured for tests. - `make e2e-eventing-setup` - prepares Subscription CR(s) and deploys a subscriber to be used in subscriptions as a sink. It does not update the Subscription CR(s) if they already exist. - `make e2e-eventing` - tests the end-to-end delivery of events for different event types. From 240cabb54ebd8825d16b10ecd0cdd7de64336cd9 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Thu, 14 Sep 2023 13:58:58 +0200 Subject: [PATCH 7/9] updated doc --- hack/e2e/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/e2e/README.md b/hack/e2e/README.md index c7eca89c..f0ff5e9f 100644 --- a/hack/e2e/README.md +++ b/hack/e2e/README.md @@ -11,7 +11,7 @@ This test covers the end-to-end flow for Eventing. It tests the creation of an E - [Go](https://go.dev/) - [kubectl](https://kubernetes.io/docs/tasks/tools/) -- Access to Kubernetes cluster ([k3d](https://k3d.io/) / k8s) +- Access to Kubernetes cluster (k8s) - Eventing manager deployed to the cluster without any Eventing CR. - For EventMesh backend, the following secrets must exist in the cluster: - Event Mesh credentials secret by name: `eventing-backend` in namespace: `kyma-system`. From bf6d1c7cef623db5cded1439eb82d1c0f593a95b Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Thu, 14 Sep 2023 15:58:43 +0200 Subject: [PATCH 8/9] Update hack/e2e/README.md Co-authored-by: Nina Hingerl <76950046+NHingerl@users.noreply.github.com> --- hack/e2e/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/e2e/README.md b/hack/e2e/README.md index f0ff5e9f..2cbedddc 100644 --- a/hack/e2e/README.md +++ b/hack/e2e/README.md @@ -7,7 +7,7 @@ This test covers the end-to-end flow for Eventing. It tests the creation of an E ## Usage -### Pre-requisites +### Prerequisites - [Go](https://go.dev/) - [kubectl](https://kubernetes.io/docs/tasks/tools/) From df37eed13dcd6adf06fde9346d5488ccde800e8b Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Thu, 14 Sep 2023 15:59:18 +0200 Subject: [PATCH 9/9] Apply suggestions from code review Co-authored-by: Nina Hingerl <76950046+NHingerl@users.noreply.github.com> --- hack/e2e/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hack/e2e/README.md b/hack/e2e/README.md index 2cbedddc..87db8814 100644 --- a/hack/e2e/README.md +++ b/hack/e2e/README.md @@ -40,9 +40,9 @@ This test covers the end-to-end flow for Eventing. It tests the creation of an E make e2e ``` -### Make targets +### Run a single test phase -The following make targets are also available to run a single test phase: +If you want to run only a single test phase, use the following make targets: - `make e2e-setup` - creates an Eventing CR and verifies that all the required resources are provisioned by the eventing-manager. If an Eventing CR already exists in the cluster, then it will only update the CR if the `spec.backend.type` is different from the backend configured for tests. - `make e2e-eventing-setup` - prepares Subscription CR(s) and deploys a subscriber to be used in subscriptions as a sink. It does not update the Subscription CR(s) if they already exist.