@@ -9,14 +9,40 @@ commands:
9
9
"openshift-gitops-argocd-application-controller"
10
10
"openshift-gitops-argocd-server"
11
11
)
12
- current_rb=( $(oc get rolebindings -n "${NAMESPACE}" | awk '/gitops/ {print $1}') )
13
12
14
- # Check that the required RoleBindings exist:
15
- for rb in "${expected_rb[@]}"
16
- do
17
- oc get rolebinding "${rb}" -n "${NAMESPACE}" > /dev/null
13
+ # Check that eventually the current role bindings equal the expected role
14
+ # bindings. Timeout after 60 seconds
15
+ timer=0
16
+ current_rb=( $(oc get rolebindings -n "${NAMESPACE}" | awk '/gitops/ {print $1}' | sort) )
17
+ while [[ "${current_rb[@]}" != "${expected_rb[@]}" ]]; do
18
+ if [[ $timer -eq 60 ]]; then
19
+ echo "timed out waiting for current role bindings to equal expected role bindings"
20
+ echo "current role bindings: ${current_rb[*]}"
21
+ echo "expected role bindings: ${expected_rb[*]}"
22
+ exit 1
23
+ fi
24
+
25
+ timer=$((timer+5))
26
+ sleep 5
27
+ current_rb=( $(oc get rolebindings -n "${NAMESPACE}" | awk '/gitops/ {print $1}' | sort) )
18
28
done
19
29
20
- # Check that there are only two RoleBindings
21
- echo "Current RoleBindings: ${current_rb[*]}"
22
- [[ "${#current_rb[@]}" == "2" ]]
30
+ # Check that the expected role bindings continue to exist for at least the
31
+ # next 20 seconds
32
+ timer=0
33
+ while [ true ]; do
34
+ if [[ $timer -eq 20 ]]; then
35
+ break
36
+ fi
37
+
38
+ current_rb=( $(oc get rolebindings -n "${NAMESPACE}" | awk '/gitops/ {print $1}' | sort) )
39
+ if [[ "${current_rb[@]}" != "${expected_rb[@]}" ]]; then
40
+ echo "current role bindings have changed, now not equal to expected role bindings"
41
+ echo "current role bindings: ${current_rb[*]}"
42
+ echo "expected role bindings: ${expected_rb[*]}"
43
+ exit 1
44
+ fi
45
+
46
+ timer=$((timer+5))
47
+ sleep 5
48
+ done
0 commit comments