Skip to content

Commit

Permalink
Use the same serviceaccount in yaml and go test
Browse files Browse the repository at this point in the history
  • Loading branch information
piyush-garg committed Jan 15, 2025
1 parent d3b8050 commit 1c73b1a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 25 deletions.
2 changes: 1 addition & 1 deletion test/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

const (
timeout = 5 * time.Minute
timeout = 10 * time.Minute
)

// TknRunner contains information about the current test execution tkn binary path
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/eventlistener/eventListener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

func TestEventListenerE2E(t *testing.T) {
c, namespace := framework.Setup(t)
knativetest.CleanupOnInterrupt(func() { framework.TearDown(t, c, namespace) }, t.Logf)
knativetest.CleanupOnInterrupt(func() { cleanupResources(t, c, namespace) }, t.Logf)
defer cleanupResources(t, c, namespace)

kubectl := cli.NewKubectl(namespace)
Expand Down Expand Up @@ -61,7 +61,7 @@ func TestEventListenerE2E(t *testing.T) {

func TestEventListenerLogsE2E(t *testing.T) {
c, namespace := framework.Setup(t)
knativetest.CleanupOnInterrupt(func() { framework.TearDown(t, c, namespace) }, t.Logf)
knativetest.CleanupOnInterrupt(func() { cleanupResources(t, c, namespace) }, t.Logf)
defer cleanupResources(t, c, namespace)

kubectl := cli.NewKubectl(namespace)
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestEventListenerLogsE2E(t *testing.T) {

func TestEventListener_v1beta1LogsE2E(t *testing.T) {
c, namespace := framework.Setup(t)
knativetest.CleanupOnInterrupt(func() { framework.TearDown(t, c, namespace) }, t.Logf)
knativetest.CleanupOnInterrupt(func() { cleanupResources(t, c, namespace) }, t.Logf)
defer cleanupResources(t, c, namespace)

kubectl := cli.NewKubectl(namespace)
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestEventListener_v1beta1LogsE2E(t *testing.T) {

func TestEventListener_v1beta1E2E(t *testing.T) {
c, namespace := framework.Setup(t)
knativetest.CleanupOnInterrupt(func() { framework.TearDown(t, c, namespace) }, t.Logf)
knativetest.CleanupOnInterrupt(func() { cleanupResources(t, c, namespace) }, t.Logf)
defer cleanupResources(t, c, namespace)

kubectl := cli.NewKubectl(namespace)
Expand Down
10 changes: 4 additions & 6 deletions test/framework/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,12 @@ func TearDown(t *testing.T, cs *Clients, namespace string) {
t.Log(string(bs))
}
Header(t.Logf, fmt.Sprintf("Dumping logs from Pods in the %s", namespace))
taskruns, err := cs.TaskRunClient.List(context.Background(), metav1.ListOptions{})
pods, err := cs.KubeClient.CoreV1().Pods(namespace).List(context.Background(), metav1.ListOptions{})
if err != nil {
t.Errorf("Error getting TaskRun list %s", err)
t.Errorf("Error getting pods list %s", err)
}
for _, tr := range taskruns.Items {
if tr.Status.PodName != "" {
CollectPodLogs(cs, tr.Status.PodName, namespace, t.Logf)
}
for _, pod := range pods.Items {
CollectPodLogs(cs, pod.Name, namespace, t.Logf)
}
}

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 1c73b1a

Please sign in to comment.