Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <admin@liudos.us>
  • Loading branch information
lhy1024 committed May 9, 2023
1 parent 210d61c commit 4c9a442
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions pkg/mcs/tso/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (s *Server) Run() error {
skipWaitAPIServiceReady = true
})
if !skipWaitAPIServiceReady {
if err := s.waitAPIServiceReady(s.ctx); err != nil {
if err := s.waitAPIServiceReady(); err != nil {
return err
}
}
Expand Down Expand Up @@ -534,17 +534,17 @@ func (s *Server) startServer() (err error) {
return nil
}

func (s *Server) waitAPIServiceReady(ctx context.Context) error {
func (s *Server) waitAPIServiceReady() error {
for i := 0; i < maxRetryTimesWaitAPIService; i++ {
ready, err := s.isAPIServiceReady(ctx)
ready, err := s.isAPIServiceReady()
if err != nil {
log.Warn("failed to check api server ready", errs.ZapError(err))
}
if ready {
return nil
}
select {
case <-ctx.Done():
case <-s.ctx.Done():
return errors.New("context canceled while waiting api server ready")
case <-time.After(retryIntervalWaitAPIService):
log.Debug("api server is not ready, retrying")
Expand All @@ -553,7 +553,7 @@ func (s *Server) waitAPIServiceReady(ctx context.Context) error {
return errors.Errorf("failed to wait api server ready after retrying %d times", maxRetryTimesWaitAPIService)
}

func (s *Server) isAPIServiceReady(ctx context.Context) (bool, error) {
func (s *Server) isAPIServiceReady() (bool, error) {
urls := strings.Split(s.cfg.BackendEndpoints, ",")
if len(urls) == 0 {
return false, errors.New("no backend endpoints")
Expand Down
8 changes: 6 additions & 2 deletions tests/integrations/tso/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,13 @@ func TestMixedTSODeployment(t *testing.T) {
re := require.New(t)

re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/tso/fastUpdatePhysicalInterval", "return(true)"))
defer re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/tso/fastUpdatePhysicalInterval"))
re.NoError(failpoint.Enable("github.com/tikv/pd/client/skipUpdateServiceMode", "return(true)"))
defer re.NoError(failpoint.Disable("github.com/tikv/pd/client/skipUpdateServiceMode"))
re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/mcs/tso/server/skipWaitAPIServiceReady", "return(true)"))
defer func() {
re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/tso/fastUpdatePhysicalInterval"))
re.NoError(failpoint.Disable("github.com/tikv/pd/client/skipUpdateServiceMode"))
re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/mcs/tso/server/skipWaitAPIServiceReady"))
}()

ctx, cancel := context.WithCancel(context.Background())
cluster, err := tests.NewTestCluster(ctx, 1)
Expand Down

0 comments on commit 4c9a442

Please sign in to comment.