Skip to content

Commit a9c6129

Browse files
author
nolancon
committed
Device Manager - Update unit tests
- Pass container to Allocate(). - Loop through containers to call Allocate() on container by container basis.
1 parent cb9fdc4 commit a9c6129

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pkg/kubelet/cm/devicemanager/manager_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ func TestPodContainerDeviceAllocation(t *testing.T) {
728728
pod := testCase.testPod
729729
activePods = append(activePods, pod)
730730
podsStub.updateActivePods(activePods)
731-
err := testManager.Allocate(pod)
731+
err := testManager.Allocate(pod, &pod.Spec.Containers[0])
732732
if !reflect.DeepEqual(err, testCase.expErr) {
733733
t.Errorf("DevicePluginManager error (%v). expected error: %v but got: %v",
734734
testCase.description, testCase.expErr, err)
@@ -823,7 +823,12 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
823823
},
824824
}
825825
podsStub.updateActivePods([]*v1.Pod{podWithPluginResourcesInInitContainers})
826-
err = testManager.Allocate(podWithPluginResourcesInInitContainers)
826+
for _, container := range podWithPluginResourcesInInitContainers.Spec.InitContainers {
827+
err = testManager.Allocate(podWithPluginResourcesInInitContainers, &container)
828+
}
829+
for _, container := range podWithPluginResourcesInInitContainers.Spec.Containers {
830+
err = testManager.Allocate(podWithPluginResourcesInInitContainers, &container)
831+
}
827832
as.Nil(err)
828833
podUID := string(podWithPluginResourcesInInitContainers.UID)
829834
initCont1 := podWithPluginResourcesInInitContainers.Spec.InitContainers[0].Name
@@ -929,7 +934,7 @@ func TestDevicePreStartContainer(t *testing.T) {
929934
activePods := []*v1.Pod{}
930935
activePods = append(activePods, pod)
931936
podsStub.updateActivePods(activePods)
932-
err = testManager.Allocate(pod)
937+
err = testManager.Allocate(pod, &pod.Spec.Containers[0])
933938
as.Nil(err)
934939
runContainerOpts, err := testManager.GetDeviceRunContainerOptions(pod, &pod.Spec.Containers[0])
935940
as.Nil(err)

0 commit comments

Comments
 (0)