From 78fc06d16c4defce219ce5d4adbfac1d6cdd1ac2 Mon Sep 17 00:00:00 2001 From: xhe Date: Tue, 12 Nov 2024 11:02:35 +0800 Subject: [PATCH] playground: add tiproxy to dsn Signed-off-by: xhe --- components/playground/main.go | 5 ++++- components/playground/playground.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/components/playground/main.go b/components/playground/main.go index 9cfb32d280..2a984afd71 100644 --- a/components/playground/main.go +++ b/components/playground/main.go @@ -553,11 +553,14 @@ func loadPort(dir string) (port int, err error) { return } -func dumpDSN(fname string, dbs []*instance.TiDBInstance) { +func dumpDSN(fname string, dbs []*instance.TiDBInstance, tdbs []*instance.TiProxy) { var dsn []string for _, db := range dbs { dsn = append(dsn, fmt.Sprintf("mysql://root@%s", db.Addr())) } + for _, tdb := range tdbs { + dsn = append(dsn, fmt.Sprintf("mysql://root@%s", tdb.Addr())) + } _ = utils.WriteFile(fname, []byte(strings.Join(dsn, "\n")), 0644) } diff --git a/components/playground/playground.go b/components/playground/playground.go index 73fe009ad5..11aa965bb6 100644 --- a/components/playground/playground.go +++ b/components/playground/playground.go @@ -1312,7 +1312,7 @@ func (p *Playground) bootCluster(ctx context.Context, env *environment.Environme p.updateMonitorTopology(spec.ComponentPrometheus, *monitorInfo) } - dumpDSN(filepath.Join(p.dataDir, "dsn"), p.tidbs) + dumpDSN(filepath.Join(p.dataDir, "dsn"), p.tidbs, p.tiproxys) go func() { // fmt.Printf("serve at :%d\n", p.port)