@@ -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
3132func 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