From a9c61295779551c85b86099a437c7ea556f857a2 Mon Sep 17 00:00:00 2001 From: nolancon Date: Thu, 6 Feb 2020 08:53:11 +0000 Subject: [PATCH] Device Manager - Update unit tests - Pass container to Allocate(). - Loop through containers to call Allocate() on container by container basis. --- pkg/kubelet/cm/devicemanager/manager_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/kubelet/cm/devicemanager/manager_test.go b/pkg/kubelet/cm/devicemanager/manager_test.go index 0c167acd594..cefd25937a0 100644 --- a/pkg/kubelet/cm/devicemanager/manager_test.go +++ b/pkg/kubelet/cm/devicemanager/manager_test.go @@ -728,7 +728,7 @@ func TestPodContainerDeviceAllocation(t *testing.T) { pod := testCase.testPod activePods = append(activePods, pod) podsStub.updateActivePods(activePods) - err := testManager.Allocate(pod) + err := testManager.Allocate(pod, &pod.Spec.Containers[0]) if !reflect.DeepEqual(err, testCase.expErr) { t.Errorf("DevicePluginManager error (%v). expected error: %v but got: %v", testCase.description, testCase.expErr, err) @@ -823,7 +823,12 @@ func TestInitContainerDeviceAllocation(t *testing.T) { }, } podsStub.updateActivePods([]*v1.Pod{podWithPluginResourcesInInitContainers}) - err = testManager.Allocate(podWithPluginResourcesInInitContainers) + for _, container := range podWithPluginResourcesInInitContainers.Spec.InitContainers { + err = testManager.Allocate(podWithPluginResourcesInInitContainers, &container) + } + for _, container := range podWithPluginResourcesInInitContainers.Spec.Containers { + err = testManager.Allocate(podWithPluginResourcesInInitContainers, &container) + } as.Nil(err) podUID := string(podWithPluginResourcesInInitContainers.UID) initCont1 := podWithPluginResourcesInInitContainers.Spec.InitContainers[0].Name @@ -929,7 +934,7 @@ func TestDevicePreStartContainer(t *testing.T) { activePods := []*v1.Pod{} activePods = append(activePods, pod) podsStub.updateActivePods(activePods) - err = testManager.Allocate(pod) + err = testManager.Allocate(pod, &pod.Spec.Containers[0]) as.Nil(err) runContainerOpts, err := testManager.GetDeviceRunContainerOptions(pod, &pod.Spec.Containers[0]) as.Nil(err)