From 9368b2ce87d92bdc58290eb65a44e09fc9b84c90 Mon Sep 17 00:00:00 2001 From: Richard Chen Date: Fri, 26 Apr 2019 16:19:17 -0700 Subject: [PATCH] Only create one pod per gpu node in E2E test --- test/e2e/scheduling/nvidia-gpus.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/e2e/scheduling/nvidia-gpus.go b/test/e2e/scheduling/nvidia-gpus.go index f1fe190d722..0c7391d3564 100644 --- a/test/e2e/scheduling/nvidia-gpus.go +++ b/test/e2e/scheduling/nvidia-gpus.go @@ -168,11 +168,23 @@ func SetupNVIDIAGPUNode(f *framework.Framework, setupResourceGatherer bool) *fra return rsgather } +func getGPUsPerPod() int64 { + var gpusPerPod int64 + gpuPod := makeCudaAdditionDevicePluginTestPod() + for _, container := range gpuPod.Spec.Containers { + if val, ok := container.Resources.Limits[gpuResourceName]; ok { + gpusPerPod += (&val).Value() + } + } + return gpusPerPod +} + func testNvidiaGPUs(f *framework.Framework) { rsgather := SetupNVIDIAGPUNode(f, true) - e2elog.Logf("Creating as many pods as there are Nvidia GPUs and have the pods run a CUDA app") + gpuPodNum := getGPUsAvailable(f) / getGPUsPerPod() + e2elog.Logf("Creating %d pods and have the pods run a CUDA app", gpuPodNum) podList := []*v1.Pod{} - for i := int64(0); i < getGPUsAvailable(f); i++ { + for i := int64(0); i < gpuPodNum; i++ { podList = append(podList, f.PodClient().Create(makeCudaAdditionDevicePluginTestPod())) } e2elog.Logf("Wait for all test pods to succeed")