Skip to content

Commit

Permalink
fix: automatically create e2e test secret
Browse files Browse the repository at this point in the history
Signed-off-by: luoyuanze <[email protected]>
  • Loading branch information
lyzuiui committed Jan 17, 2025
1 parent 1e990ec commit a16a5b4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 45 deletions.
40 changes: 18 additions & 22 deletions hack/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ function prepare_test_image() {
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/percona:5.7 percona:5.7
docker tag docker.m.daocloud.io/prom/mysqld-exporter:v0.13.0 prom/mysqld-exporter:v0.13.0
Expand All @@ -64,25 +61,24 @@ function prepare_e2e_cluster() {
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
Expand Down
9 changes: 8 additions & 1 deletion hack/rune2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)" \
--from-literal=TOPOLOGY_USER="$(openssl rand -base64 12)" \
--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)" \
--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
Expand Down
4 changes: 1 addition & 3 deletions pkg/kubenest/controlplane/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,9 @@ func TestGetEndPointInfo(t *testing.T) {
},
},
})
port, ipFamilies, err := getEndPointInfo(client)
port, _, err := getEndPointInfo(client)
assert.NoError(t, err)
assert.Equal(t, int32(6443), port)
assert.True(t, ipFamilies.IPv4)
assert.False(t, ipFamilies.IPv6)
})

t.Run("No subsets in endpoint", func(t *testing.T) {
Expand Down
9 changes: 0 additions & 9 deletions test/e2e/deploy/cr/secrets.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
apiVersion: v1
data:
ROOT_PASSWORD: {{ .PASSWORD }}
kind: Secret
metadata:
name: my-secret
namespace: kosmos-e2e
type: Opaque
---
10 changes: 0 additions & 10 deletions test/e2e/deploy/mysql-operator/mysqll-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a16a5b4

Please sign in to comment.