diff --git a/client/http/client.go b/client/http/client.go index 1de05687a2e1..4fea7a65086d 100644 --- a/client/http/client.go +++ b/client/http/client.go @@ -41,7 +41,7 @@ type Client interface { GetHotReadRegions(context.Context) (*StoreHotPeersInfos, error) GetHotWriteRegions(context.Context) (*StoreHotPeersInfos, error) GetStores(context.Context) (*StoresInfo, error) - GetMinResolvedTSByStoresIDs(context.Context, []string) (uint64, map[uint64]uint64, error) + GetMinResolvedTSByStoresIDs(context.Context, []uint64) (uint64, map[uint64]uint64, error) Close() } @@ -250,7 +250,7 @@ func (c *client) GetStores(ctx context.Context) (*StoresInfo, error) { } // GetMinResolvedTSByStoresIDs get min-resolved-ts by stores IDs. -func (c *client) GetMinResolvedTSByStoresIDs(ctx context.Context, storeIDs []string) (uint64, map[uint64]uint64, error) { +func (c *client) GetMinResolvedTSByStoresIDs(ctx context.Context, storeIDs []uint64) (uint64, map[uint64]uint64, error) { uri := MinResolvedTSPrefix // scope is an optional parameter, it can be `cluster` or specified store IDs. // - When no scope is given, cluster-level's min_resolved_ts will be returned and storesMinResolvedTS will be nil. @@ -258,7 +258,11 @@ func (c *client) GetMinResolvedTSByStoresIDs(ctx context.Context, storeIDs []str // - When scope given a list of stores, min_resolved_ts will be provided for each store // and the scope-specific min_resolved_ts will be returned. if len(storeIDs) != 0 { - uri = fmt.Sprintf("%s?scope=%s", uri, strings.Join(storeIDs, ",")) + storeIDStrs := make([]string, len(storeIDs)) + for idx, id := range storeIDs { + storeIDStrs[idx] = fmt.Sprintf("%d", id) + } + uri = fmt.Sprintf("%s?scope=%s", uri, strings.Join(storeIDStrs, ",")) } resp := struct { MinResolvedTS uint64 `json:"min_resolved_ts"` diff --git a/tests/integrations/client/http_client_test.go b/tests/integrations/client/http_client_test.go index f121ed7a6568..03d90c6cd32a 100644 --- a/tests/integrations/client/http_client_test.go +++ b/tests/integrations/client/http_client_test.go @@ -16,6 +16,7 @@ package client_test import ( "context" + "math" "testing" "github.com/stretchr/testify/suite" @@ -65,9 +66,22 @@ func (suite *httpClientTestSuite) TearDownSuite() { func (suite *httpClientTestSuite) TestGetMinResolvedTSByStoresIDs() { re := suite.Require() - + // Get the cluster-level min resolved TS. minResolvedTS, storeMinResolvedTSMap, err := suite.client.GetMinResolvedTSByStoresIDs(suite.ctx, nil) re.NoError(err) re.Greater(minResolvedTS, uint64(0)) re.Empty(storeMinResolvedTSMap) + // Get the store-level min resolved TS. + minResolvedTS, storeMinResolvedTSMap, err = suite.client.GetMinResolvedTSByStoresIDs(suite.ctx, []uint64{1}) + re.NoError(err) + re.Greater(minResolvedTS, uint64(0)) + re.Len(storeMinResolvedTSMap, 1) + re.Equal(minResolvedTS, storeMinResolvedTSMap[1]) + // Get the store-level min resolved TS with an invalid store ID. + minResolvedTS, storeMinResolvedTSMap, err = suite.client.GetMinResolvedTSByStoresIDs(suite.ctx, []uint64{1, 2}) + re.NoError(err) + re.Greater(minResolvedTS, uint64(0)) + re.Len(storeMinResolvedTSMap, 2) + re.Equal(minResolvedTS, storeMinResolvedTSMap[1]) + re.Equal(uint64(math.MaxUint64), storeMinResolvedTSMap[2]) }