Skip to content

Commit

Permalink
tests/realcluster: support local real cluster test (#7578)
Browse files Browse the repository at this point in the history
ref #7298

tests/realcluster: support local real cluster test

Signed-off-by: husharp <jinhao.hu@pingcap.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
HuSharp and ti-chi-bot[bot] authored Dec 21, 2023
1 parent f15db4b commit f1870c1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
16 changes: 8 additions & 8 deletions tests/integrations/realcluster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 11 additions & 4 deletions tests/integrations/realcluster/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion tests/integrations/realcluster/reboot_pd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit f1870c1

Please sign in to comment.