From 9eab28f6a2e91e9152bbe61439269e0aeb33fdae Mon Sep 17 00:00:00 2001 From: okJiang <819421878@qq.com> Date: Thu, 11 Jul 2024 15:28:34 +0800 Subject: [PATCH] test: check leader not ready in test (#8380) ref tikv/pd#8350 Signed-off-by: okJiang <819421878@qq.com> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- tests/autoscaling/autoscaling_test.go | 2 +- tests/compatibility/version_upgrade_test.go | 8 ++++---- tests/dashboard/race_test.go | 2 +- tests/dashboard/service_test.go | 2 +- tests/integrations/client/client_test.go | 2 +- .../integrations/mcs/discovery/register_test.go | 1 + .../resourcemanager/resource_manager_test.go | 3 ++- .../mcs/resourcemanager/server_test.go | 1 + .../integrations/mcs/scheduling/config_test.go | 1 + tests/integrations/mcs/scheduling/meta_test.go | 1 + tests/integrations/mcs/scheduling/rule_test.go | 1 + .../integrations/mcs/scheduling/server_test.go | 3 +++ tests/integrations/mcs/tso/api_test.go | 2 ++ .../mcs/tso/keyspace_group_manager_test.go | 1 + tests/integrations/mcs/tso/proxy_test.go | 1 + tests/integrations/mcs/tso/server_test.go | 5 +++++ tests/integrations/tso/client_test.go | 6 ++++++ tests/integrations/tso/consistency_test.go | 1 + tests/integrations/tso/server_test.go | 1 + tests/server/api/api_test.go | 4 ++-- tests/server/cluster/cluster_work_test.go | 6 +++--- tests/server/id/id_test.go | 14 +++++++------- tests/server/join/join_fail/join_fail_test.go | 2 +- tests/server/join/join_test.go | 8 ++++---- tests/server/member/member_test.go | 17 ++++++++++------- .../server/region_syncer/region_syncer_test.go | 10 +++++----- tests/server/storage/hot_region_storage_test.go | 6 +++--- tests/server/tso/global_tso_test.go | 6 +++--- tests/server/tso/tso_test.go | 2 +- tests/server/watch/leader_watch_test.go | 8 ++++---- tools/pd-backup/tests/backup_test.go | 2 +- tools/pd-ctl/tests/cluster/cluster_test.go | 2 +- tools/pd-ctl/tests/config/config_test.go | 2 +- tools/pd-ctl/tests/hot/hot_test.go | 4 ++-- tools/pd-ctl/tests/label/label_test.go | 2 +- tools/pd-ctl/tests/log/log_test.go | 2 +- tools/pd-ctl/tests/member/member_test.go | 6 +++--- tools/pd-ctl/tests/region/region_test.go | 6 +++--- .../resource_manager_command_test.go | 2 +- tools/pd-ctl/tests/store/store_test.go | 10 +++++----- .../tests/unsafe/unsafe_operation_test.go | 2 +- 41 files changed, 98 insertions(+), 69 deletions(-) diff --git a/tests/autoscaling/autoscaling_test.go b/tests/autoscaling/autoscaling_test.go index 663bc92f562..10d10378323 100644 --- a/tests/autoscaling/autoscaling_test.go +++ b/tests/autoscaling/autoscaling_test.go @@ -40,7 +40,7 @@ func TestAPI(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() re.NoError(leaderServer.BootstrapCluster()) diff --git a/tests/compatibility/version_upgrade_test.go b/tests/compatibility/version_upgrade_test.go index 8979d85c9bb..27eb07b0da2 100644 --- a/tests/compatibility/version_upgrade_test.go +++ b/tests/compatibility/version_upgrade_test.go @@ -37,7 +37,7 @@ func TestStoreRegister(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() re.NoError(leaderServer.BootstrapCluster()) @@ -54,14 +54,14 @@ func TestStoreRegister(t *testing.T) { _, err = svr.PutStore(context.Background(), putStoreRequest) re.NoError(err) // FIX ME: read v0.0.0 in sometime - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) version := leaderServer.GetClusterVersion() // Restart all PDs. err = cluster.StopAll() re.NoError(err) err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer = cluster.GetLeaderServer() re.NotNil(leaderServer) @@ -91,7 +91,7 @@ func TestRollingUpgrade(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() re.NoError(leaderServer.BootstrapCluster()) diff --git a/tests/dashboard/race_test.go b/tests/dashboard/race_test.go index db2d7b2e197..ad2d673f40d 100644 --- a/tests/dashboard/race_test.go +++ b/tests/dashboard/race_test.go @@ -35,7 +35,7 @@ func TestCancelDuringStarting(t *testing.T) { re.NoError(err) defer cluster.Destroy() re.NoError(cluster.RunInitialServers()) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) time.Sleep(60 * time.Millisecond) cancel() diff --git a/tests/dashboard/service_test.go b/tests/dashboard/service_test.go index aa4d0f337f9..e689b1d4662 100644 --- a/tests/dashboard/service_test.go +++ b/tests/dashboard/service_test.go @@ -131,7 +131,7 @@ func (suite *dashboardTestSuite) testDashboard(re *require.Assertions, internalP err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) servers := cluster.GetServers() leader := cluster.GetLeaderServer() leaderAddr := leader.GetAddr() diff --git a/tests/integrations/client/client_test.go b/tests/integrations/client/client_test.go index 07824c5483a..2e51c7080e9 100644 --- a/tests/integrations/client/client_test.go +++ b/tests/integrations/client/client_test.go @@ -656,7 +656,7 @@ func (suite *followerForwardAndHandleTestSuite) SetupSuite() { re.NoError(err) suite.cluster = cluster suite.endpoints = runServer(re, cluster) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leader := cluster.GetLeaderServer() grpcPDClient := testutil.MustNewGrpcClient(re, leader.GetAddr()) suite.regionID = regionIDAllocator.alloc() diff --git a/tests/integrations/mcs/discovery/register_test.go b/tests/integrations/mcs/discovery/register_test.go index 69d53463818..baf3442226a 100644 --- a/tests/integrations/mcs/discovery/register_test.go +++ b/tests/integrations/mcs/discovery/register_test.go @@ -60,6 +60,7 @@ func (suite *serverRegisterTestSuite) SetupSuite() { re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeader = suite.cluster.GetServer(leaderName) suite.clusterID = strconv.FormatUint(suite.pdLeader.GetClusterID(), 10) suite.backendEndpoints = suite.pdLeader.GetAddr() diff --git a/tests/integrations/mcs/resourcemanager/resource_manager_test.go b/tests/integrations/mcs/resourcemanager/resource_manager_test.go index c8cee89cf32..66150ef34e0 100644 --- a/tests/integrations/mcs/resourcemanager/resource_manager_test.go +++ b/tests/integrations/mcs/resourcemanager/resource_manager_test.go @@ -78,6 +78,7 @@ func (suite *resourceManagerClientTestSuite) SetupSuite() { suite.client, err = pd.NewClientWithContext(suite.ctx, suite.cluster.GetConfig().GetClientURLs(), pd.SecurityOption{}) re.NoError(err) leader := suite.cluster.GetServer(suite.cluster.WaitLeader()) + re.NotNil(leader) waitLeader(re, suite.client, leader.GetAddr()) suite.initGroups = []*rmpb.ResourceGroup{ @@ -1046,7 +1047,7 @@ func (suite *resourceManagerClientTestSuite) TestBasicResourceGroupCURD() { serverList = append(serverList, s) } re.NoError(tests.RunServers(serverList)) - suite.cluster.WaitLeader() + re.NotEmpty(suite.cluster.WaitLeader()) // re-connect client as well suite.client, err = pd.NewClientWithContext(suite.ctx, suite.cluster.GetConfig().GetClientURLs(), pd.SecurityOption{}) re.NoError(err) diff --git a/tests/integrations/mcs/resourcemanager/server_test.go b/tests/integrations/mcs/resourcemanager/server_test.go index 24de29db3a6..eaeef99e9d6 100644 --- a/tests/integrations/mcs/resourcemanager/server_test.go +++ b/tests/integrations/mcs/resourcemanager/server_test.go @@ -43,6 +43,7 @@ func TestResourceManagerServer(t *testing.T) { re.NoError(err) leaderName := cluster.WaitLeader() + re.NotEmpty(leaderName) leader := cluster.GetServer(leaderName) s, cleanup := tests.StartSingleResourceManagerTestServer(ctx, re, leader.GetAddr(), tempurl.Alloc()) diff --git a/tests/integrations/mcs/scheduling/config_test.go b/tests/integrations/mcs/scheduling/config_test.go index 54622d5c515..168d3a8742c 100644 --- a/tests/integrations/mcs/scheduling/config_test.go +++ b/tests/integrations/mcs/scheduling/config_test.go @@ -64,6 +64,7 @@ func (suite *configTestSuite) SetupSuite() { err = suite.cluster.RunInitialServers() re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeaderServer = suite.cluster.GetServer(leaderName) re.NoError(suite.pdLeaderServer.BootstrapCluster()) // Force the coordinator to be prepared to initialize the schedulers. diff --git a/tests/integrations/mcs/scheduling/meta_test.go b/tests/integrations/mcs/scheduling/meta_test.go index 11782590ab9..f1a8805e207 100644 --- a/tests/integrations/mcs/scheduling/meta_test.go +++ b/tests/integrations/mcs/scheduling/meta_test.go @@ -55,6 +55,7 @@ func (suite *metaTestSuite) SetupSuite() { err = suite.cluster.RunInitialServers() re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeaderServer = suite.cluster.GetServer(leaderName) re.NoError(suite.pdLeaderServer.BootstrapCluster()) } diff --git a/tests/integrations/mcs/scheduling/rule_test.go b/tests/integrations/mcs/scheduling/rule_test.go index 761e9b1ecbc..e8b394ec075 100644 --- a/tests/integrations/mcs/scheduling/rule_test.go +++ b/tests/integrations/mcs/scheduling/rule_test.go @@ -53,6 +53,7 @@ func (suite *ruleTestSuite) SetupSuite() { err = suite.cluster.RunInitialServers() re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeaderServer = suite.cluster.GetServer(leaderName) suite.backendEndpoint = suite.pdLeaderServer.GetAddr() re.NoError(suite.pdLeaderServer.BootstrapCluster()) diff --git a/tests/integrations/mcs/scheduling/server_test.go b/tests/integrations/mcs/scheduling/server_test.go index 0eda33130ce..3234c5cd1e6 100644 --- a/tests/integrations/mcs/scheduling/server_test.go +++ b/tests/integrations/mcs/scheduling/server_test.go @@ -70,6 +70,7 @@ func (suite *serverTestSuite) SetupSuite() { re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeader = suite.cluster.GetServer(leaderName) suite.backendEndpoints = suite.pdLeader.GetAddr() re.NoError(suite.pdLeader.BootstrapCluster()) @@ -116,6 +117,7 @@ func (suite *serverTestSuite) TestAllocIDAfterLeaderChange() { re.NotEqual(uint64(0), id) suite.cluster.ResignLeader() leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeader = suite.cluster.GetServer(leaderName) suite.backendEndpoints = suite.pdLeader.GetAddr() time.Sleep(time.Second) @@ -635,6 +637,7 @@ func (suite *multipleServerTestSuite) SetupSuite() { re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeader = suite.cluster.GetServer(leaderName) suite.backendEndpoints = suite.pdLeader.GetAddr() re.NoError(suite.pdLeader.BootstrapCluster()) diff --git a/tests/integrations/mcs/tso/api_test.go b/tests/integrations/mcs/tso/api_test.go index 4d6f9b33e3b..a07ad53f906 100644 --- a/tests/integrations/mcs/tso/api_test.go +++ b/tests/integrations/mcs/tso/api_test.go @@ -65,6 +65,7 @@ func (suite *tsoAPITestSuite) SetupTest() { err = suite.pdCluster.RunInitialServers() re.NoError(err) leaderName := suite.pdCluster.WaitLeader() + re.NotEmpty(leaderName) pdLeaderServer := suite.pdCluster.GetServer(leaderName) re.NoError(pdLeaderServer.BootstrapCluster()) suite.backendEndpoints = pdLeaderServer.GetAddr() @@ -155,6 +156,7 @@ func TestTSOServerStartFirst(t *testing.T) { err = apiCluster.RunInitialServers() re.NoError(err) leaderName := apiCluster.WaitLeader() + re.NotEmpty(leaderName) pdLeaderServer := apiCluster.GetServer(leaderName) re.NoError(pdLeaderServer.BootstrapCluster()) re.NoError(err) diff --git a/tests/integrations/mcs/tso/keyspace_group_manager_test.go b/tests/integrations/mcs/tso/keyspace_group_manager_test.go index 31aa5ee704e..2acbbcc3b42 100644 --- a/tests/integrations/mcs/tso/keyspace_group_manager_test.go +++ b/tests/integrations/mcs/tso/keyspace_group_manager_test.go @@ -82,6 +82,7 @@ func (suite *tsoKeyspaceGroupManagerTestSuite) SetupSuite() { err = suite.cluster.RunInitialServers() re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeaderServer = suite.cluster.GetServer(leaderName) re.NoError(suite.pdLeaderServer.BootstrapCluster()) suite.tsoCluster, err = tests.NewTestTSOCluster(suite.ctx, 2, suite.pdLeaderServer.GetAddr()) diff --git a/tests/integrations/mcs/tso/proxy_test.go b/tests/integrations/mcs/tso/proxy_test.go index 43877f262e2..e865d8b8a0c 100644 --- a/tests/integrations/mcs/tso/proxy_test.go +++ b/tests/integrations/mcs/tso/proxy_test.go @@ -65,6 +65,7 @@ func (s *tsoProxyTestSuite) SetupSuite() { err = s.apiCluster.RunInitialServers() re.NoError(err) leaderName := s.apiCluster.WaitLeader() + re.NotEmpty(leaderName) s.apiLeader = s.apiCluster.GetServer(leaderName) s.backendEndpoints = s.apiLeader.GetAddr() re.NoError(s.apiLeader.BootstrapCluster()) diff --git a/tests/integrations/mcs/tso/server_test.go b/tests/integrations/mcs/tso/server_test.go index 29d396b3d2e..598bfd53303 100644 --- a/tests/integrations/mcs/tso/server_test.go +++ b/tests/integrations/mcs/tso/server_test.go @@ -77,6 +77,7 @@ func (suite *tsoServerTestSuite) SetupSuite() { re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeader = suite.cluster.GetServer(leaderName) suite.backendEndpoints = suite.pdLeader.GetAddr() re.NoError(suite.pdLeader.BootstrapCluster()) @@ -173,6 +174,7 @@ func checkTSOPath(re *require.Assertions, isAPIServiceMode bool) { err = cluster.RunInitialServers() re.NoError(err) leaderName := cluster.WaitLeader() + re.NotEmpty(leaderName) pdLeader := cluster.GetServer(leaderName) re.NoError(pdLeader.BootstrapCluster()) backendEndpoints := pdLeader.GetAddr() @@ -226,6 +228,7 @@ func TestWaitAPIServiceReady(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) leaderName := cluster.WaitLeader() + re.NotEmpty(leaderName) pdLeader := cluster.GetServer(leaderName) return cluster, pdLeader.GetAddr() } @@ -283,6 +286,7 @@ func NewAPIServerForward(re *require.Assertions) APIServerForward { re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeader = suite.cluster.GetServer(leaderName) suite.backendEndpoints = suite.pdLeader.GetAddr() re.NoError(suite.pdLeader.BootstrapCluster()) @@ -557,6 +561,7 @@ func (suite *CommonTestSuite) SetupSuite() { re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeader = suite.cluster.GetServer(leaderName) suite.backendEndpoints = suite.pdLeader.GetAddr() re.NoError(suite.pdLeader.BootstrapCluster()) diff --git a/tests/integrations/tso/client_test.go b/tests/integrations/tso/client_test.go index f229c4782bb..bb721e6c5dd 100644 --- a/tests/integrations/tso/client_test.go +++ b/tests/integrations/tso/client_test.go @@ -97,6 +97,7 @@ func (suite *tsoClientTestSuite) SetupSuite() { err = suite.cluster.RunInitialServers() re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeaderServer = suite.cluster.GetServer(leaderName) re.NoError(suite.pdLeaderServer.BootstrapCluster()) suite.backendEndpoints = suite.pdLeaderServer.GetAddr() @@ -331,10 +332,12 @@ func (suite *tsoClientTestSuite) TestUpdateAfterResetTSO() { // Resign leader to trigger the TSO resetting. re.NoError(failpoint.Enable("github.com/tikv/pd/server/updateAfterResetTSO", "return(true)")) oldLeaderName := suite.cluster.WaitLeader() + re.NotEmpty(oldLeaderName) err := suite.cluster.GetServer(oldLeaderName).ResignLeader() re.NoError(err) re.NoError(failpoint.Disable("github.com/tikv/pd/server/updateAfterResetTSO")) newLeaderName := suite.cluster.WaitLeader() + re.NotEmpty(newLeaderName) re.NotEqual(oldLeaderName, newLeaderName) // Request a new TSO. testutil.Eventually(re, func() bool { @@ -494,6 +497,7 @@ func TestMixedTSODeployment(t *testing.T) { re.NoError(err) leaderServer := cluster.GetServer(cluster.WaitLeader()) + re.NotNil(leaderServer) backendEndpoints := leaderServer.GetAddr() apiSvr, err := cluster.JoinAPIServer(ctx) @@ -516,6 +520,7 @@ func TestMixedTSODeployment(t *testing.T) { time.Sleep(time.Duration(n) * time.Second) leaderServer.ResignLeader() leaderServer = cluster.GetServer(cluster.WaitLeader()) + re.NotNil(leaderServer) } cancel1() }() @@ -534,6 +539,7 @@ func TestUpgradingAPIandTSOClusters(t *testing.T) { err = apiCluster.RunInitialServers() re.NoError(err) leaderName := apiCluster.WaitLeader() + re.NotEmpty(leaderName) pdLeader := apiCluster.GetServer(leaderName) backendEndpoints := pdLeader.GetAddr() diff --git a/tests/integrations/tso/consistency_test.go b/tests/integrations/tso/consistency_test.go index 37c1441bc80..9ebe6dec8af 100644 --- a/tests/integrations/tso/consistency_test.go +++ b/tests/integrations/tso/consistency_test.go @@ -79,6 +79,7 @@ func (suite *tsoConsistencyTestSuite) SetupSuite() { err = suite.cluster.RunInitialServers() re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeaderServer = suite.cluster.GetServer(leaderName) backendEndpoints := suite.pdLeaderServer.GetAddr() if suite.legacy { diff --git a/tests/integrations/tso/server_test.go b/tests/integrations/tso/server_test.go index 5590ba68d37..5e14611ab65 100644 --- a/tests/integrations/tso/server_test.go +++ b/tests/integrations/tso/server_test.go @@ -77,6 +77,7 @@ func (suite *tsoServerTestSuite) SetupSuite() { err = suite.cluster.RunInitialServers() re.NoError(err) leaderName := suite.cluster.WaitLeader() + re.NotEmpty(leaderName) suite.pdLeaderServer = suite.cluster.GetServer(leaderName) backendEndpoints := suite.pdLeaderServer.GetAddr() if suite.legacy { diff --git a/tests/server/api/api_test.go b/tests/server/api/api_test.go index f59e85651f5..234d603b58d 100644 --- a/tests/server/api/api_test.go +++ b/tests/server/api/api_test.go @@ -742,7 +742,7 @@ func TestRemovingProgress(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leader := cluster.GetLeaderServer() grpcPDClient := testutil.MustNewGrpcClient(re, leader.GetAddr()) clusterID := leader.GetClusterID() @@ -938,7 +938,7 @@ func TestPreparingProgress(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leader := cluster.GetLeaderServer() grpcPDClient := testutil.MustNewGrpcClient(re, leader.GetAddr()) clusterID := leader.GetClusterID() diff --git a/tests/server/cluster/cluster_work_test.go b/tests/server/cluster/cluster_work_test.go index 530e15f3f8c..85a2249095b 100644 --- a/tests/server/cluster/cluster_work_test.go +++ b/tests/server/cluster/cluster_work_test.go @@ -40,7 +40,7 @@ func TestValidRequestRegion(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() grpcPDClient := testutil.MustNewGrpcClient(re, leaderServer.GetAddr()) clusterID := leaderServer.GetClusterID() @@ -84,7 +84,7 @@ func TestAskSplit(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() grpcPDClient := testutil.MustNewGrpcClient(re, leaderServer.GetAddr()) clusterID := leaderServer.GetClusterID() @@ -141,7 +141,7 @@ func TestSuspectRegions(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() grpcPDClient := testutil.MustNewGrpcClient(re, leaderServer.GetAddr()) clusterID := leaderServer.GetClusterID() diff --git a/tests/server/id/id_test.go b/tests/server/id/id_test.go index 4742424d9b5..6a7c1a9a028 100644 --- a/tests/server/id/id_test.go +++ b/tests/server/id/id_test.go @@ -43,7 +43,7 @@ func TestID(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() var last uint64 @@ -89,7 +89,7 @@ func TestCommand(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() req := &pdpb.AllocIDRequest{Header: testutil.NewRequestHeader(leaderServer.GetClusterID())} @@ -115,7 +115,7 @@ func TestMonotonicID(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() var last1 uint64 @@ -127,7 +127,7 @@ func TestMonotonicID(t *testing.T) { } err = cluster.ResignLeader() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer = cluster.GetLeaderServer() var last2 uint64 for i := uint64(0); i < 10; i++ { @@ -138,7 +138,7 @@ func TestMonotonicID(t *testing.T) { } err = cluster.ResignLeader() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer = cluster.GetLeaderServer() id, err := leaderServer.GetAllocator().Alloc() re.NoError(err) @@ -162,7 +162,7 @@ func TestPDRestart(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() var last uint64 @@ -175,7 +175,7 @@ func TestPDRestart(t *testing.T) { re.NoError(leaderServer.Stop()) re.NoError(leaderServer.Run()) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) for i := uint64(0); i < 10; i++ { id, err := leaderServer.GetAllocator().Alloc() diff --git a/tests/server/join/join_fail/join_fail_test.go b/tests/server/join/join_fail/join_fail_test.go index 26dca0d3b52..12774f366f0 100644 --- a/tests/server/join/join_fail/join_fail_test.go +++ b/tests/server/join/join_fail/join_fail_test.go @@ -33,7 +33,7 @@ func TestFailedPDJoinInStep1(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) // Join the second PD. re.NoError(failpoint.Enable("github.com/tikv/pd/server/join/add-member-failed", `return`)) diff --git a/tests/server/join/join_test.go b/tests/server/join/join_test.go index 32e66c27589..a9d2a69c5e4 100644 --- a/tests/server/join/join_test.go +++ b/tests/server/join/join_test.go @@ -43,7 +43,7 @@ func TestSimpleJoin(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) pd1 := cluster.GetServer("pd1") client := pd1.GetEtcdClient() @@ -92,7 +92,7 @@ func TestFailedAndDeletedPDJoinsPreviousCluster(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) // Wait for all nodes becoming healthy. time.Sleep(time.Second * 5) @@ -125,7 +125,7 @@ func TestDeletedPDJoinsPreviousCluster(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) // Wait for all nodes becoming healthy. time.Sleep(time.Second * 5) @@ -155,7 +155,7 @@ func TestFailedPDJoinsPreviousCluster(t *testing.T) { re.NoError(err) re.NoError(cluster.RunInitialServers()) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) // Join the second PD. pd2, err := cluster.Join(ctx) diff --git a/tests/server/member/member_test.go b/tests/server/member/member_test.go index edff14a3b98..6cd9eacddf1 100644 --- a/tests/server/member/member_test.go +++ b/tests/server/member/member_test.go @@ -102,7 +102,7 @@ func TestMemberDelete(t *testing.T) { return true } // Check by member list. - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) if err = checkMemberList(re, leader.GetConfig().ClientUrls, table.members); err != nil { t.Logf("check member fail: %v", err) time.Sleep(time.Second) @@ -159,7 +159,7 @@ func TestLeaderPriority(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leader1, err := cluster.GetServer("pd1").GetEtcdLeader() re.NoError(err) @@ -216,6 +216,7 @@ func TestLeaderResign(t *testing.T) { re.NoError(err) leader1 := cluster.WaitLeader() + re.NotEmpty(leader1) addr1 := cluster.GetServer(leader1).GetConfig().ClientUrls post(t, re, addr1+"/pd/api/v1/leader/resign", "") @@ -239,6 +240,7 @@ func TestLeaderResignWithBlock(t *testing.T) { re.NoError(err) leader1 := cluster.WaitLeader() + re.NotEmpty(leader1) addr1 := cluster.GetServer(leader1).GetConfig().ClientUrls re.NoError(failpoint.Enable("github.com/tikv/pd/server/raftclusterIsBusy", `pause`)) @@ -261,6 +263,7 @@ func TestPDLeaderLostWhileEtcdLeaderIntact(t *testing.T) { re.NoError(err) leader1 := cluster.WaitLeader() + re.NotEmpty(leader1) memberID := cluster.GetLeaderServer().GetLeader().GetMemberId() re.NoError(failpoint.Enable("github.com/tikv/pd/server/leaderLoopCheckAgain", fmt.Sprintf("return(\"%d\")", memberID))) @@ -295,7 +298,7 @@ func TestMoveLeader(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) var wg sync.WaitGroup wg.Add(5) @@ -342,12 +345,12 @@ func TestCampaignLeaderFrequently(t *testing.T) { // need to prevent 3 times(including the above 1st time) campaign leader in 5 min. for i := 0; i < 2; i++ { cluster.GetLeaderServer().ResetPDLeader() - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) re.Equal(leader, cluster.GetLeader()) } // check for the 4th time. cluster.GetLeaderServer().ResetPDLeader() - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) // PD leader should be different from before because etcd leader changed. re.NotEmpty(cluster.GetLeader()) re.NotEqual(leader, cluster.GetLeader()) @@ -363,14 +366,14 @@ func TestGrantLeaseFailed(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leader := cluster.GetLeader() re.NotEmpty(cluster.GetLeader()) re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/election/skipGrantLeader", fmt.Sprintf("return(\"%s\")", leader))) for i := 0; i < 3; i++ { cluster.GetLeaderServer().ResetPDLeader() - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) } // PD leader should be different from before because etcd leader changed. re.NotEmpty(cluster.GetLeader()) diff --git a/tests/server/region_syncer/region_syncer_test.go b/tests/server/region_syncer/region_syncer_test.go index 4803f7e6823..2015f520a91 100644 --- a/tests/server/region_syncer/region_syncer_test.go +++ b/tests/server/region_syncer/region_syncer_test.go @@ -48,7 +48,7 @@ func TestRegionSyncer(t *testing.T) { re.NoError(err) re.NoError(cluster.RunInitialServers()) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() re.NoError(leaderServer.BootstrapCluster()) @@ -140,7 +140,7 @@ func TestRegionSyncer(t *testing.T) { err = leaderServer.Stop() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer = cluster.GetLeaderServer() testutil.Eventually(re, func() bool { return !leaderServer.GetServer().GetRaftCluster().GetRegionSyncer().IsRunning() @@ -169,7 +169,7 @@ func TestFullSyncWithAddMember(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() re.NoError(leaderServer.BootstrapCluster()) rc := leaderServer.GetServer().GetRaftCluster() @@ -213,7 +213,7 @@ func TestPrepareChecker(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() re.NoError(leaderServer.BootstrapCluster()) rc := leaderServer.GetServer().GetRaftCluster() @@ -264,7 +264,7 @@ func TestPrepareCheckerWithTransferLeader(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() re.NoError(leaderServer.BootstrapCluster()) rc := leaderServer.GetServer().GetRaftCluster() diff --git a/tests/server/storage/hot_region_storage_test.go b/tests/server/storage/hot_region_storage_test.go index b63b533bc0f..2eccb4b28e9 100644 --- a/tests/server/storage/hot_region_storage_test.go +++ b/tests/server/storage/hot_region_storage_test.go @@ -46,7 +46,7 @@ func TestHotRegionStorage(t *testing.T) { re.NoError(err) err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) stores := []*metapb.Store{ { Id: 1, @@ -154,7 +154,7 @@ func TestHotRegionStorageReservedDayConfigChange(t *testing.T) { re.NoError(err) err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) stores := []*metapb.Store{ { Id: 1, @@ -246,7 +246,7 @@ func TestHotRegionStorageWriteIntervalConfigChange(t *testing.T) { re.NoError(err) err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) stores := []*metapb.Store{ { Id: 1, diff --git a/tests/server/tso/global_tso_test.go b/tests/server/tso/global_tso_test.go index 8dd98b1d628..d8f64afe871 100644 --- a/tests/server/tso/global_tso_test.go +++ b/tests/server/tso/global_tso_test.go @@ -51,7 +51,7 @@ func TestRequestFollower(t *testing.T) { defer cluster.Destroy() re.NoError(cluster.RunInitialServers()) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) var followerServer *tests.TestServer for _, s := range cluster.GetServers() { @@ -94,7 +94,7 @@ func TestDelaySyncTimestamp(t *testing.T) { re.NoError(err) defer cluster.Destroy() re.NoError(cluster.RunInitialServers()) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) var leaderServer, nextLeaderServer *tests.TestServer leaderServer = cluster.GetLeaderServer() @@ -143,7 +143,7 @@ func TestLogicalOverflow(t *testing.T) { defer cluster.Destroy() re.NoError(err) re.NoError(cluster.RunInitialServers()) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() grpcPDClient := testutil.MustNewGrpcClient(re, leaderServer.GetAddr()) diff --git a/tests/server/tso/tso_test.go b/tests/server/tso/tso_test.go index 9eff1192e57..5be37e293cf 100644 --- a/tests/server/tso/tso_test.go +++ b/tests/server/tso/tso_test.go @@ -122,7 +122,7 @@ func TestDisableLocalTSOAfterEnabling(t *testing.T) { server.SetEnableLocalTSO(false) } re.NoError(cluster.RunInitialServers()) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) // Re-request the global TSOs. leaderServer := cluster.GetLeaderServer() diff --git a/tests/server/watch/leader_watch_test.go b/tests/server/watch/leader_watch_test.go index 84e16398677..863cf7a0c08 100644 --- a/tests/server/watch/leader_watch_test.go +++ b/tests/server/watch/leader_watch_test.go @@ -41,7 +41,7 @@ func TestWatcher(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) pd1 := cluster.GetLeaderServer() re.NotNil(pd1) @@ -49,7 +49,7 @@ func TestWatcher(t *testing.T) { re.NoError(err) err = pd2.Run() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) time.Sleep(5 * time.Second) pd3, err := cluster.Join(ctx) @@ -61,7 +61,7 @@ func TestWatcher(t *testing.T) { re.Equal(pd1.GetConfig().Name, pd3.GetLeader().GetName()) err = pd1.Stop() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) re.Equal(pd2.GetConfig().Name, pd2.GetLeader().GetName()) re.NoError(failpoint.Disable("github.com/tikv/pd/server/delayWatcher")) testutil.Eventually(re, func() bool { @@ -79,7 +79,7 @@ func TestWatcherCompacted(t *testing.T) { err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) pd1 := cluster.GetLeaderServer() re.NotNil(pd1) client := pd1.GetEtcdClient() diff --git a/tools/pd-backup/tests/backup_test.go b/tools/pd-backup/tests/backup_test.go index d7b7e613be9..83a465e94fe 100644 --- a/tools/pd-backup/tests/backup_test.go +++ b/tools/pd-backup/tests/backup_test.go @@ -36,7 +36,7 @@ func TestBackup(t *testing.T) { re.NoError(err) err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) pdAddr := cluster.GetConfig().GetClientURL() urls := strings.Split(pdAddr, ",") defer cluster.Destroy() diff --git a/tools/pd-ctl/tests/cluster/cluster_test.go b/tools/pd-ctl/tests/cluster/cluster_test.go index 1cb6c5a3010..46681da9319 100644 --- a/tools/pd-ctl/tests/cluster/cluster_test.go +++ b/tools/pd-ctl/tests/cluster/cluster_test.go @@ -38,7 +38,7 @@ func TestClusterAndPing(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) err = cluster.GetLeaderServer().BootstrapCluster() re.NoError(err) pdAddr := cluster.GetConfig().GetClientURL() diff --git a/tools/pd-ctl/tests/config/config_test.go b/tools/pd-ctl/tests/config/config_test.go index da9826515de..cd77104f01f 100644 --- a/tools/pd-ctl/tests/config/config_test.go +++ b/tools/pd-ctl/tests/config/config_test.go @@ -882,7 +882,7 @@ func TestReplicationMode(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) pdAddr := cluster.GetConfig().GetClientURL() cmd := ctl.GetRootCmd() diff --git a/tools/pd-ctl/tests/hot/hot_test.go b/tools/pd-ctl/tests/hot/hot_test.go index 858f2a8d61f..643c1a67c9d 100644 --- a/tools/pd-ctl/tests/hot/hot_test.go +++ b/tools/pd-ctl/tests/hot/hot_test.go @@ -413,7 +413,7 @@ func TestHistoryHotRegions(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) pdAddr := cluster.GetConfig().GetClientURL() cmd := ctl.GetRootCmd() @@ -530,7 +530,7 @@ func TestBuckets(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) pdAddr := cluster.GetConfig().GetClientURL() cmd := ctl.GetRootCmd() diff --git a/tools/pd-ctl/tests/label/label_test.go b/tools/pd-ctl/tests/label/label_test.go index f7370a71872..057c9d9d9bb 100644 --- a/tools/pd-ctl/tests/label/label_test.go +++ b/tools/pd-ctl/tests/label/label_test.go @@ -39,7 +39,7 @@ func TestLabel(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) pdAddr := cluster.GetConfig().GetClientURL() cmd := ctl.GetRootCmd() diff --git a/tools/pd-ctl/tests/log/log_test.go b/tools/pd-ctl/tests/log/log_test.go index a89596715bd..274bc4ce7df 100644 --- a/tools/pd-ctl/tests/log/log_test.go +++ b/tools/pd-ctl/tests/log/log_test.go @@ -45,7 +45,7 @@ func (suite *logTestSuite) SetupSuite() { suite.cluster, err = pdTests.NewTestCluster(suite.ctx, 3) re.NoError(err) re.NoError(suite.cluster.RunInitialServers()) - suite.cluster.WaitLeader() + re.NotEmpty(suite.cluster.WaitLeader()) suite.pdAddrs = suite.cluster.GetConfig().GetClientURLs() store := &metapb.Store{ diff --git a/tools/pd-ctl/tests/member/member_test.go b/tools/pd-ctl/tests/member/member_test.go index 7a2d5fc72c9..dd3e465ae38 100644 --- a/tools/pd-ctl/tests/member/member_test.go +++ b/tools/pd-ctl/tests/member/member_test.go @@ -38,7 +38,7 @@ func TestMember(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) leaderServer := cluster.GetLeaderServer() re.NoError(leaderServer.BootstrapCluster()) pdAddr := cluster.GetConfig().GetClientURL() @@ -67,7 +67,7 @@ func TestMember(t *testing.T) { }) // member leader resign - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) args = []string{"-u", pdAddr, "member", "leader", "resign"} output, err = tests.ExecuteCommand(cmd, args...) re.Contains(string(output), "Success") @@ -77,7 +77,7 @@ func TestMember(t *testing.T) { }) // member leader_priority - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) args = []string{"-u", pdAddr, "member", "leader_priority", name, "100"} _, err = tests.ExecuteCommand(cmd, args...) re.NoError(err) diff --git a/tools/pd-ctl/tests/region/region_test.go b/tools/pd-ctl/tests/region/region_test.go index 2952e137f3b..afffba411bc 100644 --- a/tools/pd-ctl/tests/region/region_test.go +++ b/tools/pd-ctl/tests/region/region_test.go @@ -40,7 +40,7 @@ func TestRegionKeyFormat(t *testing.T) { re.NoError(err) err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) url := cluster.GetConfig().GetClientURL() store := &metapb.Store{ Id: 1, @@ -66,7 +66,7 @@ func TestRegion(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) pdAddr := cluster.GetConfig().GetClientURL() cmd := ctl.GetRootCmd() @@ -270,7 +270,7 @@ func TestRegionNoLeader(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) url := cluster.GetConfig().GetClientURL() stores := []*metapb.Store{ { diff --git a/tools/pd-ctl/tests/resourcemanager/resource_manager_command_test.go b/tools/pd-ctl/tests/resourcemanager/resource_manager_command_test.go index d387a2b87ae..3da72244215 100644 --- a/tools/pd-ctl/tests/resourcemanager/resource_manager_command_test.go +++ b/tools/pd-ctl/tests/resourcemanager/resource_manager_command_test.go @@ -47,7 +47,7 @@ func (s *testResourceManagerSuite) SetupSuite() { re.NoError(err) s.cluster = cluster s.cluster.RunInitialServers() - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) s.pdAddr = cluster.GetConfig().GetClientURL() } diff --git a/tools/pd-ctl/tests/store/store_test.go b/tools/pd-ctl/tests/store/store_test.go index b5cff2e8e5c..0f522b8bd44 100644 --- a/tools/pd-ctl/tests/store/store_test.go +++ b/tools/pd-ctl/tests/store/store_test.go @@ -46,7 +46,7 @@ func TestStoreLimitV2(t *testing.T) { re.NoError(err) err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) pdAddr := cluster.GetConfig().GetClientURL() cmd := ctl.GetRootCmd() @@ -79,7 +79,7 @@ func TestStore(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) pdAddr := cluster.GetConfig().GetClientURL() cmd := ctl.GetRootCmd() @@ -270,7 +270,7 @@ func TestStore(t *testing.T) { re.NoError(leaderServer.Stop()) re.NoError(leaderServer.Run()) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) storesLimit := leaderServer.GetPersistOptions().GetAllStoresLimit() re.Equal(float64(20), storesLimit[1].AddPeer) re.Equal(float64(20), storesLimit[1].RemovePeer) @@ -528,7 +528,7 @@ func TestTombstoneStore(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) pdAddr := cluster.GetConfig().GetClientURL() cmd := ctl.GetRootCmd() @@ -629,7 +629,7 @@ func TestStoreTLS(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) cmd := ctl.GetRootCmd() stores := []*response.StoreInfo{ diff --git a/tools/pd-ctl/tests/unsafe/unsafe_operation_test.go b/tools/pd-ctl/tests/unsafe/unsafe_operation_test.go index 26fb4fc46e4..da89749c2f2 100644 --- a/tools/pd-ctl/tests/unsafe/unsafe_operation_test.go +++ b/tools/pd-ctl/tests/unsafe/unsafe_operation_test.go @@ -33,7 +33,7 @@ func TestRemoveFailedStores(t *testing.T) { defer cluster.Destroy() err = cluster.RunInitialServers() re.NoError(err) - cluster.WaitLeader() + re.NotEmpty(cluster.WaitLeader()) err = cluster.GetLeaderServer().BootstrapCluster() re.NoError(err) pdAddr := cluster.GetConfig().GetClientURL()