|
4 | 4 | package e2e |
5 | 5 |
|
6 | 6 | import ( |
| 7 | + "strconv" |
| 8 | + |
7 | 9 | . "github.com/onsi/ginkgo/v2" |
8 | 10 | . "github.com/onsi/gomega" |
9 | 11 |
|
10 | 12 | "open-cluster-management.io/config-policy-controller/test/utils" |
11 | 13 | ) |
12 | 14 |
|
13 | | -var _ = Describe("Test compliance events of enforced policies that define a status", Ordered, func() { |
| 15 | +var _ = Describe("Test compliance events of enforced policies that define a status", func() { |
14 | 16 | const ( |
15 | 17 | rsrcPath = "../resources/case34_enforce_w_status/" |
16 | 18 | policyYAML = rsrcPath + "policy.yaml" |
@@ -60,7 +62,25 @@ var _ = Describe("Test compliance events of enforced policies that define a stat |
60 | 62 | }, defaultTimeoutSeconds, 5).ShouldNot(BeEmpty()) |
61 | 63 | }) |
62 | 64 |
|
63 | | - AfterAll(func() { |
| 65 | + AfterEach(func() { |
| 66 | + if CurrentSpecReport().Failed() { |
| 67 | + events := utils.GetMatchingEvents(clientManaged, testNamespace, |
| 68 | + policyName, ".*", ".*", defaultTimeoutSeconds) |
| 69 | + |
| 70 | + By("Test failed, printing compliance events for debugging, event count = " + strconv.Itoa(len(events))) |
| 71 | + for _, ev := range events { |
| 72 | + GinkgoWriter.Println("---") |
| 73 | + GinkgoWriter.Println("Name:", ev.Name) |
| 74 | + GinkgoWriter.Println("Reason:", ev.Reason) |
| 75 | + GinkgoWriter.Println("Message:", ev.Message) |
| 76 | + GinkgoWriter.Println("FirstTimestamp:", ev.FirstTimestamp) |
| 77 | + GinkgoWriter.Println("LastTimestamp:", ev.LastTimestamp) |
| 78 | + GinkgoWriter.Println("Count:", ev.Count) |
| 79 | + GinkgoWriter.Println("Type:", ev.Type) |
| 80 | + GinkgoWriter.Println("---") |
| 81 | + } |
| 82 | + } |
| 83 | + |
64 | 84 | utils.Kubectl("delete", "policy", policyName, "-n", "managed", "--ignore-not-found") |
65 | 85 | configPlc := utils.GetWithTimeout(clientManagedDynamic, gvrConfigPolicy, |
66 | 86 | cfgPlcName, "managed", false, defaultTimeoutSeconds, |
|
0 commit comments