diff --git a/test/environments/multiple.env.sh b/test/environments/multiple.env.sh index 4865c9636..8b0afc467 100755 --- a/test/environments/multiple.env.sh +++ b/test/environments/multiple.env.sh @@ -52,4 +52,9 @@ done "${ROOT}/hack/gen-clusterconfigs.sh" +if ! check_clusterpedia_apiserver; then + echo "clusterpedia apiserver is not ready" + exit 1 +fi + "${cases}" diff --git a/test/environments/single.env.sh b/test/environments/single.env.sh index 895e565e6..5c2cf8b09 100755 --- a/test/environments/single.env.sh +++ b/test/environments/single.env.sh @@ -31,4 +31,9 @@ create_data_plane ${data_plane_name} ${version} || { "${ROOT}/hack/gen-clusterconfigs.sh" +if ! check_clusterpedia_apiserver; then + echo "clusterpedia apiserver is not ready" + exit 1 +fi + "${cases}" diff --git a/test/helper.sh b/test/helper.sh index 579002bff..1e651ac4f 100755 --- a/test/helper.sh +++ b/test/helper.sh @@ -162,3 +162,15 @@ function delete_data_plane() { kwokctl export logs --name "${name}" "${ROOT}/test/logs/kwok/${name}" kwokctl delete cluster --name "${name}" } + +# check if the apiserver in the control plane is ready +function check_clusterpedia_apiserver() { + for i in {1..3} + do + if kubectl get --raw="/apis/clusterpedia.io/v1beta1/">/dev/null; then # only print error messages of the kubectl + return 0 + fi + sleep 10 + done + return 1 +}