Skip to content

Commit 5f2d4ec

Browse files
authored
tests: fix TestValidateID (#9808)
ref #9806 Signed-off-by: Ryan Leung <rleungx@gmail.com>
1 parent 1d4b63b commit 5f2d4ec

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pkg/keyspace/util_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/tikv/pd/pkg/codec"
2727
"github.com/tikv/pd/pkg/keyspace/constant"
2828
"github.com/tikv/pd/pkg/schedule/labeler"
29+
"github.com/tikv/pd/pkg/versioninfo/kerneltype"
2930
)
3031

3132
func TestValidateID(t *testing.T) {
@@ -35,11 +36,26 @@ func TestValidateID(t *testing.T) {
3536
hasErr bool
3637
}{
3738
{100, false},
38-
{constant.MaxValidKeyspaceID - 1, false},
3939
{constant.MaxValidKeyspaceID, false},
4040
{constant.MaxValidKeyspaceID + 1, true},
4141
{math.MaxUint32, true},
4242
}
43+
44+
// Add kernel-specific test case for MaxValidKeyspaceID - 1
45+
if kerneltype.IsNextGen() {
46+
// In NextGen mode, MaxValidKeyspaceID - 1 is SystemKeyspaceID, which is protected
47+
testCases = append(testCases, struct {
48+
id uint32
49+
hasErr bool
50+
}{constant.MaxValidKeyspaceID - 1, true})
51+
} else {
52+
// In Classic mode, MaxValidKeyspaceID - 1 is not protected
53+
testCases = append(testCases, struct {
54+
id uint32
55+
hasErr bool
56+
}{constant.MaxValidKeyspaceID - 1, false})
57+
}
58+
4359
for _, testCase := range testCases {
4460
re.Equal(testCase.hasErr, validateID(testCase.id) != nil)
4561
}

0 commit comments

Comments
 (0)