-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
infoschema: fix some InfoSchema V2 API for special schemas like INFOR…
- Loading branch information
1 parent
df527fe
commit bd17c5b
Showing
5 changed files
with
162 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_test") | ||
|
||
go_test( | ||
name = "infoschemav2test_test", | ||
timeout = "short", | ||
srcs = [ | ||
"main_test.go", | ||
"v2_test.go", | ||
], | ||
flaky = True, | ||
deps = [ | ||
"//pkg/domain", | ||
"//pkg/infoschema", | ||
"//pkg/parser/auth", | ||
"//pkg/testkit", | ||
"//pkg/testkit/testsetup", | ||
"@com_github_stretchr_testify//require", | ||
"@org_uber_go_goleak//:goleak", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2023 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package infoschemav2test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/pingcap/tidb/pkg/testkit/testsetup" | ||
"go.uber.org/goleak" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
testsetup.SetupForCommonTest() | ||
opts := []goleak.Option{ | ||
goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon"), | ||
goleak.IgnoreTopFunction("github.com/bazelbuild/rules_go/go/tools/bzltestutil.RegisterTimeoutHandler.func1"), | ||
goleak.IgnoreTopFunction("github.com/lestrrat-go/httprc.runFetchWorker"), | ||
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"), | ||
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"), | ||
} | ||
goleak.VerifyTestMain(m, opts...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2024 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package infoschemav2test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/pingcap/tidb/pkg/domain" | ||
"github.com/pingcap/tidb/pkg/infoschema" | ||
"github.com/pingcap/tidb/pkg/parser/auth" | ||
"github.com/pingcap/tidb/pkg/testkit" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSpecialSchemas(t *testing.T) { | ||
store := testkit.CreateMockStore(t) | ||
tk := testkit.NewTestKit(t, store) | ||
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil, nil)) | ||
tk.MustExec("use test") | ||
|
||
tk.MustQuery("select @@global.tidb_schema_cache_size;").Check(testkit.Rows("0")) | ||
tk.MustExec("set @@global.tidb_schema_cache_size = 1024;") | ||
tk.MustQuery("select @@global.tidb_schema_cache_size;").Check(testkit.Rows("1024")) | ||
tk.MustExec("create table t (id int);") | ||
is := domain.GetDomain(tk.Session()).InfoSchema() | ||
require.True(t, infoschema.IsV2(is)) | ||
|
||
tk.MustQuery("show databases;").Check(testkit.Rows( | ||
"INFORMATION_SCHEMA", "METRICS_SCHEMA", "PERFORMANCE_SCHEMA", "mysql", "sys", "test")) | ||
tk.MustExec("use information_schema;") | ||
tk.MustQuery("show tables;").MultiCheckContain([]string{ | ||
"ANALYZE_STATUS", | ||
"ATTRIBUTES", | ||
"CHARACTER_SETS", | ||
"COLLATIONS", | ||
"COLUMNS", | ||
"COLUMN_PRIVILEGES", | ||
"COLUMN_STATISTICS", | ||
"VIEWS"}) | ||
tk.MustQuery("show create table tables;").MultiCheckContain([]string{ | ||
`TABLE_CATALOG`, | ||
`TABLE_SCHEMA`, | ||
`TABLE_NAME`, | ||
`TABLE_TYPE`, | ||
}) | ||
|
||
tk.ExecToErr("drop database information_schema;") | ||
tk.ExecToErr("drop table views;") | ||
|
||
tk.MustExec("use metrics_schema;") | ||
tk.MustQuery("show tables;").CheckContain("uptime") | ||
tk.MustQuery("show create table uptime;").CheckContain("time") | ||
|
||
tk.MustExec("set @@global.tidb_schema_cache_size = default;") | ||
} |