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

Add integration test #1083

Merged
merged 45 commits into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
64bee06
test: init integration
shhdgit Dec 1, 2021
e354632
test: integration init
shhdgit Dec 1, 2021
59de412
test(integration): slowquery init
shhdgit Dec 2, 2021
886a2fb
test(*): refine tests scripts
shhdgit Dec 5, 2021
4a98ebc
test(slow_query): add db session
shhdgit Dec 5, 2021
ee8a5e9
Merge branch 'master' into test/integration
shhdgit Dec 5, 2021
95833fe
test: refine test scripts
shhdgit Dec 6, 2021
8f52c9d
Merge branch 'test/integration' of github.com:shhdgit/tidb-dashboard …
shhdgit Dec 6, 2021
ba7c7bb
Merge branch 'master' into test/integration
shhdgit Dec 6, 2021
4712414
test: update bin path
shhdgit Dec 6, 2021
074c180
test: echo profile
shhdgit Dec 6, 2021
7fb34c0
test: update source configs
shhdgit Dec 6, 2021
5c15f49
test: update integration log path
shhdgit Dec 6, 2021
9cc9b04
test: echo config path
shhdgit Dec 6, 2021
c51bc38
test: update tiup setup
shhdgit Dec 6, 2021
bd7eca7
test: update tiup usage
shhdgit Dec 7, 2021
f95f499
test: temp disable diagnose integration test
shhdgit Dec 7, 2021
eaa39b4
Merge branch 'master' into test/integration
shhdgit Dec 9, 2021
a1ce514
tweak: tiup teardown precisely
shhdgit Dec 15, 2021
3081b7a
test: slow query test
shhdgit Dec 16, 2021
8b890df
test: coverage
shhdgit Dec 16, 2021
8c5adce
chore: move integration tests
shhdgit Dec 16, 2021
2823bd7
test: compatibility test
shhdgit Dec 16, 2021
cd531f2
Merge branch 'master' into test/integration
shhdgit Dec 16, 2021
751c101
fix: bin not exist
shhdgit Dec 17, 2021
79aa642
ci: integration test matrix
shhdgit Dec 17, 2021
b244861
chore: dump tips
shhdgit Dec 17, 2021
ce0679c
test: split diagnose test
shhdgit Dec 17, 2021
ad1c13b
refine: test cases
shhdgit Dec 19, 2021
e67b261
tweak: compatibility tests
shhdgit Dec 19, 2021
e754113
tweak: compatibility test
shhdgit Dec 20, 2021
25c2bee
tweak: slowquery tests
shhdgit Dec 20, 2021
4c21254
fix: compatibility tests
shhdgit Dec 20, 2021
c7af711
test: add prev stmt search test
shhdgit Dec 20, 2021
38d3dac
tweak: close sys schema cache
shhdgit Dec 20, 2021
c611683
chore: rename TestCompatibilitySuite
shhdgit Dec 20, 2021
67e33ca
tweak: split create table workflow for local tests
shhdgit Dec 20, 2021
dd1d515
tweak: makefile phony definition
shhdgit Dec 20, 2021
7aef798
test: code coverage
shhdgit Dec 20, 2021
5d43c2d
test: code coverage
shhdgit Dec 20, 2021
27d2cfb
test: coverage flags
shhdgit Dec 20, 2021
f1d440a
chore: comments
shhdgit Dec 20, 2021
9404f95
chore: add badge to readme
shhdgit Dec 20, 2021
b57f6c7
Revert "chore: add badge to readme"
shhdgit Dec 20, 2021
8817949
chore: rename coverage flag
shhdgit Dec 20, 2021
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
Prev Previous commit
Next Next commit
test: split diagnose test
  • Loading branch information
shhdgit committed Dec 17, 2021
commit ce0679c3afe77d1db04513fcaa1fd9b1b16555dc
142 changes: 0 additions & 142 deletions pkg/apiserver/diagnose/report_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
// +build integration

// Copyright 2021 PingCAP, Inc. Licensed under Apache-2.0.

package diagnose

import (
"fmt"
"strings"
"testing"

. "github.com/pingcap/check"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)

func TestT(t *testing.T) {
Expand All @@ -23,98 +17,6 @@ var _ = Suite(&testReportSuite{})

type testReportSuite struct{}

//func (t *testReportSuite) TestReport(c *C) {
// cli, err := gorm.Open("mysql", "root:@tcp(172.16.5.40:4009)/test?charset=utf8&parseTime=True&loc=Local")
// c.Assert(err, IsNil)
// defer cli.Close()
//
// startTime := "2020-03-03 17:18:00"
// endTime := "2020-03-03 17:21:00"
//
// tables := GetReportTablesForDisplay(startTime, endTime, cli)
// for _, tbl := range tables {
// printRows(tbl)
// }
//}

func (t *testReportSuite) TestGetTable(c *C) {
cli, err := gorm.Open(mysql.Open("root:@tcp(172.16.5.40:4009)/test?charset=utf8&parseTime=True&loc=Local"))
c.Assert(err, IsNil)

startTime := "2020-03-25 23:00:00"
endTime := "2020-03-25 23:05:00"

var table TableDef
table, err = GetLoadTable(startTime, endTime, cli)
c.Assert(err, IsNil)
printRows(&table)
}

func (t *testReportSuite) TestGetCompareTable(c *C) {
cli, err := gorm.Open(mysql.Open("root:@tcp(172.16.5.40:4009)/test?charset=utf8&parseTime=True&loc=Local"))
c.Assert(err, IsNil)

//startTime1 := "2020-03-12 20:17:00"
//endTime1 := "2020-03-12 20:39:00"
//
//startTime2 := "2020-03-12 20:17:00"
//endTime2 := "2020-03-12 20:39:00"

startTime1 := "2020-04-02 12:13:00"
endTime1 := "2020-04-02 12:15:00"

startTime2 := "2020-04-02 12:15:00"
endTime2 := "2020-04-02 12:17:00"

tables := GetCompareReportTablesForDisplay(startTime1, endTime1, startTime2, endTime2, cli, nil, "ID")
for _, tbl := range tables {
printRows(tbl)
}
}

func (t *testReportSuite) TestInspection(c *C) {
cli, err := gorm.Open(mysql.Open("root:@tcp(172.16.5.40:4009)/test?charset=utf8&parseTime=True&loc=Local"))
c.Assert(err, IsNil)

// affect by big query join
startTime1 := "2020-03-08 01:36:00"
endTime1 := "2020-03-08 01:41:00"

startTime2 := "2020-03-08 01:46:30"
endTime2 := "2020-03-08 01:51:30"

// affect by big write with conflict
//startTime1 := "2020-03-10 12:35:00"
//endTime1 := "2020-03-10 12:39:00"
//
//startTime2 := "2020-03-10 12:41:00"
//endTime2 := "2020-03-10 12:45:00"

// affect by big write without conflict
//startTime1 := " 2020-03-10 13:20:00"
//endTime1 := " 2020-03-10 13:23:00"
//
//startTime2 := "2020-03-10 13:24:00"
//endTime2 := "2020-03-10 13:27:00"

// diagnose for server down
// startTime1 := "2020-03-09 20:35:00"
// endTime1 := "2020-03-09 21:20:00"
// startTime2 := "2020-03-08 20:35:00"
// endTime2 := "2020-03-09 21:20:00"

// diagnose for disk slow , need more disk metric.
//startTime1 := "2020-03-10 12:48:00"
//endTime1 := "2020-03-10 12:50:00"
//
//startTime2 := "2020-03-10 12:54:30"
//endTime2 := "2020-03-10 12:56:30"

table, errRow := CompareDiagnose(startTime1, endTime1, startTime2, endTime2, cli)
c.Assert(errRow, IsNil)
printRows(&table)
}

func (t *testReportSuite) TestCompareTable(c *C) {
table1 := TableDef{
Category: []string{"header"},
Expand Down Expand Up @@ -224,47 +126,3 @@ func (t *testReportSuite) TestRoundFloatString(c *C) {
c.Assert(result, Equals, cas.out)
}
}

func printRows(t *TableDef) {
if t == nil {
fmt.Println("table is nil")
return
}

fmt.Println(strings.Join(t.Category, " - "))
fmt.Println(t.Title)
fmt.Println(t.Comment)
if len(t.Rows) == 0 {
fmt.Println("table rows is 0")
return
}

fieldLen := t.ColumnWidth()
// fmt.Println(fieldLen)
printLine := func(values []string, comment string) {
line := ""
for i, s := range values {
for k := len(s); k < fieldLen[i]; k++ {
s += " "
}
if i > 0 {
line += " | "
}
line += s
}
if len(comment) != 0 {
line = line + " | " + comment
}
fmt.Println(line)
}

printLine(t.Column, "")

for _, row := range t.Rows {
printLine(row.Values, row.Comment)
for i := range row.SubValues {
printLine(row.SubValues[i], "")
}
}
fmt.Println("")
}
154 changes: 154 additions & 0 deletions tests/integration/diagnose_report_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
// Copyright 2021 PingCAP, Inc. Licensed under Apache-2.0.

package integration

import (
"testing"

. "github.com/pingcap/check"
)

func TestT(t *testing.T) {
CustomVerboseFlag = true
TestingT(t)
}

var _ = Suite(&testReportSuite{})

type testReportSuite struct{}

//func (t *testReportSuite) TestReport(c *C) {
// cli, err := gorm.Open("mysql", "root:@tcp(172.16.5.40:4009)/test?charset=utf8&parseTime=True&loc=Local")
// c.Assert(err, IsNil)
// defer cli.Close()
//
// startTime := "2020-03-03 17:18:00"
// endTime := "2020-03-03 17:21:00"
//
// tables := GetReportTablesForDisplay(startTime, endTime, cli)
// for _, tbl := range tables {
// printRows(tbl)
// }
//}

// func (t *testReportSuite) TestGetTable(c *C) {
// cli, err := gorm.Open(mysql.Open("root:@tcp(172.16.5.40:4009)/test?charset=utf8&parseTime=True&loc=Local"))
// c.Assert(err, IsNil)

// startTime := "2020-03-25 23:00:00"
// endTime := "2020-03-25 23:05:00"

// var table diagnose.TableDef
// table, err = diagnose.GetLoadTable(startTime, endTime, cli)
// c.Assert(err, IsNil)
// printRows(&table)
// }

// func (t *testReportSuite) TestGetCompareTable(c *C) {
// cli, err := gorm.Open(mysql.Open("root:@tcp(172.16.5.40:4009)/test?charset=utf8&parseTime=True&loc=Local"))
// c.Assert(err, IsNil)

// //startTime1 := "2020-03-12 20:17:00"
// //endTime1 := "2020-03-12 20:39:00"
// //
// //startTime2 := "2020-03-12 20:17:00"
// //endTime2 := "2020-03-12 20:39:00"

// startTime1 := "2020-04-02 12:13:00"
// endTime1 := "2020-04-02 12:15:00"

// startTime2 := "2020-04-02 12:15:00"
// endTime2 := "2020-04-02 12:17:00"

// tables := diagnose.GetCompareReportTablesForDisplay(startTime1, endTime1, startTime2, endTime2, cli, nil, "ID")
// for _, tbl := range tables {
// printRows(tbl)
// }
// }

// func (t *testReportSuite) TestInspection(c *C) {
// cli, err := gorm.Open(mysql.Open("root:@tcp(172.16.5.40:4009)/test?charset=utf8&parseTime=True&loc=Local"))
// c.Assert(err, IsNil)

// // affect by big query join
// startTime1 := "2020-03-08 01:36:00"
// endTime1 := "2020-03-08 01:41:00"

// startTime2 := "2020-03-08 01:46:30"
// endTime2 := "2020-03-08 01:51:30"

// // affect by big write with conflict
// //startTime1 := "2020-03-10 12:35:00"
// //endTime1 := "2020-03-10 12:39:00"
// //
// //startTime2 := "2020-03-10 12:41:00"
// //endTime2 := "2020-03-10 12:45:00"

// // affect by big write without conflict
// //startTime1 := " 2020-03-10 13:20:00"
// //endTime1 := " 2020-03-10 13:23:00"
// //
// //startTime2 := "2020-03-10 13:24:00"
// //endTime2 := "2020-03-10 13:27:00"

// // diagnose for server down
// // startTime1 := "2020-03-09 20:35:00"
// // endTime1 := "2020-03-09 21:20:00"
// // startTime2 := "2020-03-08 20:35:00"
// // endTime2 := "2020-03-09 21:20:00"

// // diagnose for disk slow , need more disk metric.
// //startTime1 := "2020-03-10 12:48:00"
// //endTime1 := "2020-03-10 12:50:00"
// //
// //startTime2 := "2020-03-10 12:54:30"
// //endTime2 := "2020-03-10 12:56:30"

// table, errRow := diagnose.CompareDiagnose(startTime1, endTime1, startTime2, endTime2, cli)
// c.Assert(errRow, IsNil)
// printRows(&table)
// }

// func printRows(t *diagnose.TableDef) {
// if t == nil {
// fmt.Println("table is nil")
// return
// }

// fmt.Println(strings.Join(t.Category, " - "))
// fmt.Println(t.Title)
// fmt.Println(t.Comment)
// if len(t.Rows) == 0 {
// fmt.Println("table rows is 0")
// return
// }

// fieldLen := t.ColumnWidth()
// // fmt.Println(fieldLen)
// printLine := func(values []string, comment string) {
// line := ""
// for i, s := range values {
// for k := len(s); k < fieldLen[i]; k++ {
// s += " "
// }
// if i > 0 {
// line += " | "
// }
// line += s
// }
// if len(comment) != 0 {
// line = line + " | " + comment
// }
// fmt.Println(line)
// }

// printLine(t.Column, "")

// for _, row := range t.Rows {
// printLine(row.Values, row.Comment)
// for i := range row.SubValues {
// printLine(row.SubValues[i], "")
// }
// }
// fmt.Println("")
// }
9 changes: 1 addition & 8 deletions tests/integration/v4_slowquery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,5 @@ func (s *testV4SlowQuerySuite) mustQuerySlowLogList(req *slowquery.GetListReques

func (s *testV4SlowQuerySuite) TestFieldsCompatibility() {
ds := s.mustQuerySlowLogList(&slowquery.GetListRequest{Fields: "*"})

for _, d := range ds {
s.Empty(d.RocksdbBlockCacheHitCount)
s.Empty(d.RocksdbBlockReadByte)
s.Empty(d.RocksdbBlockReadCount)
s.Empty(d.RocksdbDeleteSkippedCount)
s.Empty(d.RocksdbKeySkippedCount)
}
s.NotEmpty(ds)
}