-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
statistics: replace loads with []float64 in peer info (tikv#3729)
* statistics: replace loads with []float64 in peer info Signed-off-by: lhy1024 <admin@liudos.us> * remove unused code Signed-off-by: lhy1024 <admin@liudos.us> * address comment Signed-off-by: lhy1024 <admin@liudos.us> * address comment Signed-off-by: lhy1024 <admin@liudos.us> * remove unused code Signed-off-by: lhy1024 <admin@liudos.us> * fix test Signed-off-by: lhy1024 <admin@liudos.us> * address comment Signed-off-by: lhy1024 <admin@liudos.us> * misc Signed-off-by: lhy1024 <admin@liudos.us> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
- Loading branch information
1 parent
7792ece
commit 037d673
Showing
8 changed files
with
91 additions
and
96 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
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
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,46 @@ | ||
// Copyright 2021 TiKV Project Authors. | ||
// | ||
// 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, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package statistics | ||
|
||
import ( | ||
. "github.com/pingcap/check" | ||
"github.com/pingcap/kvproto/pkg/metapb" | ||
"github.com/tikv/pd/server/core" | ||
) | ||
|
||
var _ = Suite(&testRegionInfoSuite{}) | ||
|
||
type testRegionInfoSuite struct{} | ||
|
||
func (s *testRegionInfoSuite) TestGetLoads(c *C) { | ||
regionA := core.NewRegionInfo(&metapb.Region{Id: 100, Peers: []*metapb.Peer{}}, nil, | ||
core.SetReadBytes(1), | ||
core.SetReadKeys(2), | ||
core.SetWrittenBytes(3), | ||
core.SetWrittenKeys(4)) | ||
loads := regionA.GetLoads() | ||
c.Assert(loads, HasLen, int(RegionStatCount)) | ||
c.Assert(float64(regionA.GetBytesRead()), Equals, loads[RegionReadBytes]) | ||
c.Assert(float64(regionA.GetKeysRead()), Equals, loads[RegionReadKeys]) | ||
c.Assert(float64(regionA.GetBytesWritten()), Equals, loads[RegionWriteBytes]) | ||
c.Assert(float64(regionA.GetKeysWritten()), Equals, loads[RegionWriteKeys]) | ||
|
||
loads = regionA.GetWriteLoads() | ||
c.Assert(loads, HasLen, int(RegionStatCount)) | ||
c.Assert(0.0, Equals, loads[RegionReadBytes]) | ||
c.Assert(0.0, Equals, loads[RegionReadKeys]) | ||
c.Assert(float64(regionA.GetBytesWritten()), Equals, loads[RegionWriteBytes]) | ||
c.Assert(float64(regionA.GetKeysWritten()), Equals, loads[RegionWriteKeys]) | ||
|
||
} |