From c8257ed6c5ec47f000a2428721baf94621cc6c81 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Tue, 28 Nov 2023 11:37:16 +0800 Subject: [PATCH] *: make `TestUpdateDefaultReplicaConfig` stable (#7455) close tikv/pd#7410 Signed-off-by: Ryan Leung Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- tests/pdctl/config/config_test.go | 48 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/pdctl/config/config_test.go b/tests/pdctl/config/config_test.go index badccd9becc..3f82be44399 100644 --- a/tests/pdctl/config/config_test.go +++ b/tests/pdctl/config/config_test.go @@ -683,66 +683,66 @@ func (suite *configTestSuite) checkUpdateDefaultReplicaConfig(cluster *tests.Tes checkMaxReplicas := func(expect uint64) { args := []string{"-u", pdAddr, "config", "show", "replication"} - output, err := pdctl.ExecuteCommand(cmd, args...) - re.NoError(err) - replicationCfg := sc.ReplicationConfig{} - re.NoError(json.Unmarshal(output, &replicationCfg)) testutil.Eventually(re, func() bool { // wait for the config to be synced to the scheduling server + output, err := pdctl.ExecuteCommand(cmd, args...) + re.NoError(err) + replicationCfg := sc.ReplicationConfig{} + re.NoError(json.Unmarshal(output, &replicationCfg)) return replicationCfg.MaxReplicas == expect }) } checkLocationLabels := func(expect int) { args := []string{"-u", pdAddr, "config", "show", "replication"} - output, err := pdctl.ExecuteCommand(cmd, args...) - re.NoError(err) - replicationCfg := sc.ReplicationConfig{} - re.NoError(json.Unmarshal(output, &replicationCfg)) testutil.Eventually(re, func() bool { // wait for the config to be synced to the scheduling server + output, err := pdctl.ExecuteCommand(cmd, args...) + re.NoError(err) + replicationCfg := sc.ReplicationConfig{} + re.NoError(json.Unmarshal(output, &replicationCfg)) return len(replicationCfg.LocationLabels) == expect }) } checkIsolationLevel := func(expect string) { args := []string{"-u", pdAddr, "config", "show", "replication"} - output, err := pdctl.ExecuteCommand(cmd, args...) - re.NoError(err) - replicationCfg := sc.ReplicationConfig{} - re.NoError(json.Unmarshal(output, &replicationCfg)) testutil.Eventually(re, func() bool { // wait for the config to be synced to the scheduling server + output, err := pdctl.ExecuteCommand(cmd, args...) + re.NoError(err) + replicationCfg := sc.ReplicationConfig{} + re.NoError(json.Unmarshal(output, &replicationCfg)) return replicationCfg.IsolationLevel == expect }) } checkRuleCount := func(expect int) { args := []string{"-u", pdAddr, "config", "placement-rules", "show", "--group", placement.DefaultGroupID, "--id", placement.DefaultRuleID} - output, err := pdctl.ExecuteCommand(cmd, args...) - re.NoError(err) - rule := placement.Rule{} - re.NoError(json.Unmarshal(output, &rule)) testutil.Eventually(re, func() bool { // wait for the config to be synced to the scheduling server + output, err := pdctl.ExecuteCommand(cmd, args...) + re.NoError(err) + rule := placement.Rule{} + re.NoError(json.Unmarshal(output, &rule)) return rule.Count == expect }) } checkRuleLocationLabels := func(expect int) { args := []string{"-u", pdAddr, "config", "placement-rules", "show", "--group", placement.DefaultGroupID, "--id", placement.DefaultRuleID} - output, err := pdctl.ExecuteCommand(cmd, args...) - re.NoError(err) - rule := placement.Rule{} - re.NoError(json.Unmarshal(output, &rule)) testutil.Eventually(re, func() bool { // wait for the config to be synced to the scheduling server + output, err := pdctl.ExecuteCommand(cmd, args...) + re.NoError(err) + rule := placement.Rule{} + re.NoError(json.Unmarshal(output, &rule)) return len(rule.LocationLabels) == expect }) } checkRuleIsolationLevel := func(expect string) { args := []string{"-u", pdAddr, "config", "placement-rules", "show", "--group", placement.DefaultGroupID, "--id", placement.DefaultRuleID} - output, err := pdctl.ExecuteCommand(cmd, args...) - re.NoError(err) - rule := placement.Rule{} - re.NoError(json.Unmarshal(output, &rule)) testutil.Eventually(re, func() bool { // wait for the config to be synced to the scheduling server + output, err := pdctl.ExecuteCommand(cmd, args...) + re.NoError(err) + rule := placement.Rule{} + re.NoError(json.Unmarshal(output, &rule)) return rule.IsolationLevel == expect }) }