From 773146f01ba2cc40340697bcc4a6c261a96b2819 Mon Sep 17 00:00:00 2001 From: Piyush Garg Date: Thu, 16 Jan 2025 02:12:04 +0530 Subject: [PATCH] Test --- test/e2e-tests.sh | 2 +- test/e2e/eventlistener/eventListener_test.go | 20 +++++++++++++++++++ .../eventlistener/eventlistener.yaml | 5 ++++- .../eventlistener/eventlistener_log.yaml | 5 ++++- .../eventlistener/eventlistener_v1beta1.yaml | 5 ++++- .../eventlistener_v1beta1_log.yaml | 5 ++++- 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/test/e2e-tests.sh b/test/e2e-tests.sh index a9ede2e7d..f11020091 100755 --- a/test/e2e-tests.sh +++ b/test/e2e-tests.sh @@ -171,7 +171,7 @@ else export TEST_CLIENT_BINARY="${PWD}/tkn" fi -go_test_e2e ./test/e2e/... || failed=1 +go test -v -count=1 ./test/... -tags=e2e -run ^TestEventListenerLogsE2E || failed=1 (( failed )) && fail_test success diff --git a/test/e2e/eventlistener/eventListener_test.go b/test/e2e/eventlistener/eventListener_test.go index 9a7cf296f..785ac393c 100644 --- a/test/e2e/eventlistener/eventListener_test.go +++ b/test/e2e/eventlistener/eventListener_test.go @@ -72,6 +72,7 @@ func TestEventListenerLogsE2E(t *testing.T) { t.Logf("Creating EventListener %s in namespace %s", elName, namespace) createResources(t, c, namespace) kubectl.MustSucceed(t, "create", "-f", helper.GetResourcePath("eventlistener/eventlistener_log.yaml")) + // Wait for pods to run and crash for next test kubectl.MustSucceed(t, "wait", "--for=jsonpath=.status.phase=Running", "pod", "-n", namespace, "--timeout=2m", "--all") @@ -205,6 +206,25 @@ func createResources(t *testing.T, c *framework.Clients, namespace string) { func cleanupResources(t *testing.T, c *framework.Clients, namespace string) { t.Helper() + + tkn, _ := cli.NewTknRunner(namespace) + res := tkn.MustSucceed(t, "eventlistener", "logs", "github-listener-interceptor", "-t", "1") + t.Log(res.Stdout()) + + kubectl := cli.NewKubectl(namespace) + res = kubectl.MustSucceed(t, "wait", "--for=jsonpath=.status.phase=Running", "pod", "-n", namespace, "--timeout=2m", "--all") + t.Log(res.Stdout()) + + t.Logf("############################") + res = kubectl.MustSucceed(t, "logs", "deployment/el-github-listener-interceptor", "-n", namespace) + t.Log(res.Stdout()) + + t.Logf("############################") + res = kubectl.MustSucceed(t, "logs", "deployment/el-github-listener-interceptor", "-n", namespace, "--previous") + t.Log(res.Stdout()) + + t.Logf("############################") + framework.TearDown(t, c, namespace) // Cleanup cluster-scoped resources diff --git a/test/resources/eventlistener/eventlistener.yaml b/test/resources/eventlistener/eventlistener.yaml index 7186f9a0d..753650459 100644 --- a/test/resources/eventlistener/eventlistener.yaml +++ b/test/resources/eventlistener/eventlistener.yaml @@ -102,7 +102,7 @@ rules: # Permissions for every EventListener deployment to function - apiGroups: ["triggers.tekton.dev"] resources: ["eventlisteners", "triggerbindings", "interceptors", "triggertemplates", "triggers"] - verbs: ["get", "list"] + verbs: ["get", "list", "watch"] - apiGroups: [""] # secrets are only needed for Github/Gitlab interceptors, serviceaccounts only for per trigger authorization resources: ["configmaps", "secrets", "serviceaccounts"] @@ -111,3 +111,6 @@ rules: - apiGroups: ["tekton.dev"] resources: ["pipelineruns", "taskruns"] verbs: ["create"] + - apiGroups: [ "" ] + resources: [ "events" ] + verbs: [ "create", "patch" ] diff --git a/test/resources/eventlistener/eventlistener_log.yaml b/test/resources/eventlistener/eventlistener_log.yaml index 5e14e8013..9332bd0aa 100644 --- a/test/resources/eventlistener/eventlistener_log.yaml +++ b/test/resources/eventlistener/eventlistener_log.yaml @@ -107,7 +107,7 @@ rules: # Permissions for every EventListener deployment to function - apiGroups: ["triggers.tekton.dev"] resources: ["eventlisteners", "triggerbindings", "interceptors", "triggertemplates", "triggers"] - verbs: ["get", "list"] + verbs: ["get", "list", "watch"] - apiGroups: [""] # secrets are only needed for Github/Gitlab interceptors, serviceaccounts only for per trigger authorization resources: ["configmaps", "secrets", "serviceaccounts"] @@ -116,3 +116,6 @@ rules: - apiGroups: ["tekton.dev"] resources: ["pipelineruns", "taskruns"] verbs: ["create"] + - apiGroups: [ "" ] + resources: [ "events" ] + verbs: [ "create", "patch" ] diff --git a/test/resources/eventlistener/eventlistener_v1beta1.yaml b/test/resources/eventlistener/eventlistener_v1beta1.yaml index 9476b8880..3b0fe10db 100644 --- a/test/resources/eventlistener/eventlistener_v1beta1.yaml +++ b/test/resources/eventlistener/eventlistener_v1beta1.yaml @@ -109,7 +109,7 @@ rules: # Permissions for every EventListener deployment to function - apiGroups: ["triggers.tekton.dev"] resources: ["eventlisteners", "triggerbindings", "interceptors", "triggertemplates", "triggers"] - verbs: ["get", "list"] + verbs: ["get", "list", "watch"] - apiGroups: [""] # secrets are only needed for Github/Gitlab interceptors, serviceaccounts only for per trigger authorization resources: ["configmaps", "secrets", "serviceaccounts"] @@ -118,3 +118,6 @@ rules: - apiGroups: ["tekton.dev"] resources: ["pipelineruns", "taskruns"] verbs: ["create"] + - apiGroups: [ "" ] + resources: [ "events" ] + verbs: [ "create", "patch" ] diff --git a/test/resources/eventlistener/eventlistener_v1beta1_log.yaml b/test/resources/eventlistener/eventlistener_v1beta1_log.yaml index cf1306085..1ef4f60aa 100644 --- a/test/resources/eventlistener/eventlistener_v1beta1_log.yaml +++ b/test/resources/eventlistener/eventlistener_v1beta1_log.yaml @@ -114,7 +114,7 @@ rules: # Permissions for every EventListener deployment to function - apiGroups: ["triggers.tekton.dev"] resources: ["eventlisteners", "triggerbindings", "interceptors", "triggertemplates", "triggers"] - verbs: ["get", "list"] + verbs: ["get", "list", "watch"] - apiGroups: [""] # secrets are only needed for Github/Gitlab interceptors, serviceaccounts only for per trigger authorization resources: ["configmaps", "secrets", "serviceaccounts"] @@ -123,3 +123,6 @@ rules: - apiGroups: ["tekton.dev"] resources: ["pipelineruns", "taskruns"] verbs: ["create"] + - apiGroups: [ "" ] + resources: [ "events" ] + verbs: [ "create", "patch" ]