diff --git a/hack/cluster.sh b/hack/cluster.sh index 9fdab3cb4..b3eab7d62 100755 --- a/hack/cluster.sh +++ b/hack/cluster.sh @@ -29,7 +29,7 @@ function prepare_test_image() { docker pull bitpoke/mysql-operator-orchestrator:v0.6.3 docker pull bitpoke/mysql-operator:v0.6.3 docker pull bitpoke/mysql-operator-sidecar-5.7:v0.6.3 - docker pull nginx + docker pull nginx:1.27.3 docker pull percona:5.7 docker pull prom/mysqld-exporter:v0.13.0 else @@ -37,14 +37,11 @@ function prepare_test_image() { docker pull bitpoke/mysql-operator-orchestrator:v0.6.3 docker pull bitpoke/mysql-operator:v0.6.3 docker pull bitpoke/mysql-operator-sidecar-5.7:v0.6.3 - docker pull docker.m.daocloud.io/nginx + docker pull docker.m.daocloud.io/nginx:1.27.3 docker pull docker.m.daocloud.io/percona:5.7 docker pull docker.m.daocloud.io/prom/mysqld-exporter:v0.13.0 - docker tag docker.m.daocloud.io/bitpoke/mysql-operator-orchestrator:v0.6.3 bitpoke/mysql-operator-orchestrator:v0.6.3 - docker tag docker.m.daocloud.io/bitpoke/mysql-operator:v0.6.3 bitpoke/mysql-operator:v0.6.3 - docker tag docker.m.daocloud.io/bitpoke/mysql-operator-sidecar-5.7:v0.6.3 bitpoke/mysql-operator-sidecar-5.7:v0.6.3 - docker tag docker.m.daocloud.io/nginx nginx + docker tag docker.m.daocloud.io/nginx:1.27.3 nginx:1.27.3 docker tag docker.m.daocloud.io/percona:5.7 percona:5.7 docker tag docker.m.daocloud.io/prom/mysqld-exporter:v0.13.0 prom/mysqld-exporter:v0.13.0 fi @@ -59,30 +56,29 @@ function prepare_e2e_cluster() { kind load docker-image bitpoke/mysql-operator-orchestrator:v0.6.3 --name "${clustername}" kind load docker-image bitpoke/mysql-operator:v0.6.3 --name "${clustername}" kind load docker-image bitpoke/mysql-operator-sidecar-5.7:v0.6.3 --name "${clustername}" - kind load docker-image nginx --name "${clustername}" + kind load docker-image nginx:1.27.3 --name "${clustername}" kind load docker-image percona:5.7 --name "${clustername}" kind load docker-image prom/mysqld-exporter:v0.13.0 --name "${clustername}" kubectl --kubeconfig $CLUSTER_DIR/kubeconfig apply -f "$ROOT"/deploy/crds - - # deploy kosmos-scheduler for e2e test case of mysql-operator - sed -e "s|__VERSION__|$VERSION|g" -e "w ${ROOT}/environments/kosmos-scheduler.yml" "$ROOT"/deploy/scheduler/deployment.yaml - kubectl --kubeconfig $CLUSTER_DIR/kubeconfig apply -f "${ROOT}/environments/kosmos-scheduler.yml" - kubectl --kubeconfig $CLUSTER_DIR/kubeconfig apply -f "$ROOT"/deploy/scheduler/rbac.yaml - - util::wait_for_condition "kosmos scheduler are ready" \ - "kubectl --kubeconfig $CLUSTER_DIR/kubeconfig -n kosmos-system get deploy kosmos-scheduler -o jsonpath='{.status.replicas}{\" \"}{.status.readyReplicas}{\"\n\"}' | awk '{if (\$1 == \$2 && \$1 > 0) exit 0; else exit 1}'" \ - 300 - echo "cluster $clustername deploy kosmos-scheduler success" - - 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 --kubeconfig $CLUSTER_DIR/kubeconfig -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 ${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}'" \ - 300 + if [[ "$clustername" == "cluster-host" ]]; then + # deploy kosmos-scheduler for e2e test case of mysql-operator + sed -e "s|__VERSION__|$VERSION|g" -e "w ${ROOT}/environments/kosmos-scheduler.yml" "$ROOT"/deploy/scheduler/deployment.yaml + kubectl --kubeconfig $CLUSTER_DIR/kubeconfig apply -f "${ROOT}/environments/kosmos-scheduler.yml" + kubectl --kubeconfig $CLUSTER_DIR/kubeconfig apply -f "$ROOT"/deploy/scheduler/rbac.yaml + util::wait_for_condition "kosmos scheduler are ready" \ + "kubectl --kubeconfig $CLUSTER_DIR/kubeconfig -n kosmos-system get deploy kosmos-scheduler -o jsonpath='{.status.replicas}{\" \"}{.status.readyReplicas}{\"\n\"}' | awk '{if (\$1 == \$2 && \$1 > 0) exit 0; else exit 1}'" \ + 300 + echo "cluster $clustername deploy kosmos-scheduler success" + + 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 --kubeconfig $CLUSTER_DIR/kubeconfig -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 ${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}'" \ + 300 + fi } # prepare docker image diff --git a/hack/rune2e.sh b/hack/rune2e.sh index 400fd96da..656cd2364 100755 --- a/hack/rune2e.sh +++ b/hack/rune2e.sh @@ -60,12 +60,19 @@ sleep 100 && docker exec -i ${HOST_CLUSTER_NAME}-control-plane sh -c "curl -sSf # e2e for mysql-operator echo "apply mysql-operator on cluster ${HOST_CLUSTER_NAME} with files in path ${REPO_ROOT}/test/e2e/deploy/mysql-operator" +kubectl --kubeconfig "${REPO_ROOT}/environments/${HOST_CLUSTER_NAME}/kubeconfig" create namespace mysql-operator >/dev/null 2>&1 || true && \ +kubectl --kubeconfig "${REPO_ROOT}/environments/${HOST_CLUSTER_NAME}/kubeconfig" create secret generic mysql-operator-orc \ + --from-literal=TOPOLOGY_PASSWORD="$(openssl rand -base64 10 | tr -dc 'a-zA-Z0-9' | sed 's/^[^a-zA-Z]*//' | head -c 12)" \ + --from-literal=TOPOLOGY_USER="$(openssl rand -base64 10 | tr -dc 'a-zA-Z0-9' | sed 's/^[^a-zA-Z]*//' | head -c 10)" \ + --namespace=mysql-operator kubectl --kubeconfig "${REPO_ROOT}/environments/${HOST_CLUSTER_NAME}/kubeconfig" apply -f "${REPO_ROOT}"/test/e2e/deploy/mysql-operator util::wait_for_condition "mysql operator are ready" \ "kubectl --kubeconfig "${REPO_ROOT}/environments/${HOST_CLUSTER_NAME}/kubeconfig" get pods -n mysql-operator mysql-operator-0 | awk 'NR>1 {if (\$3 == \"Running\") exit 0; else exit 1; }'" \ 300 +kubectl --kubeconfig "${REPO_ROOT}/environments/${HOST_CLUSTER_NAME}/kubeconfig" create secret generic my-secret \ + --from-literal=ROOT_PASSWORD="$(openssl rand -base64 10 | tr -dc 'a-zA-Z0-9' | sed 's/^[^a-zA-Z]*//' | head -c 10)" \ + --namespace=kosmos-e2e kubectl --kubeconfig "${REPO_ROOT}/environments/${HOST_CLUSTER_NAME}/kubeconfig" apply -f "${REPO_ROOT}"/test/e2e/deploy/cr - util::wait_for_condition "mysql cr are ready" \ "[ \$(kubectl --kubeconfig ${REPO_ROOT}/environments/${HOST_CLUSTER_NAME}/kubeconfig get pods -n kosmos-e2e -l app.kubernetes.io/name=mysql |grep \"4/4\"| grep \"Running\" | wc -l) -eq 2 ]" \ 1200 diff --git a/test/e2e/deploy/cr/secrets.yaml b/test/e2e/deploy/cr/secrets.yaml index 6fc9e58a4..e69de29bb 100644 --- a/test/e2e/deploy/cr/secrets.yaml +++ b/test/e2e/deploy/cr/secrets.yaml @@ -1,9 +0,0 @@ -apiVersion: v1 -data: - ROOT_PASSWORD: {{ .PASSWORD }} -kind: Secret -metadata: - name: my-secret - namespace: kosmos-e2e -type: Opaque ---- diff --git a/test/e2e/deploy/mysql-operator/mysqll-operator.yaml b/test/e2e/deploy/mysql-operator/mysqll-operator.yaml index d7d13671e..09b0b5a19 100644 --- a/test/e2e/deploy/mysql-operator/mysqll-operator.yaml +++ b/test/e2e/deploy/mysql-operator/mysqll-operator.yaml @@ -183,16 +183,6 @@ spec: type: ClusterIP --- apiVersion: v1 -data: - TOPOLOGY_PASSWORD: {{ .PASSWORD }} - TOPOLOGY_USER: {{ .USER }} -kind: Secret -metadata: - name: mysql-operator-orc - namespace: mysql-operator -type: Opaque ---- -apiVersion: v1 kind: Service metadata: name: mysql-operator-0-orc-svc diff --git a/test/e2e/deploy/nginx/nginx.yaml b/test/e2e/deploy/nginx/nginx.yaml index 72ee4a739..a09fa3246 100644 --- a/test/e2e/deploy/nginx/nginx.yaml +++ b/test/e2e/deploy/nginx/nginx.yaml @@ -44,7 +44,7 @@ spec: topologyKey: kubernetes.io/hostname containers: - name: nginx - image: nginx:latest + image: nginx:1.27.3 imagePullPolicy: IfNotPresent ports: - containerPort: 80 diff --git a/test/e2e/framework/deployment_sample.go b/test/e2e/framework/deployment_sample.go index 782bd72a9..bf2af9a3b 100644 --- a/test/e2e/framework/deployment_sample.go +++ b/test/e2e/framework/deployment_sample.go @@ -21,7 +21,7 @@ const ( PollInterval = 15 * time.Second // PollTimeout defines the time after which the poll operation times out. - PollTimeout = 180 * time.Second + PollTimeout = 300 * time.Second ) func NewDeployment(namespace, name, schedulerName string, labels map[string]string, replicas *int32, nodes []string, toleration bool) *appsv1.Deployment {