MCPcopy
hub / github.com/NVIDIA/k8s-device-plugin / TestMigStrategyMixed

Function TestMigStrategyMixed

cmd/gpu-feature-discovery/mig_test.go:285–354  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

283}
284
285func TestMigStrategyMixed(t *testing.T) {
286 // create VGPU mock library with empty vgpu devices
287 vgpuMock := NewTestVGPUMock()
288 devices := []resource.Device{
289 rt.NewMigEnabledDevice(
290 rt.NewMigDevice(3, 0, 20),
291 rt.NewMigDevice(1, 0, 5),
292 ),
293 }
294
295 nvmlMock := rt.NewManagerMockWithDevices(devices...)
296
297 conf := &spec.Config{
298 Flags: spec.Flags{
299 CommandLineFlags: spec.CommandLineFlags{
300 MigStrategy: ptr("mixed"),
301 FailOnInitError: ptr(true),
302 GFD: &spec.GFDCommandLineFlags{
303 Oneshot: ptr(true),
304 OutputFile: ptr("./gfd-test-mig-mixed"),
305 SleepInterval: ptr(spec.Duration(time.Second)),
306 NoTimestamp: ptr(false),
307 MachineTypeFile: ptr(testMachineTypeFile),
308 },
309 },
310 },
311 }
312
313 setupMachineFile(t)
314 defer removeMachineFile(t)
315
316 labelOutputer, err := lm.NewOutputer(conf, flags.NodeConfig{}, flags.ClientSets{})
317 require.NoError(t, err)
318
319 d := gfd{
320 manager: nvmlMock,
321 vgpu: vgpuMock,
322 config: conf,
323 labelOutputer: labelOutputer,
324 }
325 restart, err := d.run(nil)
326 require.NoError(t, err, "Error from run function")
327 require.False(t, restart)
328
329 outFile, err := os.Open(*conf.Flags.GFD.OutputFile)
330 require.NoError(t, err, "Opening output file")
331
332 defer func() {
333 err = outFile.Close()
334 require.NoError(t, err, "Closing output file")
335 err = os.Remove(*conf.Flags.GFD.OutputFile)
336 require.NoError(t, err, "Removing output file")
337 }()
338
339 output, err := io.ReadAll(outFile)
340 require.NoError(t, err, "Reading output file")
341
342 err = checkResult(output, cfg.Path("tests/expected-output-mig-mixed.txt"), false)

Callers

nothing calls this directly

Calls 10

runMethod · 0.95
NewOutputerFunction · 0.92
NewTestVGPUMockFunction · 0.85
setupMachineFileFunction · 0.85
removeMachineFileFunction · 0.85
checkResultFunction · 0.85
buildLabelMapFromOutputFunction · 0.85
ContainsMethod · 0.80
ptrFunction · 0.70
PathMethod · 0.45

Tested by

no test coverage detected