Skip to content

Commit 62a3ac4

Browse files
JustinKuliopenshift-merge-robot
authored andcommitted
Add debug to enforce with status test
This test has been flakey - the last check for Compliant events has been coming back empty unexpectedly. This will print information about all of the events to help understand what is happening. Signed-off-by: Justin Kulikauskas <[email protected]>
1 parent f997dbc commit 62a3ac4

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

test/e2e/case34_enforce_w_status_test.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
package e2e
55

66
import (
7+
"strconv"
8+
79
. "github.com/onsi/ginkgo/v2"
810
. "github.com/onsi/gomega"
911

1012
"open-cluster-management.io/config-policy-controller/test/utils"
1113
)
1214

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() {
1416
const (
1517
rsrcPath = "../resources/case34_enforce_w_status/"
1618
policyYAML = rsrcPath + "policy.yaml"
@@ -60,7 +62,25 @@ var _ = Describe("Test compliance events of enforced policies that define a stat
6062
}, defaultTimeoutSeconds, 5).ShouldNot(BeEmpty())
6163
})
6264

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+
6484
utils.Kubectl("delete", "policy", policyName, "-n", "managed", "--ignore-not-found")
6585
configPlc := utils.GetWithTimeout(clientManagedDynamic, gvrConfigPolicy,
6686
cfgPlcName, "managed", false, defaultTimeoutSeconds,

0 commit comments

Comments
 (0)