Skip to content

Commit 019e114

Browse files
committed
Add UT
1 parent 489b9f0 commit 019e114

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pkg/binder/plugins/gpusharing/gpu-request/gpu_request_validator_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,33 @@ func TestValidateGpuRequests(t *testing.T) {
182182
},
183183
error: fmt.Errorf("cannot request both GPU and GPU memory"),
184184
},
185+
{
186+
name: "forbid GPU resource limit in sidecar container with GPU Memory fraction annotation",
187+
pod: &v1.Pod{
188+
ObjectMeta: metav1.ObjectMeta{
189+
Annotations: map[string]string{
190+
constants.GpuMemory: "1",
191+
},
192+
},
193+
Spec: v1.PodSpec{
194+
Containers: []v1.Container{
195+
{
196+
Name: "DistractionContainer",
197+
Resources: v1.ResourceRequirements{},
198+
},
199+
{
200+
Name: "SneakyGPUContainer",
201+
Resources: v1.ResourceRequirements{
202+
Limits: v1.ResourceList{
203+
constants.GpuResource: *resource.NewMilliQuantity(1, resource.DecimalSI),
204+
},
205+
},
206+
},
207+
},
208+
},
209+
},
210+
error: fmt.Errorf("cannot request both GPU and GPU memory"),
211+
},
185212
{
186213
name: "forbid negative GPU memory annotation",
187214
pod: &v1.Pod{

0 commit comments

Comments
 (0)