Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
piyush-garg committed Jan 16, 2025
1 parent d3b8050 commit 773146f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 20 additions & 0 deletions test/e2e/eventlistener/eventListener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion test/resources/eventlistener/eventlistener.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -111,3 +111,6 @@ rules:
- apiGroups: ["tekton.dev"]
resources: ["pipelineruns", "taskruns"]
verbs: ["create"]
- apiGroups: [ "" ]
resources: [ "events" ]
verbs: [ "create", "patch" ]
5 changes: 4 additions & 1 deletion test/resources/eventlistener/eventlistener_log.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -116,3 +116,6 @@ rules:
- apiGroups: ["tekton.dev"]
resources: ["pipelineruns", "taskruns"]
verbs: ["create"]
- apiGroups: [ "" ]
resources: [ "events" ]
verbs: [ "create", "patch" ]
5 changes: 4 additions & 1 deletion test/resources/eventlistener/eventlistener_v1beta1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -118,3 +118,6 @@ rules:
- apiGroups: ["tekton.dev"]
resources: ["pipelineruns", "taskruns"]
verbs: ["create"]
- apiGroups: [ "" ]
resources: [ "events" ]
verbs: [ "create", "patch" ]
5 changes: 4 additions & 1 deletion test/resources/eventlistener/eventlistener_v1beta1_log.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -123,3 +123,6 @@ rules:
- apiGroups: ["tekton.dev"]
resources: ["pipelineruns", "taskruns"]
verbs: ["create"]
- apiGroups: [ "" ]
resources: [ "events" ]
verbs: [ "create", "patch" ]

0 comments on commit 773146f

Please sign in to comment.