Skip to content

Commit

Permalink
modify test
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <jinhao.hu@pingcap.com>
  • Loading branch information
HuSharp committed Jan 11, 2023
1 parent 23c074a commit 003db29
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/client/resource_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,35 @@ func (suite *clientTestSuite) TestWatchResourceGroup() {
}
}()

for i := 0; i < 3; i++ {
group := &rmpb.ResourceGroup{
Name: "test" + strconv.Itoa(i),
Mode: rmpb.GroupMode_RUMode,
}
value, err := proto.Marshal(group)
_, err = suite.srv.GetClient().Put(suite.srv.Context(), pd.GroupSettingsPathPrefix+strconv.Itoa(i), string(value))
suite.NoError(err)
}

// TODO: can change to list resource groups after merge
watchChan, err := suite.client.WatchResourceGroup(suite.ctx, 0)
suite.NoError(err)

for i := 0; i < 3; i++ {
for i := 3; i < 6; i++ {
group := &rmpb.ResourceGroup{
Name: "test" + strconv.Itoa(i),
Mode: rmpb.GroupMode_RUMode,
}
value, err := proto.Marshal(group)
_, err = suite.srv.GetClient().Put(suite.srv.Context(), pd.GroupSettingsPathPrefix, string(value))
_, err = suite.srv.GetClient().Put(suite.srv.Context(), pd.GroupSettingsPathPrefix+strconv.Itoa(i), string(value))
suite.NoError(err)
}

i := 0
for {
select {
case <-time.After(time.Second):
close(watchChan)
return
case res := <-watchChan:
for _, r := range res {
Expand Down

0 comments on commit 003db29

Please sign in to comment.