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 520deac
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/e2e/case38_install_operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,26 @@ 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()

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

unstructured.RemoveNestedField(unstructPolicy.Object, "metadata", "managedFields")

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 520deac

Please sign in to comment.