Skip to content

Commit

Permalink
Reduce debug logs for operatorpolicy test
Browse files Browse the repository at this point in the history
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 <jkulikau@redhat.com>
  • Loading branch information
JustinKuli committed Feb 28, 2024
1 parent 8cc552e commit 4ebb85c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/e2e/case38_install_operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ var _ = Describe("Test installing an operator from OperatorPolicy", Ordered, fun
expectedCondition metav1.Condition,
expectedEventMsgSnippet string,
) {
var debugMessage string

defer func() {
if CurrentSpecReport().Failed() {
GinkgoWriter.Println(debugMessage)
}
}()

checkFunc := func(g Gomega) {
GinkgoHelper()

Expand All @@ -42,7 +50,7 @@ var _ = Describe("Test installing an operator from OperatorPolicy", Ordered, fun
policyJSON, err := json.MarshalIndent(unstructPolicy.Object, "", " ")
g.Expect(err).NotTo(HaveOccurred())

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

policy := policyv1beta1.OperatorPolicy{}
Expand Down

0 comments on commit 4ebb85c

Please sign in to comment.