diff --git a/addons/apecloud-mysql/scripts-ut-spec/etcd_clean_spec.sh b/addons/apecloud-mysql/scripts-ut-spec/etcd_clean_spec.sh index b06071946..ff900e08d 100644 --- a/addons/apecloud-mysql/scripts-ut-spec/etcd_clean_spec.sh +++ b/addons/apecloud-mysql/scripts-ut-spec/etcd_clean_spec.sh @@ -14,8 +14,8 @@ Describe "Etcd Clean Script Tests" Describe "when SERVICE_ETCD_ENDPOINT is set," setup() { SERVICE_ETCD_ENDPOINT="http://localhost:2379" - KB_NAMESPACE="test-namespace" - KB_CLUSTER_NAME="test-cluster" + CLUSTER_NAMESPACE="test-namespace" + CLUSTER_NAME="test-cluster" ETCDCTL_API="3" } Before "setup" @@ -67,8 +67,8 @@ Describe "Etcd Clean Script Tests" Describe "when ETCDCTL_API is set to 2" setup() { SERVICE_ETCD_ENDPOINT="http://localhost:2379" - KB_NAMESPACE="test-namespace" - KB_CLUSTER_NAME="test-cluster" + CLUSTER_NAMESPACE="test-namespace" + CLUSTER_NAME="test-cluster" ETCDCTL_API="2" } Before "setup" diff --git a/addons/apecloud-mysql/scripts-ut-spec/etcd_post_start_spec.sh b/addons/apecloud-mysql/scripts-ut-spec/etcd_post_start_spec.sh index 64f91a9c4..76da84cbe 100644 --- a/addons/apecloud-mysql/scripts-ut-spec/etcd_post_start_spec.sh +++ b/addons/apecloud-mysql/scripts-ut-spec/etcd_post_start_spec.sh @@ -7,8 +7,8 @@ Describe "etcd-post-start.sh script tests" LOCAL_ETCD_POD_FQDN="etcd1,etcd2" LOCAL_ETCD_PORT="2379" CELL="zone1" - KB_NAMESPACE="test-namespace" - KB_CLUSTER_NAME="test-cluster" + CLUSTER_NAMESPACE="test-namespace" + CLUSTER_NAME="test-cluster" ETCDCTL_API="3" } Before "setup" @@ -27,8 +27,8 @@ Describe "etcd-post-start.sh script tests" setup() { SERVICE_ETCD_ENDPOINT="http://etcd1:2379,http://etcd2:2379" CELL="zone1" - KB_NAMESPACE="test-namespace" - KB_CLUSTER_NAME="test-cluster" + CLUSTER_NAMESPACE="test-namespace" + CLUSTER_NAME="test-cluster" ETCDCTL_API="3" } Before "setup" @@ -46,8 +46,8 @@ Describe "etcd-post-start.sh script tests" Describe "when both LOCAL_ETCD_POD_FQDN and SERVICE_ETCD_ENDPOINT are empty" setup() { CELL="zone1" - KB_NAMESPACE="test-namespace" - KB_CLUSTER_NAME="test-cluster" + CLUSTER_NAMESPACE="test-namespace" + CLUSTER_NAME="test-cluster" ETCDCTL_API="3" } Before "setup" @@ -64,8 +64,8 @@ Describe "etcd-post-start.sh script tests" LOCAL_ETCD_POD_FQDN="etcd1,etcd2" LOCAL_ETCD_PORT="2379" CELL="zone1" - KB_NAMESPACE="test-namespace" - KB_CLUSTER_NAME="test-cluster" + CLUSTER_NAMESPACE="test-namespace" + CLUSTER_NAME="test-cluster" ETCDCTL_API="2" } Before "setup" @@ -95,8 +95,8 @@ Describe "etcd-post-start.sh script tests" LOCAL_ETCD_POD_FQDN="etcd1,etcd2" LOCAL_ETCD_PORT="2379" CELL="zone1" - KB_NAMESPACE="test-namespace" - KB_CLUSTER_NAME="test-cluster" + CLUSTER_NAMESPACE="test-namespace" + CLUSTER_NAME="test-cluster" ETCDCTL_API="3" } Before "setup" diff --git a/addons/apecloud-mysql/scripts-ut-spec/setup_spec.sh b/addons/apecloud-mysql/scripts-ut-spec/setup_spec.sh index 83310729e..13b476175 100644 --- a/addons/apecloud-mysql/scripts-ut-spec/setup_spec.sh +++ b/addons/apecloud-mysql/scripts-ut-spec/setup_spec.sh @@ -17,8 +17,8 @@ Describe "ApeCloud MySQL Startup Script Tests" MY_POD_LIST=wesql1-mysql-0,wesql1-mysql-1,wesql1-mysql-2 MY_COMP_REPLICAS=3 MY_COMP_NAME=mysql - MY_CLUSTER_NAME=wesql1 - MY_CLUSTER_UID=c3636ff1-bb54-47a4-ac4e-111ba9b41295 + CLUSTER_NAME=wesql1 + CLUSTER_UID=c3636ff1-bb54-47a4-ac4e-111ba9b41295 KB_SERVICE_CHARACTER_TYPE=wesql KB_MYSQL_VOLUME_DIR=. } @@ -90,7 +90,7 @@ Describe "get_service_name function" Include ../scripts/setup.sh setup() { MY_COMP_NAME=mysql - MY_CLUSTER_NAME=wesql1 + CLUSTER_NAME=wesql1 } Before "setup" It "returns the correct service name" @@ -104,7 +104,7 @@ Describe "get_cluster_members function" setup() { MY_POD_LIST="pod1,pod2,pod3" MY_COMP_NAME=mysql - MY_CLUSTER_NAME=wesql1 + CLUSTER_NAME=wesql1 MYSQL_CONSENSUS_PORT=13306 } Before "setup" @@ -132,9 +132,9 @@ Describe "generate_cluster_info function" MY_POD_NAME="pod1" MY_POD_LIST="pod1,pod2,pod3" MY_COMP_NAME=mysql - MY_CLUSTER_NAME=wesql1 + CLUSTER_NAME=wesql1 MY_COMP_REPLICAS=3 - MY_CLUSTER_UID="test-uid" + CLUSTER_UID="test-uid" } Before "setup" It "sets the correct environment variables" diff --git a/addons/apecloud-mysql/scripts-ut-spec/vtctld_spec.sh b/addons/apecloud-mysql/scripts-ut-spec/vtctld_spec.sh index 8ca2bec4c..0fced012d 100644 --- a/addons/apecloud-mysql/scripts-ut-spec/vtctld_spec.sh +++ b/addons/apecloud-mysql/scripts-ut-spec/vtctld_spec.sh @@ -9,8 +9,8 @@ Describe "vtctld.sh script tests" export CELL="zone1" export VTCTLD_GRPC_PORT="15999" export VTCTLD_WEB_PORT="15000" - export KB_NAMESPACE="namespace" - export KB_CLUSTER_NAME="cluster" + export CLUSTER_NAMESPACE="namespace" + export CLUSTER_NAME="cluster" export VTDATAROOT="/var/lib/vitess" } Before "setup" @@ -22,8 +22,8 @@ Describe "vtctld.sh script tests" unset CELL unset VTCTLD_GRPC_PORT unset VTCTLD_WEB_PORT - unset KB_NAMESPACE - unset KB_CLUSTER_NAME + unset CLUSTER_NAMESPACE + unset CLUSTER_NAME unset VTDATAROOT } After "cleanup" diff --git a/addons/apecloud-mysql/scripts/etcd-clean.sh b/addons/apecloud-mysql/scripts/etcd-clean.sh index 51322fce3..33f21c605 100644 --- a/addons/apecloud-mysql/scripts/etcd-clean.sh +++ b/addons/apecloud-mysql/scripts/etcd-clean.sh @@ -22,17 +22,17 @@ servers=${servers:1} echo $servers -echo "Deleting all keys with prefix /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME} from Etcd server at ${endpoints}..." +echo "Deleting all keys with prefix /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME} from Etcd server at ${endpoints}..." # Set different deletion methods according to different etcdctl versions. if [[ ${ETCDCTL_API} == "2" ]]; then - etcdctl --endpoints $servers rm -r /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME} + etcdctl --endpoints $servers rm -r /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME} else - etcdctl --endpoints $servers del /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME} --prefix + etcdctl --endpoints $servers del /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME} --prefix fi if [ $? -eq 0 ]; then - echo "Successfully deleted all keys with prefix /vitess/${KB_NAMESPACE}/$KB_CLUSTER_NAME." + echo "Successfully deleted all keys with prefix /vitess/${CLUSTER_NAMESPACE}/$CLUSTER_NAME." else echo "Failed to delete keys. Please check your Etcd server and try again." exit 1 diff --git a/addons/apecloud-mysql/scripts/etcd-post-start.sh b/addons/apecloud-mysql/scripts/etcd-post-start.sh index a7be39053..00c94fb02 100644 --- a/addons/apecloud-mysql/scripts/etcd-post-start.sh +++ b/addons/apecloud-mysql/scripts/etcd-post-start.sh @@ -30,17 +30,17 @@ echo $servers if [[ ${ETCDCTL_API} == "2" ]]; then # etcdctl API 2 manages data in a directory-based format, requiring directories to be created in advance. - etcdctl --endpoints=${servers} get "/vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/$cell" >/dev/null 2>&1 + etcdctl --endpoints=${servers} get "/vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/$cell" >/dev/null 2>&1 if [[ $? -eq 0 ]]; then exit 0 fi - echo "add /vitess/$KB_NAMESPACE/$KB_CLUSTER_NAME/global" - etcdctl --endpoints=${servers} mkdir /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/global - echo "add /vitess/$KB_NAMESPACE/$KB_CLUSTER_NAME/$cell" - etcdctl --endpoints=${servers} mkdir /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/$cell + echo "add /vitess/$CLUSTER_NAMESPACE/$CLUSTER_NAME/global" + etcdctl --endpoints=${servers} mkdir /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/global + echo "add /vitess/$CLUSTER_NAMESPACE/$CLUSTER_NAME/$cell" + etcdctl --endpoints=${servers} mkdir /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/$cell else # etcdctl API 3 manages data in key-value pairs, eliminating the need to create additional directories. - output=$(etcdctl --endpoints="${servers}" get "/vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/$cell" --prefix --keys-only) + output=$(etcdctl --endpoints="${servers}" get "/vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/$cell" --prefix --keys-only) if [[ -n $output ]]; then exit 0 fi @@ -50,8 +50,8 @@ echo "add $cell CellInfo" set +e vtctl --topo_implementation etcd2 \ --topo_global_server_address "${servers}" \ - --topo_global_root "/vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/global" VtctldCommand AddCellInfo \ - --root "/vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/$cell" \ + --topo_global_root "/vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/global" VtctldCommand AddCellInfo \ + --root "/vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/$cell" \ --server-address "${servers}" \ $cell set -e \ No newline at end of file diff --git a/addons/apecloud-mysql/scripts/setup.sh b/addons/apecloud-mysql/scripts/setup.sh index 6d6a0482c..6a24ce5a4 100755 --- a/addons/apecloud-mysql/scripts/setup.sh +++ b/addons/apecloud-mysql/scripts/setup.sh @@ -4,12 +4,12 @@ if [ -z "${__SOURCED__:+x}" ]; then set -ex fi -# MY_CLUSTER_NAME=clustername +# CLUSTER_NAME=clustername # MY_COMP_NAME=componentname # compose headless service name from cluster and component name # return: clustername-componentname-headless get_service_name() { - cluster_name=${MY_CLUSTER_NAME:?missing cluster name} + cluster_name=${CLUSTER_NAME:?missing cluster name} component_name=${MY_COMP_NAME:?missing component name} echo "${cluster_name}-${component_name}-headless" } @@ -55,7 +55,7 @@ generate_cluster_info() { echo "KB_MYSQL_N=${KB_MYSQL_N}" if [ -z "$KB_MYSQL_CLUSTER_UID" ]; then - export KB_MYSQL_CLUSTER_UID=${MY_CLUSTER_UID:?missing cluster uid} + export KB_MYSQL_CLUSTER_UID=${CLUSTER_UID:?missing cluster uid} fi echo "KB_MYSQL_CLUSTER_UID=${KB_MYSQL_CLUSTER_UID}" diff --git a/addons/apecloud-mysql/scripts/vtctld.sh b/addons/apecloud-mysql/scripts/vtctld.sh index a8cc36355..2e4fd06ff 100755 --- a/addons/apecloud-mysql/scripts/vtctld.sh +++ b/addons/apecloud-mysql/scripts/vtctld.sh @@ -30,7 +30,7 @@ cell=${CELL:-'zone1'} grpc_port=${VTCTLD_GRPC_PORT:-'15999'} vtctld_web_port=${VTCTLD_WEB_PORT:-'15000'} -topology_fags="--topo_implementation etcd2 --topo_global_server_address ${endpoints} --topo_global_root /vitess/${KB_NAMESPACE}/${KB_CLUSTER_NAME}/global" +topology_fags="--topo_implementation etcd2 --topo_global_server_address ${endpoints} --topo_global_root /vitess/${CLUSTER_NAMESPACE}/${CLUSTER_NAME}/global" VTDATAROOT=$VTDATAROOT/vtctld su vitess <