From 33e14f86e8c1ecbe91b6a44bdb5fec6dca336cc9 Mon Sep 17 00:00:00 2001 From: Arenatlx <314806019@qq.com> Date: Wed, 7 Jul 2021 15:55:29 +0800 Subject: [PATCH] test: fix the auth problem in the test of set replica for system tables (#25742) --- ddl/db_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ddl/db_test.go b/ddl/db_test.go index 16bc8e8c55..a98c9107e6 100644 --- a/ddl/db_test.go +++ b/ddl/db_test.go @@ -29,6 +29,7 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/failpoint" "github.com/pingcap/parser/ast" + "github.com/pingcap/parser/auth" "github.com/pingcap/parser/model" "github.com/pingcap/parser/mysql" "github.com/pingcap/parser/terror" @@ -5340,13 +5341,19 @@ func (s *testSerialDBSuite) TestSetTableFlashReplicaForSystemTable(c *C) { memOrSysDB := []string{"MySQL", "INFORMATION_SCHEMA", "PERFORMANCE_SCHEMA", "METRICS_SCHEMA"} for _, db := range memOrSysDB { tk.MustExec("use " + db) + tk.Se.Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil) rows := tk.MustQuery("show tables").Rows() for i := 0; i < len(rows); i++ { sysTables = append(sysTables, rows[i][0].(string)) } for _, one := range sysTables { _, err := tk.Exec(fmt.Sprintf("alter table `%s` set tiflash replica 1", one)) - c.Assert(err.Error(), Equals, "[ddl:8200]ALTER table replica for tables in system database is currently unsupported") + if db == "MySQL" { + c.Assert(err.Error(), Equals, "[ddl:8200]ALTER table replica for tables in system database is currently unsupported") + } else { + c.Assert(err.Error(), Equals, fmt.Sprintf("[planner:1142]ALTER command denied to user 'root'@'%%' for table '%s'", strings.ToLower(one))) + } + } sysTables = sysTables[:0] }