Skip to content

Commit

Permalink
topsql: update tipb for topsql (pingcap#25801)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 authored Jun 29, 2021
1 parent 731d490 commit 9c1e47a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ require (
github.com/pingcap/parser v0.0.0-20210618053735-57843e8185c4
github.com/pingcap/sysutil v0.0.0-20210315073920-cc0985d983a3
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible
github.com/pingcap/tipb v0.0.0-20210603161937-cfb5a9225f95
github.com/pingcap/tipb v0.0.0-20210628060001-1793e022b962
github.com/prometheus/client_golang v1.5.1
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.9.1
Expand Down Expand Up @@ -76,7 +76,6 @@ require (
golang.org/x/tools v0.1.0
google.golang.org/grpc v1.27.1
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
honnef.co/go/tools v0.2.0 // indirect
modernc.org/mathutil v1.2.2 // indirect
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ github.com/pingcap/sysutil v0.0.0-20210315073920-cc0985d983a3/go.mod h1:tckvA041
github.com/pingcap/tidb-dashboard v0.0.0-20210312062513-eef5d6404638/go.mod h1:OzFN8H0EDMMqeulPhPMw2i2JaiZWOKFQ7zdRPhENNgo=
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible h1:ceznmu/lLseGHP/jKyOa/3u/5H3wtLLLqkH2V3ssSjg=
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM=
github.com/pingcap/tipb v0.0.0-20210603161937-cfb5a9225f95 h1:Cj7FhGvYn8hrXDNcaHi0aTl0KdV67KTL+P5gBp3vqT4=
github.com/pingcap/tipb v0.0.0-20210603161937-cfb5a9225f95/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
github.com/pingcap/tipb v0.0.0-20210628060001-1793e022b962 h1:9Y9Eci9LwAEhyXAlAU0bSix7Nemm3G267oyN3GVK+j0=
github.com/pingcap/tipb v0.0.0-20210628060001-1793e022b962/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
8 changes: 4 additions & 4 deletions util/topsql/reporter/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ func (r *GRPCReportClient) sendBatchCPUTimeRecord(ctx context.Context, records m
}
for _, record := range records {
record := &tipb.CPUTimeRecord{
TimestampList: record.TimestampList,
CpuTimeMsList: record.CPUTimeMsList,
SqlDigest: record.SQLDigest,
PlanDigest: record.PlanDigest,
RecordListTimestampSec: record.TimestampList,
RecordListCpuTimeMs: record.CPUTimeMsList,
SqlDigest: record.SQLDigest,
PlanDigest: record.PlanDigest,
}
if err := stream.Send(record); err != nil {
return err
Expand Down
24 changes: 12 additions & 12 deletions util/topsql/reporter/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ func (s *testTopSQLReporter) TestCollectAndSendBatch(c *C) {
c.Assert(err, IsNil)
id = n
}
c.Assert(req.CpuTimeMsList, HasLen, 1)
for i := range req.CpuTimeMsList {
c.Assert(req.CpuTimeMsList[i], Equals, uint32(id))
c.Assert(req.RecordListCpuTimeMs, HasLen, 1)
for i := range req.RecordListCpuTimeMs {
c.Assert(req.RecordListCpuTimeMs[i], Equals, uint32(id))
}
c.Assert(req.TimestampList, HasLen, 1)
for i := range req.TimestampList {
c.Assert(req.TimestampList[i], Equals, uint64(1))
c.Assert(req.RecordListTimestampSec, HasLen, 1)
for i := range req.RecordListTimestampSec {
c.Assert(req.RecordListTimestampSec[i], Equals, uint64(1))
}
normalizedSQL, exist := agentServer.GetSQLMetaByDigestBlocking(req.SqlDigest, time.Second)
c.Assert(exist, IsTrue)
Expand Down Expand Up @@ -152,13 +152,13 @@ func (s *testTopSQLReporter) TestCollectAndEvicted(c *C) {
id = n
}
c.Assert(id >= maxSQLNum, IsTrue)
c.Assert(req.CpuTimeMsList, HasLen, 1)
for i := range req.CpuTimeMsList {
c.Assert(req.CpuTimeMsList[i], Equals, uint32(id))
c.Assert(req.RecordListCpuTimeMs, HasLen, 1)
for i := range req.RecordListCpuTimeMs {
c.Assert(req.RecordListCpuTimeMs[i], Equals, uint32(id))
}
c.Assert(req.TimestampList, HasLen, 1)
for i := range req.TimestampList {
c.Assert(req.TimestampList[i], Equals, uint64(2))
c.Assert(req.RecordListTimestampSec, HasLen, 1)
for i := range req.RecordListTimestampSec {
c.Assert(req.RecordListTimestampSec[i], Equals, uint64(2))
}
normalizedSQL, exist := agentServer.GetSQLMetaByDigestBlocking(req.SqlDigest, time.Second)
c.Assert(exist, IsTrue)
Expand Down
6 changes: 3 additions & 3 deletions util/topsql/topsql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ func (s *testSuite) TestTopSQLReporter(c *C) {
records := server.GetLatestRecords()
checkSQLPlanMap := map[string]struct{}{}
for _, req := range records {
c.Assert(len(req.CpuTimeMsList) > 0, IsTrue)
c.Assert(req.CpuTimeMsList[0] > 0, IsTrue)
c.Assert(req.TimestampList[0] > 0, IsTrue)
c.Assert(len(req.RecordListCpuTimeMs) > 0, IsTrue)
c.Assert(req.RecordListCpuTimeMs[0] > 0, IsTrue)
c.Assert(req.RecordListCpuTimeMs[0] > 0, IsTrue)
normalizedSQL, exist := server.GetSQLMetaByDigestBlocking(req.SqlDigest, time.Second)
c.Assert(exist, IsTrue)
expectedNormalizedSQL, exist := sqlMap[string(req.SqlDigest)]
Expand Down

0 comments on commit 9c1e47a

Please sign in to comment.