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 149f7c3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
5 changes: 3 additions & 2 deletions test/e2e/eventlistener/eventListener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ 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")
kubectl.MustSucceed(t, "wait", "--for=condition=Ready", "pod", "-n", namespace, "--timeout=5m", "--all")

t.Run("Get logs of EventListener", func(t *testing.T) {
res := tkn.MustSucceed(t, "eventlistener", "logs", elName, "-t", "1")
Expand Down Expand Up @@ -108,7 +109,7 @@ func TestEventListener_v1beta1LogsE2E(t *testing.T) {
createResources(t, c, namespace)
kubectl.MustSucceed(t, "create", "-f", helper.GetResourcePath("eventlistener/eventlistener_v1beta1_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")
kubectl.MustSucceed(t, "wait", "--for=condition=Ready", "pod", "-n", namespace, "--timeout=5m", "--all")

t.Run("Get logs of EventListener", func(t *testing.T) {
res := tkn.MustSucceed(t, "eventlistener", "logs", elName, "-t", "1")
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"]
16 changes: 7 additions & 9 deletions test/resources/eventlistener/eventlistener_log.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ kind: EventListener
metadata:
name: github-listener-interceptor
spec:
serviceAccountName: tekton-triggers-github-log-sa
serviceAccountName: tekton-triggers-github-sa
triggers:
- name: github-listener
interceptors:
Expand Down Expand Up @@ -82,18 +82,13 @@ spec:
- name: url
value: $(tt.params.gitrepositoryurl)
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: tekton-triggers-github-log-sa
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: tekton-triggers-github-binding
subjects:
- kind: ServiceAccount
name: tekton-triggers-github-log-sa
name: tekton-triggers-github-sa
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand All @@ -107,12 +102,15 @@ 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"]
verbs: ["get", "list", "watch"]
# Permissions to create resources in associated TriggerTemplates
- apiGroups: ["tekton.dev"]
resources: ["pipelineruns", "taskruns"]
resources: ["pipelineruns"]
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"]
16 changes: 7 additions & 9 deletions test/resources/eventlistener/eventlistener_v1beta1_log.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ kind: EventListener
metadata:
name: github-listener-interceptor
spec:
serviceAccountName: tekton-triggers-github-log-sa
serviceAccountName: tekton-triggers-github-sa
triggers:
- name: github-listener
interceptors:
Expand Down Expand Up @@ -89,18 +89,13 @@ spec:
- name: url
value: $(tt.params.gitrepositoryurl)
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: tekton-triggers-github-log-sa
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: tekton-triggers-github-binding
subjects:
- kind: ServiceAccount
name: tekton-triggers-github-log-sa
name: tekton-triggers-github-sa
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand All @@ -114,12 +109,15 @@ 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"]
verbs: ["get", "list", "watch"]
# Permissions to create resources in associated TriggerTemplates
- apiGroups: ["tekton.dev"]
resources: ["pipelineruns", "taskruns"]
resources: ["pipelineruns"]
verbs: ["create"]
- apiGroups: [""]
resources: ["events"]
verbs: ["create", "patch"]

0 comments on commit 149f7c3

Please sign in to comment.