From 584b3f403561a587d4c137b91efd2eddacbb5629 Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Thu, 28 Dec 2023 12:37:53 +0800 Subject: [PATCH 01/14] add finalizer for mcs and fix some bug Signed-off-by: duanmengkk --- hack/rune2e.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/hack/rune2e.sh b/hack/rune2e.sh index 2f2e1e9cd..aec7daf55 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -44,9 +44,21 @@ util::wait_for_condition "mysql operator are ready" \ #kubectl --context="kind-cluster-host" exec -it /bin/sh -c kubectl --context="kind-${HOST_CLUSTER_NAME}" apply -f "${ROOT}"/../test/e2e/deploy/cr -util::wait_for_condition "mysql cr are ready" \ - "[ \$(kubectl get pods -n kosmos-e2e --field-selector=status.phase=Running --no-headers | wc -l) -eq 2 ]" \ - 1200 +sleep 480 +kubectl --context=kind-${HOST_CLUSTER_NAME} get pods -n kosmos-e2e + +echo "集群2 servicimport" +kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n kosmos-e2e get serviceimports +echo "集群1 servicimport" +kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get serviceimports +echo "集群2 esp" +kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n kosmos-e2e get endpointslices +echo "集群1 esp" +kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get endpointslices + +#util::wait_for_condition "mysql cr are ready" \ +# "[ \$(kubectl get pods -n kosmos-e2e --field-selector=status.phase=Running --no-headers | wc -l) -eq 2 ]" \ +# 1200 echo "E2e test of mysql-operator success" From 578f1352136b17f790ea73c3fc21cba7667c02b3 Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Thu, 28 Dec 2023 13:12:30 +0800 Subject: [PATCH 02/14] add finalizer for mcs and fix some bug Signed-off-by: duanmengkk --- hack/rune2e.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hack/rune2e.sh b/hack/rune2e.sh index aec7daf55..78c9b3139 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -44,7 +44,7 @@ util::wait_for_condition "mysql operator are ready" \ #kubectl --context="kind-cluster-host" exec -it /bin/sh -c kubectl --context="kind-${HOST_CLUSTER_NAME}" apply -f "${ROOT}"/../test/e2e/deploy/cr -sleep 480 +sleep 240 kubectl --context=kind-${HOST_CLUSTER_NAME} get pods -n kosmos-e2e echo "集群2 servicimport" @@ -55,6 +55,8 @@ echo "集群2 esp" kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n kosmos-e2e get endpointslices echo "集群1 esp" kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get endpointslices +echo "主集群 esp" +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get endpointslices #util::wait_for_condition "mysql cr are ready" \ # "[ \$(kubectl get pods -n kosmos-e2e --field-selector=status.phase=Running --no-headers | wc -l) -eq 2 ]" \ From cf5d4b89674451eeb3a8e22c0e913de24e413926 Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Thu, 28 Dec 2023 13:38:38 +0800 Subject: [PATCH 03/14] add finalizer for mcs and fix some bug Signed-off-by: duanmengkk --- hack/rune2e.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/hack/rune2e.sh b/hack/rune2e.sh index 78c9b3139..94d7a0a76 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -7,7 +7,6 @@ set -o pipefail KUBECONFIG_PATH=${KUBECONFIG_PATH:-"${HOME}/.kube"} export KUBECONFIG=$KUBECONFIG_PATH/"config" - E2E_NAMESPACE="kosmos-e2e" HOST_CLUSTER_NAME="cluster-host" MEMBER1_CLUSTER_NAME="cluster-member1" @@ -33,7 +32,10 @@ util::wait_for_condition "mcs of member2 are ready" \ nginx_service_ip=$(kubectl -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" || { echo "fail"; exit 1; } +sleep 100 && docker exec -i ${HOST_CLUSTER_NAME}-control-plane sh -c "curl -sSf -m 5 ${nginx_service_ip}:80" && echo "success" || { + echo "fail" + exit 1 +} # e2e for mysql-operator kubectl --context="kind-cluster-host" apply -f "${ROOT}"/../test/e2e/deploy/mysql-operator @@ -45,8 +47,10 @@ util::wait_for_condition "mysql operator are ready" \ kubectl --context="kind-${HOST_CLUSTER_NAME}" apply -f "${ROOT}"/../test/e2e/deploy/cr sleep 240 -kubectl --context=kind-${HOST_CLUSTER_NAME} get pods -n kosmos-e2e - +echo "主集群e2e pod" +kubectl --context=kind-${HOST_CLUSTER_NAME} get pods -n kosmos-e2e -o wide +echo "主集群所有 pod" +kubectl --context=kind-${HOST_CLUSTER_NAME} get pods -A echo "集群2 servicimport" kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n kosmos-e2e get serviceimports echo "集群1 servicimport" @@ -57,7 +61,10 @@ echo "集群1 esp" kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get endpointslices echo "主集群 esp" kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get endpointslices - +echo "主集群 mysql init容器日志" +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init +echo "主集群 mysql mysql容器日志" +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 mysql #util::wait_for_condition "mysql cr are ready" \ # "[ \$(kubectl get pods -n kosmos-e2e --field-selector=status.phase=Running --no-headers | wc -l) -eq 2 ]" \ # 1200 From a58d55e843a19aa0a5fbdfb0f566aa04128b6954 Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Thu, 28 Dec 2023 14:41:23 +0800 Subject: [PATCH 04/14] add finalizer for mcs and fix some bug Signed-off-by: duanmengkk --- hack/rune2e.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hack/rune2e.sh b/hack/rune2e.sh index 94d7a0a76..440b5d55b 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -61,6 +61,20 @@ echo "集群1 esp" kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get endpointslices echo "主集群 esp" kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get endpointslices + +node=$(kubectl --context kind-cluster-host -n kosmos-e2e get pod -o wide | grep mysql-cluster-e2e-mysql-0 | awk '{print $9}') +if node="kosmos-cluster-member2"; then + echo "主集群 mysql init容器日志" + kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init + echo "主集群 mysql mysql容器日志" + kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 mysql +else + echo "主集群 mysql init容器日志" + kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init + echo "主集群 mysql mysql容器日志" + kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 mysql +fi + echo "主集群 mysql init容器日志" kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init echo "主集群 mysql mysql容器日志" From e3bef3fe6d08f5ef6dcfd0311d1f1eeb64b45c51 Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Thu, 28 Dec 2023 15:12:49 +0800 Subject: [PATCH 05/14] add finalizer for mcs and fix some bug Signed-off-by: duanmengkk --- hack/rune2e.sh | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/hack/rune2e.sh b/hack/rune2e.sh index 440b5d55b..76104b322 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -62,18 +62,10 @@ kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get endpointslices echo "主集群 esp" kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get endpointslices -node=$(kubectl --context kind-cluster-host -n kosmos-e2e get pod -o wide | grep mysql-cluster-e2e-mysql-0 | awk '{print $9}') -if node="kosmos-cluster-member2"; then - echo "主集群 mysql init容器日志" - kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init - echo "主集群 mysql mysql容器日志" - kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 mysql -else - echo "主集群 mysql init容器日志" - kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init - echo "主集群 mysql mysql容器日志" - kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 mysql -fi +echo "主集群 mysql init容器日志" +kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init +echo "主集群 mysql mysql容器日志" +kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 mysql echo "主集群 mysql init容器日志" kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init From d215206bda3912284a169001cb73d13f94e2cea5 Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Thu, 28 Dec 2023 17:23:19 +0800 Subject: [PATCH 06/14] fix Signed-off-by: duanmengkk --- hack/cluster.sh | 2 +- hack/rune2e.sh | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hack/cluster.sh b/hack/cluster.sh index 2de67ee86..cb2565e5d 100755 --- a/hack/cluster.sh +++ b/hack/cluster.sh @@ -219,7 +219,7 @@ function deploy_cluster_by_ctl() { docker exec ${clustername}-control-plane /bin/sh -c "mv /etc/kubernetes/manifests/kube-scheduler.yaml /etc/kubernetes" # add the args for e2e test case of mysql-operator - kubectl --context="kind-${clustername}" -n kosmos-system patch deployment clustertree-cluster-manager --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "--auto-mcs-prefix=kosmos-e2e"}]' + kubectl --context="kind-${clustername}" -n kosmos-system patch deployment clustertree-cluster-manager --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "--auto-mcs-prefix=kosmos-e2e2"}]' util::wait_for_condition "kosmos clustertree are ready" \ "kubectl --context="kind-${clustername}" -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}'" \ diff --git a/hack/rune2e.sh b/hack/rune2e.sh index 76104b322..201f048ab 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -62,15 +62,16 @@ kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get endpointslices echo "主集群 esp" kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get endpointslices -echo "主集群 mysql init容器日志" +echo "集群1 mysql init容器日志" kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init -echo "主集群 mysql mysql容器日志" +echo "集群1 mysql mysql容器日志" kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 mysql +echo "集群1 mysql init容器旧日志" +kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs -p mysql-cluster-e2e-mysql-0 init +echo "集群1 mysql mysql容器旧日志" +kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs -p mysql-cluster-e2e-mysql-0 mysql + -echo "主集群 mysql init容器日志" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init -echo "主集群 mysql mysql容器日志" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 mysql #util::wait_for_condition "mysql cr are ready" \ # "[ \$(kubectl get pods -n kosmos-e2e --field-selector=status.phase=Running --no-headers | wc -l) -eq 2 ]" \ # 1200 From 9f683deeb229c859973fe66a360670cac33cd097 Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Thu, 28 Dec 2023 17:59:15 +0800 Subject: [PATCH 07/14] add shell Signed-off-by: duanmengkk --- hack/rune2e.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/hack/rune2e.sh b/hack/rune2e.sh index 201f048ab..6c179ef34 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -16,26 +16,26 @@ ROOT="$(dirname "${BASH_SOURCE[0]}")" source "${ROOT}/util.sh" # e2e for nginx and mcs -kubectl --context="kind-${HOST_CLUSTER_NAME}" apply -f "${ROOT}"/../test/e2e/deploy/nginx -util::wait_for_condition "nginx are ready" \ - "kubectl --context=kind-${HOST_CLUSTER_NAME} -n ${E2E_NAMESPACE} get pod -l app=nginx | awk 'NR>1 {if (\$3 == \"Running\") exit 0; else exit 1; }'" \ - 120 +#kubectl --context="kind-${HOST_CLUSTER_NAME}" apply -f "${ROOT}"/../test/e2e/deploy/nginx +#util::wait_for_condition "nginx are ready" \ +# "kubectl --context=kind-${HOST_CLUSTER_NAME} -n ${E2E_NAMESPACE} get pod -l app=nginx | awk 'NR>1 {if (\$3 == \"Running\") exit 0; else exit 1; }'" \ +# 120 -util::wait_for_condition "mcs of member1 are ready" \ - "[ \$(kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n ${E2E_NAMESPACE} get endpointslices.discovery.k8s.io --no-headers -l kubernetes.io\/service-name=nginx-service | wc -l) -eq 1 ] " \ - 120 +#util::wait_for_condition "mcs of member1 are ready" \ +# "[ \$(kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n ${E2E_NAMESPACE} get endpointslices.discovery.k8s.io --no-headers -l kubernetes.io\/service-name=nginx-service | wc -l) -eq 1 ] " \ +# 120 -util::wait_for_condition "mcs of member2 are ready" \ - "[ \$(kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n ${E2E_NAMESPACE} get endpointslices.discovery.k8s.io --no-headers -l kubernetes.io\/service-name=nginx-service | wc -l) -eq 1 ] " \ - 120 +#util::wait_for_condition "mcs of member2 are ready" \ +# "[ \$(kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n ${E2E_NAMESPACE} get endpointslices.discovery.k8s.io --no-headers -l kubernetes.io\/service-name=nginx-service | wc -l) -eq 1 ] " \ +# 120 -nginx_service_ip=$(kubectl -n kosmos-e2e get svc nginx-service -o=jsonpath='{.spec.clusterIP}') +#nginx_service_ip=$(kubectl -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" || { - echo "fail" - exit 1 -} +#sleep 100 && docker exec -i ${HOST_CLUSTER_NAME}-control-plane sh -c "curl -sSf -m 5 ${nginx_service_ip}:80" && echo "success" || { +# echo "fail" +# exit 1 +#} # e2e for mysql-operator kubectl --context="kind-cluster-host" apply -f "${ROOT}"/../test/e2e/deploy/mysql-operator @@ -82,7 +82,7 @@ echo "E2e test of mysql-operator success" GO111MODULE=on go install github.com/onsi/ginkgo/v2/ginkgo set +e -ginkgo -v --race --trace --fail-fast -p --randomize-all ./test/e2e/ -- +#ginkgo -v --race --trace --fail-fast -p --randomize-all ./test/e2e/ -- TESTING_RESULT=$? LOG_PATH=$ROOT/../e2e-logs From fa86936e5bbb7f1505609c060ba709d7cbeea760 Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Thu, 28 Dec 2023 20:59:55 +0800 Subject: [PATCH 08/14] fix Signed-off-by: duanmengkk --- hack/rune2e.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hack/rune2e.sh b/hack/rune2e.sh index 6c179ef34..f0a6c9d55 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -42,7 +42,7 @@ kubectl --context="kind-cluster-host" apply -f "${ROOT}"/../test/e2e/deploy/mysq util::wait_for_condition "mysql operator are ready" \ "kubectl --context=kind-${HOST_CLUSTER_NAME} get pods -n mysql-operator mysql-operator-0 | awk 'NR>1 {if (\$3 == \"Running\") exit 0; else exit 1; }'" \ 300 - +kubectl --context=kind-${HOST_CLUSTER_NAME} create ns kosmos-e2e #kubectl --context="kind-cluster-host" exec -it /bin/sh -c kubectl --context="kind-${HOST_CLUSTER_NAME}" apply -f "${ROOT}"/../test/e2e/deploy/cr @@ -71,7 +71,6 @@ kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs -p mysql-clust echo "集群1 mysql mysql容器旧日志" kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs -p mysql-cluster-e2e-mysql-0 mysql - #util::wait_for_condition "mysql cr are ready" \ # "[ \$(kubectl get pods -n kosmos-e2e --field-selector=status.phase=Running --no-headers | wc -l) -eq 2 ]" \ # 1200 From 9e947d2b537b3843750f46756eabc183dd65561d Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Tue, 2 Jan 2024 10:43:28 +0800 Subject: [PATCH 09/14] fix Signed-off-by: duanmengkk --- hack/rune2e.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hack/rune2e.sh b/hack/rune2e.sh index f0a6c9d55..c2128a1f2 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -66,6 +66,15 @@ echo "集群1 mysql init容器日志" kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init echo "集群1 mysql mysql容器日志" kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 mysql + +echo "集群1 mysql pvc" +kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get pvc +echo "集群1 mysql pv" +kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get pv + +echo "集群1 所有 pod" +kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get pvc + echo "集群1 mysql init容器旧日志" kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs -p mysql-cluster-e2e-mysql-0 init echo "集群1 mysql mysql容器旧日志" From badaae99b52f014bf0b9ada3b36a47739a7beed8 Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Tue, 2 Jan 2024 13:38:25 +0800 Subject: [PATCH 10/14] fix Signed-off-by: duanmengkk --- test/e2e/deploy/cr/cluster-cr.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/e2e/deploy/cr/cluster-cr.yaml b/test/e2e/deploy/cr/cluster-cr.yaml index fb29e252a..a170ba3b8 100644 --- a/test/e2e/deploy/cr/cluster-cr.yaml +++ b/test/e2e/deploy/cr/cluster-cr.yaml @@ -4,7 +4,7 @@ metadata: name: mysql-cluster-e2e namespace: kosmos-e2e spec: - replicas: 2 + replicas: 1 secretName: my-secret ## For setting custom docker image or specifying mysql version @@ -78,7 +78,8 @@ spec: - key: kubernetes.io/hostname operator: NotIn values: - - cluster-host-control-plane + - kosmos-cluster-member1 + - kosmos-cluster-member2 podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: From 5210989205d325733953611d0bcf5d922781a2a0 Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Wed, 3 Jan 2024 10:58:02 +0800 Subject: [PATCH 11/14] fix Signed-off-by: duanmengkk --- hack/rune2e.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hack/rune2e.sh b/hack/rune2e.sh index c2128a1f2..1187143a0 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -52,33 +52,33 @@ kubectl --context=kind-${HOST_CLUSTER_NAME} get pods -n kosmos-e2e -o wide echo "主集群所有 pod" kubectl --context=kind-${HOST_CLUSTER_NAME} get pods -A echo "集群2 servicimport" -kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n kosmos-e2e get serviceimports +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get serviceimports echo "集群1 servicimport" -kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get serviceimports +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get serviceimports echo "集群2 esp" -kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n kosmos-e2e get endpointslices +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get endpointslices echo "集群1 esp" -kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get endpointslices +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get endpointslices echo "主集群 esp" kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get endpointslices echo "集群1 mysql init容器日志" -kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init echo "集群1 mysql mysql容器日志" -kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 mysql +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 mysql echo "集群1 mysql pvc" -kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get pvc +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get pvc echo "集群1 mysql pv" -kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get pv +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get pv echo "集群1 所有 pod" -kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e get pvc +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get pvc echo "集群1 mysql init容器旧日志" -kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs -p mysql-cluster-e2e-mysql-0 init +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs -p mysql-cluster-e2e-mysql-0 init echo "集群1 mysql mysql容器旧日志" -kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n kosmos-e2e logs -p mysql-cluster-e2e-mysql-0 mysql +kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs -p mysql-cluster-e2e-mysql-0 mysql #util::wait_for_condition "mysql cr are ready" \ # "[ \$(kubectl get pods -n kosmos-e2e --field-selector=status.phase=Running --no-headers | wc -l) -eq 2 ]" \ From c7830965f0066f1eba2fff8cac28a9850ce635fc Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Fri, 5 Jan 2024 09:17:56 +0800 Subject: [PATCH 12/14] fix Signed-off-by: duanmengkk --- hack/rune2e.sh | 82 +++++++++--------------------- test/e2e/deploy/cr/cluster-cr.yaml | 5 +- 2 files changed, 25 insertions(+), 62 deletions(-) diff --git a/hack/rune2e.sh b/hack/rune2e.sh index 1187143a0..a16919132 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -16,75 +16,39 @@ ROOT="$(dirname "${BASH_SOURCE[0]}")" source "${ROOT}/util.sh" # e2e for nginx and mcs -#kubectl --context="kind-${HOST_CLUSTER_NAME}" apply -f "${ROOT}"/../test/e2e/deploy/nginx -#util::wait_for_condition "nginx are ready" \ -# "kubectl --context=kind-${HOST_CLUSTER_NAME} -n ${E2E_NAMESPACE} get pod -l app=nginx | awk 'NR>1 {if (\$3 == \"Running\") exit 0; else exit 1; }'" \ -# 120 +kubectl --context="kind-${HOST_CLUSTER_NAME}" apply -f "${ROOT}"/../test/e2e/deploy/nginx +util::wait_for_condition "nginx are ready" \ + "kubectl --context=kind-${HOST_CLUSTER_NAME} -n ${E2E_NAMESPACE} get pod -l app=nginx | awk 'NR>1 {if (\$3 == \"Running\") exit 0; else exit 1; }'" \ + 120 -#util::wait_for_condition "mcs of member1 are ready" \ -# "[ \$(kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n ${E2E_NAMESPACE} get endpointslices.discovery.k8s.io --no-headers -l kubernetes.io\/service-name=nginx-service | wc -l) -eq 1 ] " \ -# 120 +util::wait_for_condition "mcs of member1 are ready" \ + "[ \$(kubectl --context=kind-${MEMBER1_CLUSTER_NAME} -n ${E2E_NAMESPACE} get endpointslices.discovery.k8s.io --no-headers -l kubernetes.io\/service-name=nginx-service | wc -l) -eq 1 ] " \ + 120 -#util::wait_for_condition "mcs of member2 are ready" \ -# "[ \$(kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n ${E2E_NAMESPACE} get endpointslices.discovery.k8s.io --no-headers -l kubernetes.io\/service-name=nginx-service | wc -l) -eq 1 ] " \ -# 120 +util::wait_for_condition "mcs of member2 are ready" \ + "[ \$(kubectl --context=kind-${MEMBER2_CLUSTER_NAME} -n ${E2E_NAMESPACE} get endpointslices.discovery.k8s.io --no-headers -l kubernetes.io\/service-name=nginx-service | wc -l) -eq 1 ] " \ + 120 -#nginx_service_ip=$(kubectl -n kosmos-e2e get svc nginx-service -o=jsonpath='{.spec.clusterIP}') +nginx_service_ip=$(kubectl -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" || { -# echo "fail" -# exit 1 -#} - -# e2e for mysql-operator -kubectl --context="kind-cluster-host" apply -f "${ROOT}"/../test/e2e/deploy/mysql-operator -util::wait_for_condition "mysql operator are ready" \ - "kubectl --context=kind-${HOST_CLUSTER_NAME} get pods -n mysql-operator mysql-operator-0 | awk 'NR>1 {if (\$3 == \"Running\") exit 0; else exit 1; }'" \ - 300 -kubectl --context=kind-${HOST_CLUSTER_NAME} create ns kosmos-e2e -#kubectl --context="kind-cluster-host" exec -it /bin/sh -c -kubectl --context="kind-${HOST_CLUSTER_NAME}" apply -f "${ROOT}"/../test/e2e/deploy/cr - -sleep 240 -echo "主集群e2e pod" -kubectl --context=kind-${HOST_CLUSTER_NAME} get pods -n kosmos-e2e -o wide -echo "主集群所有 pod" -kubectl --context=kind-${HOST_CLUSTER_NAME} get pods -A -echo "集群2 servicimport" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get serviceimports -echo "集群1 servicimport" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get serviceimports -echo "集群2 esp" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get endpointslices -echo "集群1 esp" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get endpointslices -echo "主集群 esp" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get endpointslices - -echo "集群1 mysql init容器日志" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 init -echo "集群1 mysql mysql容器日志" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs mysql-cluster-e2e-mysql-0 mysql - -echo "集群1 mysql pvc" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get pvc -echo "集群1 mysql pv" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get pv - -echo "集群1 所有 pod" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e get pvc - -echo "集群1 mysql init容器旧日志" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs -p mysql-cluster-e2e-mysql-0 init -echo "集群1 mysql mysql容器旧日志" -kubectl --context=kind-${HOST_CLUSTER_NAME} -n kosmos-e2e logs -p mysql-cluster-e2e-mysql-0 mysql +sleep 100 && docker exec -i ${HOST_CLUSTER_NAME}-control-plane sh -c "curl -sSf -m 5 ${nginx_service_ip}:80" && echo "success" || { + echo "fail" + exit 1 +} + +## e2e for mysql-operator +#kubectl --context="kind-cluster-host" apply -f "${ROOT}"/../test/e2e/deploy/mysql-operator +#util::wait_for_condition "mysql operator are ready" \ +# "kubectl --context=kind-${HOST_CLUSTER_NAME} get pods -n mysql-operator mysql-operator-0 | awk 'NR>1 {if (\$3 == \"Running\") exit 0; else exit 1; }'" \ +# 300 +#kubectl --context="kind-${HOST_CLUSTER_NAME}" apply -f "${ROOT}"/../test/e2e/deploy/cr #util::wait_for_condition "mysql cr are ready" \ # "[ \$(kubectl get pods -n kosmos-e2e --field-selector=status.phase=Running --no-headers | wc -l) -eq 2 ]" \ # 1200 -echo "E2e test of mysql-operator success" +#echo "E2e test of mysql-operator success" # Install ginkgo GO111MODULE=on go install github.com/onsi/ginkgo/v2/ginkgo diff --git a/test/e2e/deploy/cr/cluster-cr.yaml b/test/e2e/deploy/cr/cluster-cr.yaml index a170ba3b8..fb29e252a 100644 --- a/test/e2e/deploy/cr/cluster-cr.yaml +++ b/test/e2e/deploy/cr/cluster-cr.yaml @@ -4,7 +4,7 @@ metadata: name: mysql-cluster-e2e namespace: kosmos-e2e spec: - replicas: 1 + replicas: 2 secretName: my-secret ## For setting custom docker image or specifying mysql version @@ -78,8 +78,7 @@ spec: - key: kubernetes.io/hostname operator: NotIn values: - - kosmos-cluster-member1 - - kosmos-cluster-member2 + - cluster-host-control-plane podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: From 74a0db8f24d5731d15d40849327a6832d32effd4 Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Fri, 5 Jan 2024 15:21:23 +0800 Subject: [PATCH 13/14] fix Signed-off-by: duanmengkk --- hack/cluster.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/cluster.sh b/hack/cluster.sh index cb2565e5d..2de67ee86 100755 --- a/hack/cluster.sh +++ b/hack/cluster.sh @@ -219,7 +219,7 @@ function deploy_cluster_by_ctl() { docker exec ${clustername}-control-plane /bin/sh -c "mv /etc/kubernetes/manifests/kube-scheduler.yaml /etc/kubernetes" # add the args for e2e test case of mysql-operator - kubectl --context="kind-${clustername}" -n kosmos-system patch deployment clustertree-cluster-manager --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "--auto-mcs-prefix=kosmos-e2e2"}]' + kubectl --context="kind-${clustername}" -n kosmos-system patch deployment clustertree-cluster-manager --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "--auto-mcs-prefix=kosmos-e2e"}]' util::wait_for_condition "kosmos clustertree are ready" \ "kubectl --context="kind-${clustername}" -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}'" \ From 66aeca08de827e2bb57dac344e012e909f8ef7aa Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Fri, 5 Jan 2024 15:24:56 +0800 Subject: [PATCH 14/14] fix Signed-off-by: duanmengkk --- hack/rune2e.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/rune2e.sh b/hack/rune2e.sh index a16919132..14f526181 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -54,7 +54,7 @@ sleep 100 && docker exec -i ${HOST_CLUSTER_NAME}-control-plane sh -c "curl -sSf GO111MODULE=on go install github.com/onsi/ginkgo/v2/ginkgo set +e -#ginkgo -v --race --trace --fail-fast -p --randomize-all ./test/e2e/ -- +ginkgo -v --race --trace --fail-fast -p --randomize-all ./test/e2e/ -- TESTING_RESULT=$? LOG_PATH=$ROOT/../e2e-logs