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 5d4ea4f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 27 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
12 changes: 6 additions & 6 deletions test/e2e/eventlistener/eventListener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestEventListenerE2E(t *testing.T) {
createResources(t, c, namespace)
kubectl.MustSucceed(t, "create", "-f", helper.GetResourcePath("eventlistener/eventlistener.yaml"))
// Wait for pods to become available for next test
kubectl.MustSucceed(t, "wait", "--for=condition=Ready", "pod", "-n", namespace, "--timeout=2m", "--all")
kubectl.MustSucceed(t, "wait", "--for=condition=Ready", "pod", "-n", namespace, "--timeout=5m", "--all")

t.Run("Assert if EventListener AVAILABLE status is true", func(t *testing.T) {
res := tkn.MustSucceed(t, "eventlistener", "list")
Expand All @@ -56,7 +56,7 @@ func TestEventListenerE2E(t *testing.T) {
t.Logf("Scaling EventListener %s to 3 replicas in namespace %s", elName, namespace)
kubectl.MustSucceed(t, "apply", "-f", helper.GetResourcePath("eventlistener/eventlistener-multi-replica.yaml"))
// Wait for pods to become available for next test
kubectl.MustSucceed(t, "wait", "--for=condition=Ready", "pod", "-n", namespace, "--timeout=2m", "--all")
kubectl.MustSucceed(t, "wait", "--for=condition=Ready", "pod", "-n", namespace, "--timeout=5m", "--all")
}

func TestEventListenerLogsE2E(t *testing.T) {
Expand All @@ -73,7 +73,7 @@ func TestEventListenerLogsE2E(t *testing.T) {
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=jsonpath=.status.phase=Running", "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 +108,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=jsonpath=.status.phase=Running", "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 @@ -143,7 +143,7 @@ func TestEventListener_v1beta1E2E(t *testing.T) {
createResources(t, c, namespace)
kubectl.MustSucceed(t, "create", "-f", helper.GetResourcePath("eventlistener/eventlistener_v1beta1.yaml"))
// Wait for pods to become available for next test
kubectl.MustSucceed(t, "wait", "--for=condition=Ready", "pod", "-n", namespace, "--timeout=2m", "--all")
kubectl.MustSucceed(t, "wait", "--for=condition=Ready", "pod", "-n", namespace, "--timeout=5m", "--all")

t.Run("Assert if EventListener AVAILABLE status is true", func(t *testing.T) {
res := tkn.MustSucceed(t, "eventlistener", "list")
Expand All @@ -154,7 +154,7 @@ func TestEventListener_v1beta1E2E(t *testing.T) {
t.Logf("Scaling EventListener %s to 3 replicas in namespace %s", elName, namespace)
kubectl.MustSucceed(t, "apply", "-f", helper.GetResourcePath("eventlistener/eventlistener_v1beta1-multi-replica.yaml"))
// Wait for pods to become available for next test
kubectl.MustSucceed(t, "wait", "--for=condition=Ready", "pod", "-n", namespace, "--timeout=2m", "--all")
kubectl.MustSucceed(t, "wait", "--for=condition=Ready", "pod", "-n", namespace, "--timeout=5m", "--all")
}

func createResources(t *testing.T, c *framework.Clients, namespace string) {
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 5d4ea4f

Please sign in to comment.