From 7ba80a7757fbcd537624f3e24daed5f213c4dd96 Mon Sep 17 00:00:00 2001 From: Piyush Garg Date: Thu, 6 Feb 2020 22:29:41 +0530 Subject: [PATCH] Delete clusterscoped resource in teardown This will delete the clusterscoped resources we are creating in event listener e2e tests during teardown Fix #418 --- test/init_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/init_test.go b/test/init_test.go index 161ae489be4..f73a82cbcb9 100644 --- a/test/init_test.go +++ b/test/init_test.go @@ -101,6 +101,19 @@ func tearDown(t *testing.T, cs *clients, namespace string) { if err := cs.KubeClient.CoreV1().Namespaces().Delete(namespace, &metav1.DeleteOptions{}); err != nil { t.Errorf("Failed to delete namespace %s: %s", namespace, err) } + + t.Logf("Deleting Clusterscoped resource") + if err := cs.KubeClient.RbacV1().ClusterRoles().Delete("my-role", &metav1.DeleteOptions{}); err != nil { + t.Errorf("Failed to delete clusterrole my-role: %s", err) + } + + if err := cs.KubeClient.RbacV1().ClusterRoleBindings().Delete("my-rolebinding", &metav1.DeleteOptions{}); err != nil { + t.Errorf("Failed to delete clusterrolebinding my-rolebinding: %s", err) + } + + if err := cs.TriggersClient.TektonV1alpha1().ClusterTriggerBindings().Delete("my-clustertriggerbinding", &metav1.DeleteOptions{}); err != nil { + t.Errorf("Failed to delete clustertriggerbinding my-clustertriggerbinding: %s", err) + } } func header(logf logging.FormatLogger, text string) {