diff --git a/test/e2e/fleet_guard_rail_test.go b/test/e2e/fleet_guard_rail_test.go index 3a85635c2..18e38cac4 100644 --- a/test/e2e/fleet_guard_rail_test.go +++ b/test/e2e/fleet_guard_rail_test.go @@ -43,7 +43,7 @@ var _ = Describe("fleet guard rail tests for deny MC CREATE operations", func() }, } - By("expecting denial of operation CREATE of member cluster") + By(fmt.Sprintf("expecting denial of operation CREATE of member cluster %s", mc.Name)) err := impersonateHubClient.Create(ctx, mc) var statusErr *k8sErrors.StatusError Expect(errors.As(err, &statusErr)).To(BeTrue(), fmt.Sprintf("Create member cluster call produced error %s. Error type wanted is %s.", reflect.TypeOf(err), reflect.TypeOf(&k8sErrors.StatusError{}))) @@ -67,10 +67,10 @@ var _ = Describe("fleet guard rail tests for allow/deny MC UPDATE, DELETE operat var mc clusterv1beta1.MemberCluster g.Expect(hubClient.Get(ctx, types.NamespacedName{Name: mcName}, &mc)).Should(Succeed()) - By("update member cluster spec") + By(fmt.Sprintf("update member cluster spec for MC %s", mc.Name)) mc.Spec.HeartbeatPeriodSeconds = 30 - By("expecting denial of operation UPDATE of member cluster") + By(fmt.Sprintf("expecting denial of operation UPDATE of member cluster %s", mc.Name)) err := impersonateHubClient.Update(ctx, &mc) if k8sErrors.IsConflict(err) { return err @@ -89,7 +89,7 @@ var _ = Describe("fleet guard rail tests for allow/deny MC UPDATE, DELETE operat }, } - By("expecting denial of operation DELETE of member cluster") + By(fmt.Sprintf("expecting denial of operation DELETE of member cluster %s", mc.Name)) err := impersonateHubClient.Delete(ctx, &mc) var statusErr *k8sErrors.StatusError Expect(errors.As(err, &statusErr)).To(BeTrue(), fmt.Sprintf("Delete member cluster call produced error %s. Error type wanted is %s.", reflect.TypeOf(err), reflect.TypeOf(&k8sErrors.StatusError{}))) @@ -98,7 +98,7 @@ var _ = Describe("fleet guard rail tests for allow/deny MC UPDATE, DELETE operat It("should allow update operation on member cluster CR labels for any user", func() { var mc clusterv1beta1.MemberCluster - By("update labels in member cluster, expecting successful UPDATE of member cluster") + By(fmt.Sprintf("update labels in member cluster %s, expecting successful UPDATE of member cluster", mcName)) Eventually(func(g Gomega) error { g.Expect(hubClient.Get(ctx, types.NamespacedName{Name: mcName}, &mc)).Should(Succeed()) labels := make(map[string]string) @@ -110,7 +110,7 @@ var _ = Describe("fleet guard rail tests for allow/deny MC UPDATE, DELETE operat It("should allow update operation on member cluster CR annotations for any user", func() { var mc clusterv1beta1.MemberCluster - By("update annotations in member cluster, expecting successful UPDATE of member cluster") + By(fmt.Sprintf("update annotations in member cluster %s, expecting successful UPDATE of member cluster", mcName)) Eventually(func(g Gomega) error { g.Expect(hubClient.Get(ctx, types.NamespacedName{Name: mcName}, &mc)).Should(Succeed()) annotations := make(map[string]string) @@ -122,7 +122,7 @@ var _ = Describe("fleet guard rail tests for allow/deny MC UPDATE, DELETE operat It("should allow update operation on member cluster CR spec for user in system:masters group", func() { var mc clusterv1beta1.MemberCluster - By("update spec of member cluster, expecting successful UPDATE of member cluster") + By(fmt.Sprintf("update spec of member cluster %s, expecting successful UPDATE of member cluster", mcName)) Eventually(func(g Gomega) error { g.Expect(hubClient.Get(ctx, types.NamespacedName{Name: mcName}, &mc)).Should(Succeed()) mc.Spec.HeartbeatPeriodSeconds = 31 @@ -132,7 +132,7 @@ var _ = Describe("fleet guard rail tests for allow/deny MC UPDATE, DELETE operat It("should allow update operation on member cluster CR status for user in system:masters group", func() { var mc clusterv1beta1.MemberCluster - By("update status of member cluster, expecting successful UPDATE of member cluster") + By(fmt.Sprintf("update status of member cluster %s, expecting successful UPDATE of member cluster", mcName)) Eventually(func(g Gomega) error { g.Expect(hubClient.Get(ctx, types.NamespacedName{Name: mcName}, &mc)).Should(Succeed()) g.Expect(mc.Status.Conditions).ToNot(BeEmpty()) diff --git a/test/e2e/utils_test.go b/test/e2e/utils_test.go index bce1137c1..fb761db3f 100644 --- a/test/e2e/utils_test.go +++ b/test/e2e/utils_test.go @@ -10,6 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -147,6 +148,7 @@ func deleteResourcesForFleetGuardRail() { func createMemberClusterResource(name string) { // Create the MC. + By(fmt.Sprintf("In MC BeforeAll %s", name)) mc := &clusterv1beta1.MemberCluster{ ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -164,6 +166,7 @@ func createMemberClusterResource(name string) { } func deleteMemberClusterResource(name string) { + By(fmt.Sprintf("In MC AfterAll %s", name)) Eventually(func(g Gomega) error { var mc clusterv1beta1.MemberCluster err := hubClient.Get(ctx, types.NamespacedName{Name: name}, &mc)