Skip to content

Commit

Permalink
serial: generalize function to check different degraded reasons
Browse files Browse the repository at this point in the history
Upgrade `isDegradedInternalError` to `isDegradedWith` to check different
reasons instead of checking that the reason is particularly
`status.ReasonInternalError`.

Signed-off-by: Shereen Haj <shajmakh@redhat.com>
  • Loading branch information
shajmakh committed Feb 25, 2025
1 parent 52cb65e commit 7890dda
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions test/e2e/serial/tests/tolerations.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ var _ = Describe("[serial][disruptive][rtetols] numaresources RTE tolerations su
Eventually(func(g Gomega) {
err := fxt.Client.Get(ctx, nroKey, &updatedNropObj)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(isDegradedInternalError(updatedNropObj.Status.Conditions, kvalidation.ErrorTypeNotSupported.String())).To(BeTrue(), "Condition not degraded as expected")
g.Expect(isDegradedWith(updatedNropObj.Status.Conditions, kvalidation.ErrorTypeNotSupported.String(), status.ReasonInternalError)).To(BeTrue(), "Condition not degraded as expected")
}).WithTimeout(5 * time.Minute).WithPolling(30 * time.Second).Should(Succeed())
})

Expand Down Expand Up @@ -163,7 +163,7 @@ var _ = Describe("[serial][disruptive][rtetols] numaresources RTE tolerations su
Eventually(func(g Gomega) {
err := fxt.Client.Get(ctx, nroKey, &updatedNropObj)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(isDegradedInternalError(updatedNropObj.Status.Conditions, kvalidation.ErrorTypeNotSupported.String())).To(BeTrue(), "Condition not degraded as expected")
g.Expect(isDegradedWith(updatedNropObj.Status.Conditions, kvalidation.ErrorTypeNotSupported.String(), status.ReasonInternalError)).To(BeTrue(), "Condition not degraded as expected")
}).WithTimeout(5 * time.Minute).WithPolling(30 * time.Second).Should(Succeed())
})
})
Expand Down Expand Up @@ -786,7 +786,7 @@ func isRTEPodFoundOnNode(cli client.Client, ctx context.Context, nodeName string
return matchingPod, found
}

func isDegradedInternalError(conds []metav1.Condition, msgContains string) bool {
func isDegradedWith(conds []metav1.Condition, msgContains string, reason string) bool {
cond := status.FindCondition(conds, status.ConditionDegraded)
if cond == nil {
return false
Expand All @@ -798,8 +798,8 @@ func isDegradedInternalError(conds []metav1.Condition, msgContains string) bool
klog.InfoS("Degraded message is not as expected", "condition", cond.String(), "expected message to contain", msgContains)
return false
}
if cond.Reason != status.ReasonInternalError {
klog.InfoS("Degraded reason is not as expected", "condition", cond.String(), "expected", status.ReasonInternalError)
if cond.Reason != reason {
klog.InfoS("Degraded reason is not as expected", "condition", cond.String(), "expected", reason)
return false
}
return true
Expand Down Expand Up @@ -876,7 +876,6 @@ func waitForMcpUpdateWithID(cli client.Client, ctx context.Context, mcpsInfo []m
Expect(err).ToNot(HaveOccurred())
Expect(ok).To(BeTrue())
}

}

func verifyUpdatedMCOnNodes(cli client.Client, ctx context.Context, node corev1.Node, desired string) (bool, error) {
Expand Down

0 comments on commit 7890dda

Please sign in to comment.