From f1870c1f63b0378559bdd7f8c28bfbd3fea19ba8 Mon Sep 17 00:00:00 2001 From: Hu# Date: Thu, 21 Dec 2023 16:04:54 +0800 Subject: [PATCH] tests/realcluster: support local real cluster test (#7578) ref tikv/pd#7298 tests/realcluster: support local real cluster test Signed-off-by: husharp Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- tests/integrations/realcluster/Makefile | 16 ++++++++-------- tests/integrations/realcluster/deploy.sh | 15 +++++++++++---- tests/integrations/realcluster/reboot_pd_test.go | 5 ++++- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/tests/integrations/realcluster/Makefile b/tests/integrations/realcluster/Makefile index c9ffd3d6599..e03007a4c31 100644 --- a/tests/integrations/realcluster/Makefile +++ b/tests/integrations/realcluster/Makefile @@ -30,24 +30,24 @@ tidy: git diff go.mod go.sum | cat git diff --quiet go.mod go.sum -check: deploy test kill_tiup +check: deploy test kill_cluster -deploy: kill_tiup +deploy: kill_cluster @ echo "deploying..." ./deploy.sh - @ echo "wait tiup cluster ready..." + @ echo "wait cluster ready..." ./wait_tiup.sh 15 20 @ echo "check cluster status..." - @ pid=$$(ps -ef | grep 'tiup' | grep -v grep | awk '{print $$2}' | head -n 1); \ + @ pid=$$(ps -ef | grep 'playground' | grep -v grep | awk '{print $$2}' | head -n 1); \ echo $$pid; -kill_tiup: - @ echo "kill tiup..." - @ pid=$$(ps -ef | grep 'tiup' | grep -v grep | awk '{print $$2}' | head -n 1); \ +kill_cluster: + @ echo "kill cluster..." + @ pid=$$(ps -ef | grep 'playground' | grep -v grep | awk '{print $$2}' | head -n 1); \ if [ ! -z "$$pid" ]; then \ echo $$pid; \ kill $$pid; \ - echo "waiting for tiup to exit..."; \ + echo "waiting for cluster to exit..."; \ sleep 10; \ fi diff --git a/tests/integrations/realcluster/deploy.sh b/tests/integrations/realcluster/deploy.sh index 18e6de7f0b9..d6cd0b27f72 100755 --- a/tests/integrations/realcluster/deploy.sh +++ b/tests/integrations/realcluster/deploy.sh @@ -15,9 +15,16 @@ curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh $TIUP_BIN_DIR update playground cd ../../.. -# Run TiUP -$TIUP_BIN_DIR playground nightly --kv 3 --tiflash 1 --db 1 --pd 3 --without-monitor \ - --pd.binpath ./bin/pd-server --kv.binpath ./bin/tikv-server --db.binpath ./bin/tidb-server --tiflash.binpath ./bin/tiflash --tag pd_test \ - > $CUR_PATH/playground.log 2>&1 & +if [ ! -d "bin" ] || [ ! -e "bin/tikv-server" ] && [ ! -e "bin/tidb-server" ] && [ ! -e "bin/pd-server" ] && [ ! -e "bin/tiflash" ]; then + color-green "downloading binaries..." + color-green "this may take a few minutes, you can also download them manually and put them in the bin directory." + $TIUP_BIN_DIR playground nightly --kv 3 --tiflash 1 --db 1 --pd 3 --without-monitor --tag pd_test \ + > $CUR_PATH/playground.log 2>&1 & +else + color-green "using existing binaries..." + $TIUP_BIN_DIR playground nightly --kv 3 --tiflash 1 --db 1 --pd 3 --without-monitor \ + --pd.binpath ./bin/pd-server --kv.binpath ./bin/tikv-server --db.binpath ./bin/tidb-server --tiflash.binpath ./bin/tiflash --tag pd_test \ + > $CUR_PATH/playground.log 2>&1 & +fi cd $CUR_PATH diff --git a/tests/integrations/realcluster/reboot_pd_test.go b/tests/integrations/realcluster/reboot_pd_test.go index 59747912897..8e99b0822f0 100644 --- a/tests/integrations/realcluster/reboot_pd_test.go +++ b/tests/integrations/realcluster/reboot_pd_test.go @@ -40,10 +40,13 @@ func TestReloadLabel(t *testing.T) { resp, _ := pdHTTPCli.GetStores(ctx) setStore := resp.Stores[0] - re.Empty(setStore.Store.Labels, nil) + // TiFlash labels will be ["engine": "tiflash"] storeLabel := map[string]string{ "zone": "zone1", } + for _, label := range setStore.Store.Labels { + storeLabel[label.Key] = label.Value + } err := pdHTTPCli.SetStoreLabels(ctx, setStore.Store.ID, storeLabel) re.NoError(err)