mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Device Manager - Update unit tests
- Pass container to Allocate(). - Loop through containers to call Allocate() on container by container basis.
This commit is contained in:
parent
cb9fdc49db
commit
a9c6129577
@ -728,7 +728,7 @@ func TestPodContainerDeviceAllocation(t *testing.T) {
|
|||||||
pod := testCase.testPod
|
pod := testCase.testPod
|
||||||
activePods = append(activePods, pod)
|
activePods = append(activePods, pod)
|
||||||
podsStub.updateActivePods(activePods)
|
podsStub.updateActivePods(activePods)
|
||||||
err := testManager.Allocate(pod)
|
err := testManager.Allocate(pod, &pod.Spec.Containers[0])
|
||||||
if !reflect.DeepEqual(err, testCase.expErr) {
|
if !reflect.DeepEqual(err, testCase.expErr) {
|
||||||
t.Errorf("DevicePluginManager error (%v). expected error: %v but got: %v",
|
t.Errorf("DevicePluginManager error (%v). expected error: %v but got: %v",
|
||||||
testCase.description, testCase.expErr, err)
|
testCase.description, testCase.expErr, err)
|
||||||
@ -823,7 +823,12 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
podsStub.updateActivePods([]*v1.Pod{podWithPluginResourcesInInitContainers})
|
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)
|
as.Nil(err)
|
||||||
podUID := string(podWithPluginResourcesInInitContainers.UID)
|
podUID := string(podWithPluginResourcesInInitContainers.UID)
|
||||||
initCont1 := podWithPluginResourcesInInitContainers.Spec.InitContainers[0].Name
|
initCont1 := podWithPluginResourcesInInitContainers.Spec.InitContainers[0].Name
|
||||||
@ -929,7 +934,7 @@ func TestDevicePreStartContainer(t *testing.T) {
|
|||||||
activePods := []*v1.Pod{}
|
activePods := []*v1.Pod{}
|
||||||
activePods = append(activePods, pod)
|
activePods = append(activePods, pod)
|
||||||
podsStub.updateActivePods(activePods)
|
podsStub.updateActivePods(activePods)
|
||||||
err = testManager.Allocate(pod)
|
err = testManager.Allocate(pod, &pod.Spec.Containers[0])
|
||||||
as.Nil(err)
|
as.Nil(err)
|
||||||
runContainerOpts, err := testManager.GetDeviceRunContainerOptions(pod, &pod.Spec.Containers[0])
|
runContainerOpts, err := testManager.GetDeviceRunContainerOptions(pod, &pod.Spec.Containers[0])
|
||||||
as.Nil(err)
|
as.Nil(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user