Skip to content

Commit

Permalink
nit: fix logging functional test
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Sch <sebassch@gmail.com>
  • Loading branch information
SchSeba committed Dec 5, 2023
1 parent 1382ccf commit 72587d9
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions test/conformance/tests/test_sriov_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ var _ = Describe("[sriov] operator", func() {
setOperatorConfigLogLevel(2)

By("Flip DisableDrain to trigger operator activity")
since := time.Now()
since := time.Now().Add(-10 * time.Second)
Eventually(func() error {
return cluster.SetDisableNodeDrainState(clients, operatorNamespace, !initialDisableDrain)
}, 1*time.Minute, 5*time.Second).ShouldNot(HaveOccurred())
Expand All @@ -240,28 +240,40 @@ var _ = Describe("[sriov] operator", func() {
setOperatorConfigLogLevel(0)

By("Flip DisableDrain again to trigger operator activity")
since = time.Now()
since = time.Now().Add(-10 * time.Second)
Eventually(func() error {
return cluster.SetDisableNodeDrainState(clients, operatorNamespace, initialDisableDrain)
}, 1*time.Minute, 5*time.Second).ShouldNot(HaveOccurred())

By("Assert logs contains less operator activity")
Eventually(func(g Gomega) {
logs := getOperatorLogs(since)
g.Expect(logs).To(

// time only contains sec, but we can have race here that in the same sec there was a sync
afterLogs := []string{}
found := false
for _, log := range logs {
if found {
afterLogs = append(afterLogs, log)
}
if strings.Contains(log, "{\"new-level\": 0, \"current-level\": 2}") {
found = true
}
}
g.Expect(found).To(BeTrue())
g.Expect(afterLogs).To(
ContainElement(And(
ContainSubstring("Reconciling SriovOperatorConfig"),
)),
)

// Should not contain verbose logging
g.Expect(logs).ToNot(
g.Expect(afterLogs).ToNot(
ContainElement(
ContainSubstring("Start to sync webhook objects"),
),
)
}, 1*time.Minute, 5*time.Second).Should(Succeed())

}, 3*time.Minute, 5*time.Second).Should(Succeed())
})
})
})
Expand Down

0 comments on commit 72587d9

Please sign in to comment.