From a944bf1ff4b4a737b4675eaeaab549c8f9702761 Mon Sep 17 00:00:00 2001 From: ichn-hu Date: Wed, 19 May 2021 20:22:38 +0800 Subject: [PATCH 1/2] fix --- executor/memtable_reader.go | 4 ++++ executor/show_test.go | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/executor/memtable_reader.go b/executor/memtable_reader.go index 76ea478d91e71..97df3b0cbc4bb 100644 --- a/executor/memtable_reader.go +++ b/executor/memtable_reader.go @@ -191,6 +191,10 @@ func fetchClusterConfig(sctx sessionctx.Context, nodeTypes, nodeAddrs set.String url = fmt.Sprintf("%s://%s%s", util.InternalHTTPSchema(), statusAddr, pdapi.Config) case "tikv", "tidb": url = fmt.Sprintf("%s://%s/config", util.InternalHTTPSchema(), statusAddr) + case "tiflash": + fmt.Println("tiflash !") + // TODO: tiflash does not yet support reading config, handle correspondingly once it supports. + return default: ch <- result{err: errors.Errorf("unknown node type: %s(%s)", typ, address)} return diff --git a/executor/show_test.go b/executor/show_test.go index ea6d6734159b6..6d6fde3765235 100644 --- a/executor/show_test.go +++ b/executor/show_test.go @@ -1112,6 +1112,17 @@ func (s *testSuite5) TestShowClusterConfig(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") + instances := []string{ + strings.Join([]string{"tiflash", "127.0.0.0:1234", "127.0.0.0:1234", "mock-version,mock-githash,0"}, ","), + } + + fpExpr := `return("` + strings.Join(instances, ";") + `")` + fpName := "github.com/pingcap/tidb/executor/mockClusterConfigServerInfo" + c.Assert(failpoint.Enable(fpName, fpExpr), IsNil) + defer func() { c.Assert(failpoint.Disable(fpName), IsNil) }() + tk.MustExec("show config") + c.Assert(tk.Se.GetSessionVars().SysWarningCount, Equals, 0) + var confItems [][]types.Datum var confErr error var confFunc executor.TestShowClusterConfigFunc = func() ([][]types.Datum, error) { From 631121e8ae7ccb14e68e9643dacdf12d758c79ae Mon Sep 17 00:00:00 2001 From: ichn-hu Date: Wed, 19 May 2021 22:22:43 +0800 Subject: [PATCH 2/2] fail --- executor/memtable_reader.go | 3 +-- executor/memtable_reader_test.go | 2 +- executor/show_test.go | 11 ----------- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/executor/memtable_reader.go b/executor/memtable_reader.go index 97df3b0cbc4bb..f98306b5da51d 100644 --- a/executor/memtable_reader.go +++ b/executor/memtable_reader.go @@ -192,8 +192,7 @@ func fetchClusterConfig(sctx sessionctx.Context, nodeTypes, nodeAddrs set.String case "tikv", "tidb": url = fmt.Sprintf("%s://%s/config", util.InternalHTTPSchema(), statusAddr) case "tiflash": - fmt.Println("tiflash !") - // TODO: tiflash does not yet support reading config, handle correspondingly once it supports. + // TODO: support show tiflash config once tiflash supports it return default: ch <- result{err: errors.Errorf("unknown node type: %s(%s)", typ, address)} diff --git a/executor/memtable_reader_test.go b/executor/memtable_reader_test.go index 53607dd80ef03..5b55a9d601b03 100644 --- a/executor/memtable_reader_test.go +++ b/executor/memtable_reader_test.go @@ -170,7 +170,7 @@ func (s *testMemTableReaderSuite) TestTiDBClusterConfig(c *C) { // mock servers servers := []string{} - for _, typ := range []string{"tidb", "tikv", "pd"} { + for _, typ := range []string{"tidb", "tikv", "tiflash", "pd"} { for _, server := range testServers { servers = append(servers, strings.Join([]string{typ, server.address, server.address}, ",")) } diff --git a/executor/show_test.go b/executor/show_test.go index 6d6fde3765235..ea6d6734159b6 100644 --- a/executor/show_test.go +++ b/executor/show_test.go @@ -1112,17 +1112,6 @@ func (s *testSuite5) TestShowClusterConfig(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") - instances := []string{ - strings.Join([]string{"tiflash", "127.0.0.0:1234", "127.0.0.0:1234", "mock-version,mock-githash,0"}, ","), - } - - fpExpr := `return("` + strings.Join(instances, ";") + `")` - fpName := "github.com/pingcap/tidb/executor/mockClusterConfigServerInfo" - c.Assert(failpoint.Enable(fpName, fpExpr), IsNil) - defer func() { c.Assert(failpoint.Disable(fpName), IsNil) }() - tk.MustExec("show config") - c.Assert(tk.Se.GetSessionVars().SysWarningCount, Equals, 0) - var confItems [][]types.Datum var confErr error var confFunc executor.TestShowClusterConfigFunc = func() ([][]types.Datum, error) {