Skip to content

Commit

Permalink
*: fix race due to wrong usage (#8655)
Browse files Browse the repository at this point in the history
close #8654

Signed-off-by: Ryan Leung <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
rleungx and ti-chi-bot[bot] authored Sep 24, 2024
1 parent 6b927e1 commit 14b3b9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ func TestStoreHeartbeat(t *testing.T) {
},
PeerStats: []*pdpb.PeerStat{},
}
cluster.opt.GetScheduleConfig().StoreLimitVersion = "v1"
scheCfg := cluster.opt.GetScheduleConfig().Clone()
scheCfg.StoreLimitVersion = "v1"
cluster.opt.SetScheduleConfig(scheCfg)
re.NoError(cluster.HandleStoreHeartbeat(hotReq, hotResp))
re.NoError(cluster.HandleStoreHeartbeat(hotReq, hotResp))
re.NoError(cluster.HandleStoreHeartbeat(hotReq, hotResp))
Expand Down
8 changes: 6 additions & 2 deletions tests/integrations/mcs/scheduling/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,15 @@ func (suite *apiTestSuite) checkConfigForward(cluster *tests.TestCluster) {

// Test to change config only in scheduling server
// Expect to get new config in scheduling server but not old config in api server
opts.GetScheduleConfig().LeaderScheduleLimit = 100
scheCfg := opts.GetScheduleConfig().Clone()
scheCfg.LeaderScheduleLimit = 100
opts.SetScheduleConfig(scheCfg)
re.Equal(100, int(opts.GetLeaderScheduleLimit()))
testutil.ReadGetJSON(re, tests.TestDialClient, urlPrefix, &cfg)
re.Equal(100., cfg["schedule"].(map[string]any)["leader-schedule-limit"])
opts.GetReplicationConfig().MaxReplicas = 5
repCfg := opts.GetReplicationConfig().Clone()
repCfg.MaxReplicas = 5
opts.SetReplicationConfig(repCfg)
re.Equal(5, int(opts.GetReplicationConfig().MaxReplicas))
testutil.ReadGetJSON(re, tests.TestDialClient, urlPrefix, &cfg)
re.Equal(5., cfg["replication"].(map[string]any)["max-replicas"])
Expand Down
8 changes: 6 additions & 2 deletions tools/pd-ctl/tests/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,12 @@ func (suite *configTestSuite) checkConfigForwardControl(cluster *pdTests.TestClu
// Test Config
// inject different config to scheduling server
if sche := cluster.GetSchedulingPrimaryServer(); sche != nil {
sche.GetPersistConfig().GetScheduleConfig().LeaderScheduleLimit = 233
sche.GetPersistConfig().GetReplicationConfig().MaxReplicas = 7
scheCfg := sche.GetPersistConfig().GetScheduleConfig().Clone()
scheCfg.LeaderScheduleLimit = 233
sche.GetPersistConfig().SetScheduleConfig(scheCfg)
repCfg := sche.GetPersistConfig().GetReplicationConfig().Clone()
repCfg.MaxReplicas = 7
sche.GetPersistConfig().SetReplicationConfig(repCfg)
re.Equal(uint64(233), sche.GetPersistConfig().GetLeaderScheduleLimit())
re.Equal(7, sche.GetPersistConfig().GetMaxReplicas())
}
Expand Down

0 comments on commit 14b3b9d

Please sign in to comment.