Skip to content

Commit

Permalink
Fix eventlistener permissions and tests
Browse files Browse the repository at this point in the history
This will fix eventlistener permissions and will send
a dummy event to trigger logs
  • Loading branch information
piyush-garg committed Jan 25, 2025
1 parent d3b8050 commit 624bfb7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
23 changes: 19 additions & 4 deletions test/e2e/eventlistener/eventListener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package eventlistener

import (
"context"
"fmt"
"testing"

"github.com/tektoncd/cli/test/cli"
Expand Down Expand Up @@ -72,8 +73,15 @@ 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")
// Wait for pods to run
kubectl.MustSucceed(t, "wait", "--for=condition=Ready", "pod", "-n", namespace, "--timeout=5m", "--all")
svcURL := fmt.Sprintf("http://el-github-listener-interceptor.%s.svc.cluster.local:8080", namespace)

// Send dummy event
kubectl.MustSucceed(t, "-n", namespace, "run", "curlrequest", "--image=curlimages/curl", "--restart=Never", "--",
"curl -v -H 'X-GitHub-Event: pull_request' -H 'X-Hub-Signature: sha1=ba0cdc263b3492a74b601d240c27efe81c4720cb' -H 'Content-Type: application/json' "+
"-d '{\"action\": \"opened\", \"pull_request\":{\"head\":{\"sha\": \"28911bbb5a3e2ea034daf1f6be0a822d50e31e73\"}},\"repository\":{\"clone_url\": \"https://github.com/tektoncd/triggers.git\"}}'",
svcURL)

t.Run("Get logs of EventListener", func(t *testing.T) {
res := tkn.MustSucceed(t, "eventlistener", "logs", elName, "-t", "1")
Expand Down Expand Up @@ -107,8 +115,15 @@ func TestEventListener_v1beta1LogsE2E(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_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")
// Wait for pods to run
kubectl.MustSucceed(t, "wait", "--for=condition=Ready", "pod", "-n", namespace, "--timeout=5m", "--all")
svcURL := fmt.Sprintf("http://el-github-listener-interceptor.%s.svc.cluster.local:8080", namespace)

// Send dummy event
kubectl.MustSucceed(t, "-n", namespace, "run", "curlrequest", "--image=curlimages/curl", "--restart=Never", "--",
"curl -v -H 'X-GitHub-Event: pull_request' -H 'X-Hub-Signature: sha1=ba0cdc263b3492a74b601d240c27efe81c4720cb' -H 'Content-Type: application/json' "+
"-d '{\"action\": \"opened\", \"pull_request\":{\"head\":{\"sha\": \"28911bbb5a3e2ea034daf1f6be0a822d50e31e73\"}},\"repository\":{\"clone_url\": \"https://github.com/tektoncd/triggers.git\"}}'",
svcURL)

t.Run("Get logs of EventListener", func(t *testing.T) {
res := tkn.MustSucceed(t, "eventlistener", "logs", elName, "-t", "1")
Expand Down
9 changes: 2 additions & 7 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 Down
9 changes: 2 additions & 7 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 Down

0 comments on commit 624bfb7

Please sign in to comment.