Skip to content

Commit

Permalink
This is an automated cherry-pick of #8486
Browse files Browse the repository at this point in the history
close #8480

Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
rleungx authored and ti-chi-bot committed Aug 27, 2024
1 parent fcb34c9 commit 10c6ca3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
37 changes: 35 additions & 2 deletions server/api/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import (
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/stretchr/testify/suite"
<<<<<<< HEAD

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (12)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (11)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (6)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (6)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (6)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (2)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (2)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (2)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (7)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (1)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (7)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (1)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (7)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (1)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (10)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (10)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (10)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / statics

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / statics

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / tso-function-test

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (4)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (4)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (4)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (13)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (9)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (9)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (9)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (8)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (8)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (8)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (5)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (5)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (5)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (3)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (3)

missing import path

Check failure on line 25 in server/api/label_test.go

View workflow job for this annotation

GitHub Actions / chunks (3)

missing import path
=======
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/pkg/response"
>>>>>>> c8ad186c3 (server: skip the engine key when match store label (#8486))
tu "github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/server"
"github.com/tikv/pd/server/config"
Expand Down Expand Up @@ -274,19 +279,47 @@ func (suite *strictlyLabelsStoreTestSuite) TestStoreMatch() {
valid: false,
expectError: "key matching the label was not found",
},
{
store: &metapb.Store{
Id: 3,
Address: "tiflash1",
State: metapb.StoreState_Up,
Labels: []*metapb.StoreLabel{
{
Key: "zone",
Value: "us-west-1",
},
{
Key: "disk",
Value: "ssd",
},
{
Key: core.EngineKey,
Value: core.EngineTiFlash,
},
},
Version: "3.0.0",
},
valid: true,
expectError: "placement rules is disabled",
},
}

for _, testCase := range testCases {
resp, err := suite.grpcSvr.PutStore(context.Background(), &pdpb.PutStoreRequest{
Header: &pdpb.RequestHeader{ClusterId: suite.svr.ClusterID()},
Store: &metapb.Store{
Id: testCase.store.Id,
Address: fmt.Sprintf("tikv%d", testCase.store.Id),
Address: testCase.store.Address,
State: testCase.store.State,
Labels: testCase.store.Labels,
Version: testCase.store.Version,
},
})
if testCase.store.Address == "tiflash1" {
re.Contains(resp.GetHeader().GetError().String(), testCase.expectError)
continue
}
if testCase.valid {
suite.NoError(err)
suite.Nil(resp.GetHeader().GetError())
Expand All @@ -306,7 +339,7 @@ func (suite *strictlyLabelsStoreTestSuite) TestStoreMatch() {
Header: &pdpb.RequestHeader{ClusterId: suite.svr.ClusterID()},
Store: &metapb.Store{
Id: testCase.store.Id,
Address: fmt.Sprintf("tikv%d", testCase.store.Id),
Address: testCase.store.Address,
State: testCase.store.State,
Labels: testCase.store.Labels,
Version: testCase.store.Version,
Expand Down
3 changes: 3 additions & 0 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,9 @@ func (c *RaftCluster) checkStoreLabels(s *core.StoreInfo) error {
}
for _, label := range s.GetLabels() {
key := label.GetKey()
if key == core.EngineKey {
continue
}
if _, ok := keysSet[key]; !ok {
log.Warn("not found the key match with the store label",
zap.Stringer("store", s.GetMeta()),
Expand Down

0 comments on commit 10c6ca3

Please sign in to comment.