Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: migrate test infra to testify for inspection_summary_test.go #31483

Merged
merged 73 commits into from
Jan 10, 2022
Merged
Changes from 67 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
5088674
executor : migrate test-infra to testify for batch_point_get_test.go
YufeiCh Oct 26, 2021
c5cea4f
Merge branch 'master' into master
YufeiCh Oct 26, 2021
60dd480
fix check-dev
YufeiCh Oct 27, 2021
e366aa8
Merge branch 'master' of github.com:YufeiCh/tidb
YufeiCh Oct 27, 2021
e485688
Merge branch 'pingcap:master' into master
YufeiCh Oct 27, 2021
b72b965
move testBatchPointGetSuite and newStoreWithBootstrap to executor_tes…
YufeiCh Oct 27, 2021
a36a3fc
remove testBatchPointGetSuite from executor_test.go
YufeiCh Oct 27, 2021
599fbdb
executor: migrate test-infra to testify for delete_test.go
YufeiCh Oct 27, 2021
63d9880
executor : migrate test-infra to testify for index_advise_test.go
YufeiCh Oct 27, 2021
cee3096
fix for year number and require.EqualError
YufeiCh Oct 28, 2021
36939ee
Merge branch 'master' into master
YufeiCh Oct 28, 2021
ecfd490
fix for year number and require.EqualError
YufeiCh Oct 28, 2021
00b3393
Merge branch 'master' of github.com:YufeiCh/tidb
YufeiCh Oct 28, 2021
a850ad9
Merge branch 'master' into master
ti-chi-bot Oct 28, 2021
e4a9ef5
Merge branch 'pingcap:master' into master
YufeiCh Oct 28, 2021
2cb2c73
executor: migrate test-infra to testify for hash_table_test.go
YufeiCh Oct 28, 2021
8afa211
Merge branch 'pingcap:master' into master
YufeiCh Oct 28, 2021
e995257
Merge branch 'master' into master
YufeiCh Oct 28, 2021
e460137
fix hash_table_test.go
YufeiCh Oct 28, 2021
43fddaf
executor: migrate migrate test-infra to testify for grant_test.go
YufeiCh Oct 28, 2021
b014865
Rename hash_table_test.go to hash_table_serial_test.go
YufeiCh Oct 28, 2021
6ec63ed
Merge branch 'master' into master
YufeiCh Oct 28, 2021
0c186e0
Update grant_test.go
YufeiCh Oct 28, 2021
e33b1d0
make grant_test.go run in parallel
YufeiCh Oct 28, 2021
0e4f2e7
Merge branch 'master' into master
YufeiCh Oct 28, 2021
eca89ea
Merge branch 'master' into master
ti-chi-bot Oct 29, 2021
05a8978
Merge branch 'pingcap:master' into master
YufeiCh Oct 29, 2021
e89c215
Merge branch 'pingcap:master' into master
YufeiCh Nov 2, 2021
00393a5
executor: migrate test-infra to testify for admin_test.go
YufeiCh Nov 2, 2021
bad88eb
update admin_test.go for replicate fmt.print
YufeiCh Nov 2, 2021
965a5fd
fix for Commentf method
YufeiCh Nov 2, 2021
5ce6832
fix for check-dev2
YufeiCh Nov 3, 2021
5493d18
Merge branch 'pingcap:master' into master
YufeiCh Nov 4, 2021
6977878
fix for duplicated error check
YufeiCh Nov 4, 2021
a45a732
Merge branch 'master' into master
YufeiCh Nov 4, 2021
2d5b1bb
Merge branch 'master' into master
YufeiCh Nov 5, 2021
ded64b8
Merge branch 'master' into master
YufeiCh Nov 5, 2021
79298a0
Merge branch 'master' into master
mmyj Nov 5, 2021
e2d4780
Merge branch 'master' into master
mmyj Nov 5, 2021
fdf2323
fix for dupilicated error check
YufeiCh Nov 5, 2021
2b9af2c
Merge branch 'master' into master
YufeiCh Nov 5, 2021
31280d4
Merge branch 'master' into master
YufeiCh Nov 8, 2021
2ac2f78
Merge branch 'master' into master
YufeiCh Nov 8, 2021
5f96bcf
fix for bugs
YufeiCh Nov 8, 2021
c66b7c0
Merge branch 'master' of github.com:YufeiCh/tidb
YufeiCh Nov 8, 2021
548dde1
move the require.error check back
YufeiCh Nov 8, 2021
5ab1ec8
move back the require.Error
YufeiCh Nov 9, 2021
0df216b
Merge branch 'master' into master
YufeiCh Nov 9, 2021
6441b0d
Merge branch 'master' into master
ti-chi-bot Nov 11, 2021
de7c046
Merge branch 'master' into master
ti-chi-bot Nov 11, 2021
78146eb
Merge branch 'master' into master
ti-chi-bot Nov 11, 2021
d28e520
Merge branch 'master' into master
ti-chi-bot Nov 11, 2021
6f4b70b
Merge branch 'master' into master
ti-chi-bot Nov 11, 2021
7883b59
Merge branch 'master' into master
ti-chi-bot Nov 11, 2021
78e98f4
Merge branch 'master' into master
ti-chi-bot Nov 11, 2021
4ce71d2
Merge branch 'master' into master
ti-chi-bot Nov 11, 2021
fea3bda
Merge branch 'master' into master
ti-chi-bot Nov 11, 2021
96e1b15
seperate global variable change test
YufeiCh Nov 12, 2021
dc7a109
Merge branch 'master' of github.com:YufeiCh/tidb
YufeiCh Nov 12, 2021
4ef454c
fix for gofmt
YufeiCh Nov 12, 2021
ee9ce31
Merge branch 'master' into master
ti-chi-bot Nov 12, 2021
5bf366d
Merge branch 'pingcap:master' into master
YufeiCh Nov 22, 2021
8fb95b6
Merge branch 'pingcap:master' into master
YufeiCh Dec 22, 2021
905f503
Merge branch 'pingcap:master' into master
YufeiCh Jan 7, 2022
6507eb3
executor: migrate test infra to testify for inspection_summary_test.go
YufeiCh Jan 7, 2022
bd4e762
Merge branch 'pingcap:master' into master
YufeiCh Jan 10, 2022
24387b7
Merge branch 'master' of github.com:YufeiCh/tidb
YufeiCh Jan 10, 2022
b016f71
change Nil to NoError
YufeiCh Jan 10, 2022
e8f690c
fix
YufeiCh Jan 10, 2022
c48d3f7
fix
YufeiCh Jan 10, 2022
2aa0489
fix
YufeiCh Jan 10, 2022
1b062bc
Merge branch 'master' into master
YufeiCh Jan 10, 2022
c33f986
Merge branch 'master' into master
ti-chi-bot Jan 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 24 additions & 41 deletions executor/inspection_summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,62 +16,45 @@ package executor_test

import (
"context"
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/domain"
"github.com/pingcap/tidb/executor"
"github.com/pingcap/tidb/infoschema"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/parser/mysql"
"github.com/pingcap/tidb/testkit"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/set"
"github.com/pingcap/tidb/util/testkit"
"github.com/stretchr/testify/require"
)

var _ = SerialSuites(&inspectionSummarySuite{})

type inspectionSummarySuite struct {
store kv.Storage
dom *domain.Domain
}

func (s *inspectionSummarySuite) SetUpSuite(c *C) {
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
s.store = store
s.dom = dom
}

func (s *inspectionSummarySuite) TearDownSuite(c *C) {
s.dom.Close()
s.store.Close()
}

func (s *inspectionSummarySuite) TestValidInspectionSummaryRules(c *C) {
func TestValidInspectionSummaryRules(t *testing.T) {
for rule, tbls := range executor.InspectionSummaryRules {
tables := set.StringSet{}
for _, t := range tbls {
c.Assert(tables.Exist(t), IsFalse, Commentf("duplicate table name: %v in rule: %v", t, rule))
require.False(t, tables.Exist(t), "duplicate table name: %v in rule: %v", t, rule)
tables.Insert(t)

_, found := infoschema.MetricTableMap[t]
c.Assert(found, IsTrue, Commentf("metric table %v not define", t))
require.True(t, found, "metric table %v not define", t)
}
}
}

func (s *inspectionSummarySuite) TestInspectionSummary(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
func TestInspectionSummary(t *testing.T) {
store, domain, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()

tk := testkit.NewTestKit(t, store)

fpName := "github.com/pingcap/tidb/executor/mockMetricsTableData"
c.Assert(failpoint.Enable(fpName, "return"), IsNil)
defer func() { c.Assert(failpoint.Disable(fpName), IsNil) }()
require.Nil(t, failpoint.Enable(fpName, "return"))
YufeiCh marked this conversation as resolved.
Show resolved Hide resolved
defer func() { require.Nil(t, failpoint.Disable(fpName)) }()

datetime := func(s string) types.Time {
t, err := types.ParseTime(tk.Se.GetSessionVars().StmtCtx, s, mysql.TypeDatetime, types.MaxFsp)
c.Assert(err, IsNil)
return t
time, err := types.ParseTime(tk.Session().GetSessionVars().StmtCtx, s, mysql.TypeDatetime, types.MaxFsp)
require.NoError(t, err)
return time
}

// construct some mock data
Expand All @@ -97,10 +80,10 @@ func (s *inspectionSummarySuite) TestInspectionSummary(c *C) {
return fpName == fpname
})

rs, err := tk.Se.Execute(ctx, "select * from information_schema.inspection_summary where rule='query-summary' and metrics_name in ('tidb_qps', 'tidb_query_duration')")
c.Assert(err, IsNil)
result := tk.ResultSetToResultWithCtx(ctx, rs[0], Commentf("execute inspect SQL failed"))
c.Assert(tk.Se.GetSessionVars().StmtCtx.WarningCount(), Equals, uint16(0), Commentf("unexpected warnings: %+v", tk.Se.GetSessionVars().StmtCtx.GetWarnings()))
rs, err := tk.Session().Execute(ctx, "select * from information_schema.inspection_summary where rule='query-summary' and metrics_name in ('tidb_qps', 'tidb_query_duration')")
require.NoError(t, err)
result := tk.ResultSetToResultWithCtx(ctx, rs[0], "execute inspect SQL failed")
require.Equal(t, uint16(0), tk.Session().GetSessionVars().StmtCtx.WarningCount(), "unexpected warnings: %+v", tk.Session().GetSessionVars().StmtCtx.GetWarnings())
result.Check(testkit.Rows(
"query-summary tikv-0 tidb_query_duration Select 0.99 0 0 0 The quantile of TiDB query durations(second)",
"query-summary tikv-1 tidb_query_duration Update 0.99 2 1 3 The quantile of TiDB query durations(second)",
Expand All @@ -111,10 +94,10 @@ func (s *inspectionSummarySuite) TestInspectionSummary(c *C) {
))

// Test for select * from information_schema.inspection_summary without specify rules.
rs, err = tk.Se.Execute(ctx, "select * from information_schema.inspection_summary where metrics_name = 'tidb_qps'")
c.Assert(err, IsNil)
result = tk.ResultSetToResultWithCtx(ctx, rs[0], Commentf("execute inspect SQL failed"))
c.Assert(tk.Se.GetSessionVars().StmtCtx.WarningCount(), Equals, uint16(0), Commentf("unexpected warnings: %+v", tk.Se.GetSessionVars().StmtCtx.GetWarnings()))
rs, err = tk.Session().Execute(ctx, "select * from information_schema.inspection_summary where metrics_name = 'tidb_qps'")
require.NoError(t, err)
result = tk.ResultSetToResultWithCtx(ctx, rs[0], "execute inspect SQL failed")
require.Equal(t, tk.Session().GetSessionVars().StmtCtx.WarningCount(), "unexpected warnings: %+v", tk.Session().GetSessionVars().StmtCtx.GetWarnings())
result.Check(testkit.Rows(
"query-summary tidb-0 tidb_qps Query, Error <nil> 1 1 1 TiDB query processing numbers per second",
"query-summary tidb-0 tidb_qps Query, OK <nil> 0 0 0 TiDB query processing numbers per second",
Expand Down