Skip to content

Commit

Permalink
Merge pull request #437 from village-way/main
Browse files Browse the repository at this point in the history
e2e: use latest tag for e2e test and delete 0.2.0 tag
  • Loading branch information
duanmengkk authored Mar 18, 2024
2 parents e5028c1 + e338efd commit e746b64
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
15 changes: 6 additions & 9 deletions hack/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ set -o errexit
set -o nounset
set -o pipefail

HOST_CLUSTER_NAME="cluster-host"
CURRENT="$(dirname "${BASH_SOURCE[0]}")"
ROOT=$(dirname "${BASH_SOURCE[0]}")/..
# true: when cluster is exist, reuse exist one!
REUSE=${REUSE:-false}
#VERSION=${VERSION:-latest}
VERSION="v0.2.0"
VERSION=${VERSION:-latest}

CN_ZONE=${CN_ZONE:-false}
source "$(dirname "${BASH_SOURCE[0]}")/util.sh"
Expand Down Expand Up @@ -86,7 +84,6 @@ function create_cluster() {
CLUSTER_DIR="${ROOT}/environments/${clustername}"
mkdir -p "${CLUSTER_DIR}"

echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
echo "$CLUSTER_DIR"

ipFamily=ipv4
Expand Down Expand Up @@ -124,7 +121,7 @@ function create_cluster() {
kind load docker-image calico/typha:v3.25.0 --name $clustername
kind load docker-image quay.io/tigera/operator:v1.29.0 --name $clustername

kubectl taint nodes --all node-role.kubernetes.io/control-plane- || true
kubectl --kubeconfig $CLUSTER_DIR/kubeconfig taint nodes --all node-role.kubernetes.io/control-plane- || true

# prepare external kubeconfig
kind get kubeconfig --name "${clustername}" > "${CLUSTER_DIR}/kubeconfig"
Expand All @@ -139,9 +136,9 @@ function create_cluster() {
echo "create cluster ${clustername} success"
echo "wait all node ready"
# N = nodeNum + 1
N=$(kubectl get nodes --no-headers | wc -l)
N=$(kubectl --kubeconfig $CLUSTER_DIR/kubeconfig get nodes --no-headers | wc -l)
util::wait_for_condition "all nodes are ready" \
"kubectl get nodes | awk 'NR>1 {if (\$2 != \"Ready\") exit 1; }' && [ \$(kubectl get nodes --no-headers | wc -l) -eq ${N} ]" \
"kubectl --kubeconfig $CLUSTER_DIR/kubeconfig get nodes | awk 'NR>1 {if (\$2 != \"Ready\") exit 1; }' && [ \$(kubectl --kubeconfig $CLUSTER_DIR/kubeconfig get nodes --no-headers | wc -l) -eq ${N} ]" \
300
echo "all node ready"
}
Expand Down Expand Up @@ -186,7 +183,7 @@ function join_cluster_by_ctl() {
local member_cluster=$2
local hostClusterDir=$3
local memberClusterDir=$4
kosmosctl join cluster --name "$member_cluster" --host-kubeconfig "$hostClusterDir/kubeconfig" --kubeconfig "$memberClusterDir/kubeconfig" --inner-kubeconfig "$memberClusterDir/kubeconfig-nodeIp" --enable-all --version ${VERSION}
"${ROOT}"/_output/bin/"$os"/"$arch"/kosmosctl join cluster --name "$member_cluster" --host-kubeconfig "$hostClusterDir/kubeconfig" --kubeconfig "$memberClusterDir/kubeconfig" --inner-kubeconfig "$memberClusterDir/kubeconfig-nodeIp" --enable-all --version ${VERSION}
}

function addTaint() {
Expand All @@ -207,7 +204,7 @@ function deploy_cluster_by_ctl() {
load_cluster_images "$clustername"
CLUSTER_DIR="${ROOT}/environments/${clustername}"

kosmosctl install --version ${VERSION} --kubeconfig "${kubeconfig}" --inner-kubeconfig "${innerKubeconfig}"
"${ROOT}"/_output/bin/"$os"/"$arch"/kosmosctl install --version ${VERSION} --kubeconfig "${kubeconfig}" --inner-kubeconfig "${innerKubeconfig}"

util::wait_for_condition "kosmos ${clustername} clustertree are ready" \
"kubectl --kubeconfig $CLUSTER_DIR/kubeconfig -n kosmos-system get deploy clustertree-cluster-manager -o jsonpath='{.status.replicas}{\" \"}{.status.readyReplicas}{\"\n\"}' | awk '{if (\$1 == \$2 && \$1 > 0) exit 0; else exit 1}'" \
Expand Down
10 changes: 5 additions & 5 deletions hack/rune2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ wait
kubectl --kubeconfig "${REPO_ROOT}/environments/${HOST_CLUSTER_NAME}/kubeconfig" apply -f "${REPO_ROOT}"/test/e2e/deploy/nginx
util::wait_for_condition "nginx are ready" \
"kubectl --kubeconfig ${REPO_ROOT}/environments/${HOST_CLUSTER_NAME}/kubeconfig -n ${E2E_NAMESPACE} get pod -l app=nginx | awk 'NR>1 {if (\$3 == \"Running\") exit 0; else exit 1; }'" \
120
300

util::wait_for_condition "mcs of member1 are ready" \
"[ \$(kubectl --kubeconfig ${REPO_ROOT}/environments/${MEMBER1_CLUSTER_NAME}/kubeconfig -n ${E2E_NAMESPACE} get endpointslices.discovery.k8s.io --no-headers -l kubernetes.io\/service-name=nginx-service | wc -l) -eq 1 ] " \
120
300

util::wait_for_condition "mcs of member2 are ready" \
"[ \$(kubectl --kubeconfig ${REPO_ROOT}/environments/${MEMBER2_CLUSTER_NAME}/kubeconfig -n ${E2E_NAMESPACE} get endpointslices.discovery.k8s.io --no-headers -l kubernetes.io\/service-name=nginx-service | wc -l) -eq 1 ] " \
120
300

util::wait_for_condition "mcs of member3 are ready" \
"[ \$(kubectl --kubeconfig ${REPO_ROOT}/environments/${MEMBER3_CLUSTER_NAME}/kubeconfig -n ${E2E_NAMESPACE} get endpointslices.discovery.k8s.io --no-headers -l kubernetes.io\/service-name=nginx-service | wc -l) -eq 1 ] " \
120
300

nginx_service_ip=$(kubectl -n kosmos-e2e get svc nginx-service -o=jsonpath='{.spec.clusterIP}')
nginx_service_ip=$(kubectl --kubeconfig ${REPO_ROOT}/environments/${HOST_CLUSTER_NAME}/kubeconfig -n kosmos-e2e get svc nginx-service -o=jsonpath='{.spec.clusterIP}')

# e2e test for access nginx service
sleep 100 && docker exec -i ${HOST_CLUSTER_NAME}-control-plane sh -c "curl -sSf -m 5 ${nginx_service_ip}:80" && echo "success" || {
Expand Down

0 comments on commit e746b64

Please sign in to comment.