Skip to content

Commit da028e4

Browse files
committedNov 6, 2023
Fix flake: Operator Group [It] e2e functionality
Signed-off-by: Todd Short <[email protected]>
1 parent 13e7c0f commit da028e4

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed
 

‎test/e2e/operator_groups_e2e_test.go

+17-8
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,30 @@ var _ = Describe("Operator Group", func() {
127127
}
128128
_, err = crc.OperatorsV1().OperatorGroups(opGroupNamespace).Create(context.TODO(), &operatorGroup, metav1.CreateOptions{})
129129
require.NoError(GinkgoT(), err)
130-
expectedOperatorGroupStatus := v1.OperatorGroupStatus{
131-
Namespaces: []string{opGroupNamespace, createdOtherNamespace.GetName()},
132-
}
130+
131+
// fetched namespaces might be in any order
132+
namespaces := map[string]bool{}
133+
namespaces[opGroupNamespace] = true
134+
namespaces[createdOtherNamespace.GetName()] = true
133135

134136
log("Waiting on operator group to have correct status")
135137
err = wait.Poll(pollInterval, pollDuration, func() (bool, error) {
136138
fetched, fetchErr := crc.OperatorsV1().OperatorGroups(opGroupNamespace).Get(context.TODO(), operatorGroup.Name, metav1.GetOptions{})
137139
if fetchErr != nil {
138-
return false, fetchErr
140+
log(fmt.Sprintf("error getting operatorgroup %s/%s: %v", opGroupNamespace, operatorGroup.Name, err))
141+
return false, nil
139142
}
140-
if len(fetched.Status.Namespaces) > 0 {
141-
require.ElementsMatch(GinkgoT(), expectedOperatorGroupStatus.Namespaces, fetched.Status.Namespaces, "have %#v", fetched.Status.Namespaces)
142-
return true, nil
143+
if len(namespaces) != len(fetched.Status.Namespaces) {
144+
log(fmt.Sprintf("element length mismatch: %v vs %v", namespaces, fetched.Status.Namespaces))
145+
return false, nil
143146
}
144-
return false, nil
147+
for _, v := range fetched.Status.Namespaces {
148+
if !namespaces[v] {
149+
log(fmt.Sprintf("element values mismatch: %v vs %v", namespaces, fetched.Status.Namespaces))
150+
return false, nil
151+
}
152+
}
153+
return true, nil
145154
})
146155
require.NoError(GinkgoT(), err)
147156

0 commit comments

Comments
 (0)
Please sign in to comment.