diff --git a/tests/integrations/mcs/resource_manager/resource_manager_test.go b/tests/integrations/mcs/resource_manager/resource_manager_test.go index cd03e8148008..b80eaf6fbb0b 100644 --- a/tests/integrations/mcs/resource_manager/resource_manager_test.go +++ b/tests/integrations/mcs/resource_manager/resource_manager_test.go @@ -700,69 +700,69 @@ func (suite *resourceManagerClientTestSuite) TestResourcePenalty() { re.NoError(err) } -func (suite *resourceManagerClientTestSuite) TestAcquireTokenBucket() { - re := suite.Require() - cli := suite.client - - groups := suite.initGroups - for _, group := range groups { - resp, err := cli.AddResourceGroup(suite.ctx, group) - re.NoError(err) - re.Contains(resp, "Success!") - } - reqs := &rmpb.TokenBucketsRequest{ - Requests: make([]*rmpb.TokenBucketRequest, 0), - TargetRequestPeriodMs: uint64(time.Second * 10 / time.Millisecond), - } - re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/mcs/resource_manager/server/fastPersist", `return(true)`)) - suite.resignAndWaitLeader() - for i := 0; i < 3; i++ { - for _, group := range groups { - requests := make([]*rmpb.RequestUnitItem, 0) - requests = append(requests, &rmpb.RequestUnitItem{ - Type: rmpb.RequestUnitType_RU, - Value: 30000, - }) - req := &rmpb.TokenBucketRequest{ - ResourceGroupName: group.Name, - Request: &rmpb.TokenBucketRequest_RuItems{ - RuItems: &rmpb.TokenBucketRequest_RequestRU{ - RequestRU: requests, - }, - }, - } - reqs.Requests = append(reqs.Requests, req) - } - aresp, err := cli.AcquireTokenBuckets(suite.ctx, reqs) - re.NoError(err) - for _, resp := range aresp { - re.Len(resp.GrantedRUTokens, 1) - re.Equal(resp.GrantedRUTokens[0].GrantedTokens.Tokens, float64(30000.)) - if resp.ResourceGroupName == "test2" { - re.Equal(int64(-1), resp.GrantedRUTokens[0].GrantedTokens.GetSettings().GetBurstLimit()) - } - } - gresp, err := cli.GetResourceGroup(suite.ctx, groups[0].GetName()) - re.NoError(err) - re.Less(gresp.RUSettings.RU.Tokens, groups[0].RUSettings.RU.Tokens) - - checkFunc := func(g1 *rmpb.ResourceGroup, g2 *rmpb.ResourceGroup) { - re.Equal(g1.GetName(), g2.GetName()) - re.Equal(g1.GetMode(), g2.GetMode()) - re.Equal(g1.GetRUSettings().RU.Settings.FillRate, g2.GetRUSettings().RU.Settings.FillRate) - // now we don't persistent tokens in running state, so tokens is original. - re.Less(g1.GetRUSettings().RU.Tokens, g2.GetRUSettings().RU.Tokens) - re.NoError(err) - } - time.Sleep(250 * time.Millisecond) - // to test persistent - suite.resignAndWaitLeader() - gresp, err = cli.GetResourceGroup(suite.ctx, groups[0].GetName()) - re.NoError(err) - checkFunc(gresp, groups[0]) - } - re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/mcs/resource_manager/server/fastPersist")) -} +// func (suite *resourceManagerClientTestSuite) TestAcquireTokenBucket() { +// re := suite.Require() +// cli := suite.client + +// groups := suite.initGroups +// for _, group := range groups { +// resp, err := cli.AddResourceGroup(suite.ctx, group) +// re.NoError(err) +// re.Contains(resp, "Success!") +// } +// reqs := &rmpb.TokenBucketsRequest{ +// Requests: make([]*rmpb.TokenBucketRequest, 0), +// TargetRequestPeriodMs: uint64(time.Second * 10 / time.Millisecond), +// } +// re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/mcs/resource_manager/server/fastPersist", `return(true)`)) +// suite.resignAndWaitLeader() +// for i := 0; i < 3; i++ { +// for _, group := range groups { +// requests := make([]*rmpb.RequestUnitItem, 0) +// requests = append(requests, &rmpb.RequestUnitItem{ +// Type: rmpb.RequestUnitType_RU, +// Value: 30000, +// }) +// req := &rmpb.TokenBucketRequest{ +// ResourceGroupName: group.Name, +// Request: &rmpb.TokenBucketRequest_RuItems{ +// RuItems: &rmpb.TokenBucketRequest_RequestRU{ +// RequestRU: requests, +// }, +// }, +// } +// reqs.Requests = append(reqs.Requests, req) +// } +// aresp, err := cli.AcquireTokenBuckets(suite.ctx, reqs) +// re.NoError(err) +// for _, resp := range aresp { +// re.Len(resp.GrantedRUTokens, 1) +// re.Equal(resp.GrantedRUTokens[0].GrantedTokens.Tokens, float64(30000.)) +// if resp.ResourceGroupName == "test2" { +// re.Equal(int64(-1), resp.GrantedRUTokens[0].GrantedTokens.GetSettings().GetBurstLimit()) +// } +// } +// gresp, err := cli.GetResourceGroup(suite.ctx, groups[0].GetName()) +// re.NoError(err) +// re.Less(gresp.RUSettings.RU.Tokens, groups[0].RUSettings.RU.Tokens) + +// checkFunc := func(g1 *rmpb.ResourceGroup, g2 *rmpb.ResourceGroup) { +// re.Equal(g1.GetName(), g2.GetName()) +// re.Equal(g1.GetMode(), g2.GetMode()) +// re.Equal(g1.GetRUSettings().RU.Settings.FillRate, g2.GetRUSettings().RU.Settings.FillRate) +// // now we don't persistent tokens in running state, so tokens is original. +// re.Less(g1.GetRUSettings().RU.Tokens, g2.GetRUSettings().RU.Tokens) +// re.NoError(err) +// } +// time.Sleep(250 * time.Millisecond) +// // to test persistent +// suite.resignAndWaitLeader() +// gresp, err = cli.GetResourceGroup(suite.ctx, groups[0].GetName()) +// re.NoError(err) +// checkFunc(gresp, groups[0]) +// } +// re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/mcs/resource_manager/server/fastPersist")) +// } func (suite *resourceManagerClientTestSuite) TestBasicResourceGroupCURD() { re := suite.Require()