From c564faa009f1614acb8c4f7a4b9ece9175d16a29 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Fri, 8 Mar 2024 12:09:55 +0800 Subject: [PATCH] fix the test Signed-off-by: Ryan Leung --- pkg/mcs/tso/server/server.go | 2 +- server/handler.go | 2 +- tests/integrations/tso/server_test.go | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/mcs/tso/server/server.go b/pkg/mcs/tso/server/server.go index bac93ddfb6bf..c79585f07c14 100644 --- a/pkg/mcs/tso/server/server.go +++ b/pkg/mcs/tso/server/server.go @@ -321,7 +321,7 @@ func (s *Server) SetExternalTS(externalTS uint64) error { // ResetTS resets the TSO with the specified one. func (s *Server) ResetTS(ts uint64, ignoreSmaller, skipUpperBoundCheck bool, keyspaceGroupID uint32) error { - log.Info("reset-ts", + log.Info("reset ts", zap.Uint64("new-ts", ts), zap.Bool("ignore-smaller", ignoreSmaller), zap.Bool("skip-upper-bound-check", skipUpperBoundCheck), diff --git a/server/handler.go b/server/handler.go index db7fa3f8952e..b403365983bf 100644 --- a/server/handler.go +++ b/server/handler.go @@ -413,7 +413,7 @@ func (h *Handler) GetSchedulerConfigHandler() (http.Handler, error) { // ResetTS resets the ts with specified tso. func (h *Handler) ResetTS(ts uint64, ignoreSmaller, skipUpperBoundCheck bool, _ uint32) error { - log.Info("reset-ts", + log.Info("reset ts", zap.Uint64("new-ts", ts), zap.Bool("ignore-smaller", ignoreSmaller), zap.Bool("skip-upper-bound-check", skipUpperBoundCheck)) diff --git a/tests/integrations/tso/server_test.go b/tests/integrations/tso/server_test.go index ac3d914aa80b..25d115f387be 100644 --- a/tests/integrations/tso/server_test.go +++ b/tests/integrations/tso/server_test.go @@ -23,7 +23,9 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/kvproto/pkg/tsopb" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/client/testutil" tso "github.com/tikv/pd/pkg/mcs/tso/server" + "github.com/tikv/pd/pkg/mcs/utils" tsopkg "github.com/tikv/pd/pkg/tso" "github.com/tikv/pd/pkg/utils/tempurl" tu "github.com/tikv/pd/pkg/utils/testutil" @@ -84,6 +86,13 @@ func (suite *tsoServerTestSuite) SetupSuite() { } else { suite.tsoServer, suite.tsoServerCleanup = tests.StartSingleTSOTestServer(suite.ctx, re, backendEndpoints, tempurl.Alloc()) suite.tsoClientConn, suite.tsoClient = tso.MustNewGrpcClient(re, suite.tsoServer.GetAddr()) + testutil.Eventually(re, func() bool { + am, err := suite.tsoServer.GetKeyspaceGroupManager().GetAllocatorManager(utils.DefaultKeyspaceGroupID) + if err != nil { + return false + } + return am.GetMember().IsLeaderElected() + }) } }