Skip to content

Commit

Permalink
playground: fix tiproxy scale (#2365)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhebox authored Feb 29, 2024
1 parent 38b6c96 commit 8164c78
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
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"

0 comments on commit 8164c78

Please sign in to comment.