Skip to content

Commit

Permalink
test: fix tests (#1696)
Browse files Browse the repository at this point in the history
* test: fix region syncer test

Signed-off-by: disksing <i@disksing.com>
  • Loading branch information
disksing authored and nolouch committed Aug 21, 2019
1 parent 16d7464 commit de7e9de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ func (s *Server) Tso(stream pdpb.PD_TsoServer) error {
}
start := time.Now()
// TSO uses leader lease to determine validity. No need to check leader here.
if s.IsClosed() {
return status.Errorf(codes.Unknown, "server not started")
}
if request.GetHeader().GetClusterId() != s.clusterID {
return status.Errorf(codes.FailedPrecondition, "mismatch cluster id, need %d but got %d", s.clusterID, request.GetHeader().GetClusterId())
}
Expand Down
2 changes: 1 addition & 1 deletion tests/server/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (s *serverTestSuite) TestReconnect(c *C) {
testutil.WaitUntil(c, func(c *C) bool {
res, err := http.Get(s.GetConfig().AdvertiseClientUrls + "/pd/api/v1/version")
c.Assert(err, IsNil)
return res.StatusCode == http.StatusInternalServerError
return res.StatusCode == http.StatusServiceUnavailable
})
}
}
Expand Down
5 changes: 3 additions & 2 deletions tests/server/region_syncer/region_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ func (s *serverTestSuite) TestRegionSyncer(c *C) {
err = rc.HandleRegionHeartbeat(region)
c.Assert(err, IsNil)
}
// ensure flush to region storage
time.Sleep(3 * time.Second)
// ensure flush to region storage, we use a duration larger than the
// region storage flush rate limit (3s).
time.Sleep(4 * time.Second)
err = leaderServer.Stop()
c.Assert(err, IsNil)
cluster.WaitLeader()
Expand Down

0 comments on commit de7e9de

Please sign in to comment.