Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch committed May 25, 2018
1 parent 28243b5 commit 2c7feb0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions server/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package server

import (
"fmt"
"math/rand"
"time"

. "github.com/pingcap/check"
Expand Down Expand Up @@ -236,6 +237,29 @@ func dispatchHeartbeat(c *C, co *coordinator, region *core.RegionInfo, stream *m
co.dispatch(region)
}

func (s *testCoordinatorSuite) TestCollectMetrics(c *C) {
_, opt := newTestScheduleConfig()
tc := newTestClusterInfo(opt)
hbStreams := newHeartbeatStreams(tc.getClusterID())
defer hbStreams.Close()

co := newCoordinator(tc.clusterInfo, hbStreams, namespace.DefaultClassifier)
co.run()

for i := 0; i <= 10; i++ {
go func(i int) {
for j := 0; j < 10000; j++ {
tc.addRegionStore(uint64(i%5), rand.Intn(200))
}
}(i)
}
for i := 0; i < 1000; i++ {
co.collectHotSpotMetrics()
co.collectSchedulerMetrics()
co.cluster.collectMetrics()
}
}

func (s *testCoordinatorSuite) TestCheckRegion(c *C) {
cfg, opt := newTestScheduleConfig()
cfg.DisableLearner = false
Expand Down

0 comments on commit 2c7feb0

Please sign in to comment.