Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
Signed-off-by: nolouch <[email protected]>
  • Loading branch information
nolouch committed Dec 6, 2023
1 parent b239ee5 commit 272f23f
Showing 1 changed file with 63 additions and 63 deletions.
126 changes: 63 additions & 63 deletions tests/integrations/mcs/resource_manager/resource_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 272f23f

Please sign in to comment.