Skip to content

Commit cbf8ec4

Browse files
committed
fix: deflake run_kubectl_apply_tests
Signed-off-by: knight42 <[email protected]>
1 parent ec560b9 commit cbf8ec4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/cmd/apply.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,18 @@ run_kubectl_server_side_apply_tests() {
444444
}
445445
__EOF__
446446

447+
# Ensure the API server has recognized and started serving the associated CR API
448+
local tries=5
449+
for i in $(seq 1 $tries); do
450+
local output
451+
output=$(kubectl "${kube_flags[@]:?}" api-resources --api-group mygroup.example.com -oname)
452+
if kube::test::if_has_string "$output" resources.mygroup.example.com; then
453+
break
454+
fi
455+
echo "${i}: Waiting for CR API to be available"
456+
sleep "$i"
457+
done
458+
447459
# Dry-run create the CR
448460
kubectl "${kube_flags[@]:?}" apply --server-side --dry-run=server -f hack/testdata/CRD/resource.yaml "${kube_flags[@]:?}"
449461
# Make sure that the CR doesn't exist

0 commit comments

Comments
 (0)