Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playground: fix tiproxy scale #2365

Merged
merged 8 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions components/playground/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ func (p *Playground) handleScaleIn(w io.Writer, pid int) error {
p.ticdcs = append(p.ticdcs[:i], p.ticdcs[i+1:]...)
}
}
case spec.ComponentTiProxy:
for i := 0; i < len(p.tiproxys); i++ {
if p.tiproxys[i].Pid() == pid {
p.tiproxys = append(p.tiproxys[:i], p.tiproxys[i+1:]...)
}
}
case spec.ComponentTiKVCDC:
for i := 0; i < len(p.tikvCdcs); i++ {
if p.tikvCdcs[i].Pid() == pid {
Expand Down Expand Up @@ -428,6 +434,8 @@ func (p *Playground) sanitizeComponentConfig(cid string, cfg *instance.Config) e
return p.sanitizeConfig(p.bootOptions.Pump, cfg)
case spec.ComponentDrainer:
return p.sanitizeConfig(p.bootOptions.Drainer, cfg)
case spec.ComponentTiProxy:
return p.sanitizeConfig(p.bootOptions.TiProxy, cfg)
default:
return fmt.Errorf("unknown %s in sanitizeConfig", cid)
}
Expand Down
21 changes: 21 additions & 0 deletions tests/tiup-playground/test_playground.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function kill_all() {
killall -9 pd-server || true
killall -9 tikv-cdc || true
killall -9 tiflash || true
killall -9 tiproxy || true
killall -9 grafana-server || true
killall -9 tiup-playground || true
killall -9 prometheus || true
Expand Down Expand Up @@ -160,4 +161,24 @@ check_instance_num tikv-cdc 2
killall -2 tiup-playground.test || killall -2 tiup-playground
sleep 30

# test for TiProxy
echo -e "\033[0;36m<<< Run TiProxy test >>>\033[0m"
tiup-playground $TIDB_VERSION --db 1 --pd 1 --kv 1 --tiflash 0 --tiproxy 1 --tiproxy.version "nightly" > $outfile 2>&1 &
sleep 3
timeout 300 grep -q "TiDB Playground Cluster is started" <(tail -f $outfile)
tiup-playground display | grep -qv "exit"
# scale out
tiup-playground scale-out --tiproxy 1
sleep 5
check_instance_num tiproxy 2
# scale in
pid=`tiup-playground display | grep "tiproxy" | awk 'NR==1 {print $1}'`
tiup-playground scale-in --pid $pid
sleep 5
check_instance_num tiproxy 1

# exit all
killall -2 tiup-playground.test || killall -2 tiup-playground
sleep 30

echo -e "\033[0;36m<<< Run all test success >>>\033[0m"
Loading