Skip to content

Commit

Permalink
Merge pull request kosmos-io#836 from lyzuiui/main_kubenest
Browse files Browse the repository at this point in the history
Cherry-Pick: Optimize e2e test scripts
  • Loading branch information
duanmengkk authored Feb 17, 2025
2 parents 2273d9d + 4038e4f commit 71adfbf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions hack/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ function create_cluster() {
docker exec ${clustername}-control-plane /bin/sh -c "cat /etc/kubernetes/admin.conf" | sed -e "s|${clustername}-control-plane|$dockerip|g" -e "/certificate-authority-data:/d" -e "5s/^/ insecure-skip-tls-verify: true\n/" -e "w ${CLUSTER_DIR}/kubeconfig-nodeIp"

kubectl --kubeconfig $CLUSTER_DIR/kubeconfig create -f "$CURRENT/calicooperator/tigera-operator.yaml" || $("${REUSE}" -eq "true")
kind export kubeconfig --name "$clustername"
util::wait_for_crd installations.operator.tigera.io
#kind export kubeconfig --name "$clustername"
util::wait_for_crd --kubeconfig $CLUSTER_DIR/kubeconfig installations.operator.tigera.io
kubectl --kubeconfig $CLUSTER_DIR/kubeconfig apply -f "${CLUSTER_DIR}"/calicoconfig
echo "create cluster ${clustername} success"
echo "wait all node ready"
Expand Down
16 changes: 15 additions & 1 deletion hack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,25 @@ function util::wait_for_crd() {
local crd_names=("$@")
local timeout=500
local count=0
local kubeconfig=""

while [[ $# -gt 0 ]]; do
case "$1" in
--kubeconfig)
kubeconfig="$2"
shift 2
;;
*)
crd_names+=("$1")
shift
;;
esac
done

local end=$((SECONDS+timeout))
while [ $SECONDS -lt $end ]; do
for crd_name in "${crd_names[@]}"; do
if kubectl get crd "$crd_name"; then
if kubectl ${kubeconfig:+--kubeconfig="$kubeconfig"} get crd "$crd_name" >/dev/null 2>&1; then
echo "CRD $crd_name has been stored successfully."
# delete crd from waiting list
count=$(($count+1))
Expand Down

0 comments on commit 71adfbf

Please sign in to comment.