Skip to content

Commit 0671703

Browse files
Reduce debug logs for operatorpolicy test
Instead of printing the log every time the function fails in one of the Eventually runs, it saves a message and will only print it if the test overall fails. This should reduce noise during the tests. Signed-off-by: Justin Kulikauskas <[email protected]>
1 parent 8cc552e commit 0671703

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/e2e/case38_install_operator_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,26 @@ var _ = Describe("Test installing an operator from OperatorPolicy", Ordered, fun
3333
expectedCondition metav1.Condition,
3434
expectedEventMsgSnippet string,
3535
) {
36+
var debugMessage string
37+
38+
defer func() {
39+
if CurrentSpecReport().Failed() {
40+
GinkgoWriter.Println(debugMessage)
41+
}
42+
}()
43+
3644
checkFunc := func(g Gomega) {
3745
GinkgoHelper()
3846

3947
unstructPolicy := utils.GetWithTimeout(clientManagedDynamic, gvrOperatorPolicy, polName,
4048
opPolTestNS, true, eventuallyTimeout)
4149

50+
unstructured.RemoveNestedField(unstructPolicy.Object, "metadata", "managedFields")
51+
4252
policyJSON, err := json.MarshalIndent(unstructPolicy.Object, "", " ")
4353
g.Expect(err).NotTo(HaveOccurred())
4454

45-
GinkgoWriter.Printf("Debug info for failure.\npolicy JSON: %s\nwanted related objects: %+v\n"+
55+
debugMessage = fmt.Sprintf("Debug info for failure.\npolicy JSON: %s\nwanted related objects: %+v\n"+
4656
"wanted condition: %+v\n", string(policyJSON), expectedRelatedObjs, expectedCondition)
4757

4858
policy := policyv1beta1.OperatorPolicy{}

0 commit comments

Comments
 (0)