Skip to content

Commit 9aa9344

Browse files
committed
Add UT
1 parent 489b9f0 commit 9aa9344

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,32 @@ 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: "SneakyGPUContainer",
197+
Resources: v1.ResourceRequirements{},
198+
},
199+
{
200+
Resources: v1.ResourceRequirements{
201+
Limits: v1.ResourceList{
202+
constants.GpuResource: *resource.NewMilliQuantity(1, resource.DecimalSI),
203+
},
204+
},
205+
},
206+
},
207+
},
208+
},
209+
error: fmt.Errorf("cannot request both GPU and GPU memory"),
210+
},
185211
{
186212
name: "forbid negative GPU memory annotation",
187213
pod: &v1.Pod{

0 commit comments

Comments
 (0)