@@ -290,6 +290,8 @@ func TestPlugin(t *testing.T) {
290
290
prepare prepare
291
291
want want
292
292
293
+ // enableDRAAdminAccess is set to true if the DRAAdminAccess feature gate is enabled.
294
+ enableDRAAdminAccess bool
293
295
// Feature gates. False is chosen so that the uncommon case
294
296
// doesn't need to be set.
295
297
disableDRA bool
@@ -301,7 +303,7 @@ func TestPlugin(t *testing.T) {
301
303
status : framework .NewStatus (framework .Skip ),
302
304
},
303
305
postfilter : result {
304
- status : framework .NewStatus (framework .Unschedulable , `no new claims to deallocate` ),
306
+ status : framework .NewStatus (framework .Unschedulable ),
305
307
},
306
308
},
307
309
},
@@ -554,9 +556,10 @@ func TestPlugin(t *testing.T) {
554
556
},
555
557
},
556
558
557
- "request-admin-access" : {
558
- // Because the pending claim asks for admin access, allocation succeeds despite resources
559
- // being exhausted.
559
+ "request-admin-access-with-DRAAdminAccess-featuregate" : {
560
+ // When the DRAAdminAccess feature gate is enabled,
561
+ // Because the pending claim asks for admin access,
562
+ // allocation succeeds despite resources being exhausted.
560
563
pod : podWithClaimName ,
561
564
claims : []* resourceapi.ResourceClaim {adminAccess (pendingClaim ), otherAllocatedClaim },
562
565
classes : []* resourceapi.DeviceClass {deviceClass },
@@ -582,6 +585,24 @@ func TestPlugin(t *testing.T) {
582
585
assumedClaim : reserve (adminAccess (allocatedClaim ), podWithClaimName ),
583
586
},
584
587
},
588
+ enableDRAAdminAccess : true ,
589
+ },
590
+ "request-admin-access-without-DRAAdminAccess-featuregate" : {
591
+ // When the DRAAdminAccess feature gate is disabled,
592
+ // even though the pending claim requests admin access,
593
+ // the scheduler returns an unschedulable status.
594
+ pod : podWithClaimName ,
595
+ claims : []* resourceapi.ResourceClaim {adminAccess (pendingClaim ), otherAllocatedClaim },
596
+ classes : []* resourceapi.DeviceClass {deviceClass },
597
+ objs : []apiruntime.Object {workerNodeSlice },
598
+ want : want {
599
+ filter : perNodeResult {
600
+ workerNode .Name : {
601
+ status : framework .NewStatus (framework .UnschedulableAndUnresolvable , `claim default/my-pod-my-resource, request req-1: admin access is requested, but the feature is disabled` ),
602
+ },
603
+ },
604
+ },
605
+ enableDRAAdminAccess : false ,
585
606
},
586
607
587
608
"structured-ignore-allocated-admin-access" : {
@@ -768,6 +789,9 @@ func TestPlugin(t *testing.T) {
768
789
prefilter : result {
769
790
status : framework .NewStatus (framework .Skip ),
770
791
},
792
+ postfilter : result {
793
+ status : framework .NewStatus (framework .Unschedulable , `plugin disabled` ),
794
+ },
771
795
},
772
796
disableDRA : true ,
773
797
},
@@ -783,6 +807,7 @@ func TestPlugin(t *testing.T) {
783
807
nodes = []* v1.Node {workerNode }
784
808
}
785
809
features := feature.Features {
810
+ EnableDRAAdminAccess : tc .enableDRAAdminAccess ,
786
811
EnableDynamicResourceAllocation : ! tc .disableDRA ,
787
812
}
788
813
testCtx := setup (t , nodes , tc .claims , tc .classes , tc .objs , features )
@@ -801,9 +826,6 @@ func TestPlugin(t *testing.T) {
801
826
assert .Equal (t , tc .want .preFilterResult , result )
802
827
testCtx .verify (t , tc .want .prefilter , initialObjects , result , status )
803
828
})
804
- if status .IsSkip () {
805
- return
806
- }
807
829
unschedulable := status .Code () != framework .Success
808
830
809
831
var potentialNodes []* framework.NodeInfo
@@ -912,9 +934,9 @@ type testContext struct {
912
934
913
935
func (tc * testContext ) verify (t * testing.T , expected result , initialObjects []metav1.Object , result interface {}, status * framework.Status ) {
914
936
t .Helper ()
915
- if expectedErr := status .AsError (); expectedErr != nil {
937
+ if actualErr := status .AsError (); actualErr != nil {
916
938
// Compare only the error strings.
917
- assert .ErrorContains (t , status .AsError (), expectedErr .Error ())
939
+ assert .ErrorContains (t , actualErr , expected . status .AsError ().Error ())
918
940
} else {
919
941
assert .Equal (t , expected .status , status )
920
942
}
0 commit comments