Skip to content

Commit 3bb305c

Browse files
authored
Merge pull request #945 from p12tic/split-gpu-test
test: Split test_gpu test
2 parents e668a33 + 09034a0 commit 3bb305c

File tree

1 file changed

+52
-17
lines changed

1 file changed

+52
-17
lines changed

pytests/test_container_to_args.py

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,13 @@ async def test_env_file_obj_optional(self):
326326
],
327327
)
328328

329-
async def test_gpu(self):
329+
async def test_gpu_count_all(self):
330330
c = create_compose_mock()
331331

332332
cnt = get_minimal_container()
333333
cnt["command"] = ["nvidia-smi"]
334334
cnt["deploy"] = {"resources": {"reservations": {"devices": [{}]}}}
335335

336-
# count: all
337336
cnt["deploy"]["resources"]["reservations"]["devices"][0] = {
338337
"driver": "nvidia",
339338
"count": "all",
@@ -356,11 +355,23 @@ async def test_gpu(self):
356355
],
357356
)
358357

359-
# count: 2
360-
cnt["deploy"]["resources"]["reservations"]["devices"][0] = {
361-
"driver": "nvidia",
362-
"count": 2,
363-
"capabilities": ["gpu"],
358+
async def test_gpu_count_specific(self):
359+
c = create_compose_mock()
360+
361+
cnt = get_minimal_container()
362+
cnt["command"] = ["nvidia-smi"]
363+
cnt["deploy"] = {
364+
"resources": {
365+
"reservations": {
366+
"devices": [
367+
{
368+
"driver": "nvidia",
369+
"count": 2,
370+
"capabilities": ["gpu"],
371+
}
372+
]
373+
}
374+
}
364375
}
365376

366377
args = await container_to_args(c, cnt)
@@ -381,11 +392,23 @@ async def test_gpu(self):
381392
],
382393
)
383394

384-
# device_ids: all
385-
cnt["deploy"]["resources"]["reservations"]["devices"][0] = {
386-
"driver": "nvidia",
387-
"device_ids": "all",
388-
"capabilities": ["gpu"],
395+
async def test_gpu_device_ids_all(self):
396+
c = create_compose_mock()
397+
398+
cnt = get_minimal_container()
399+
cnt["command"] = ["nvidia-smi"]
400+
cnt["deploy"] = {
401+
"resources": {
402+
"reservations": {
403+
"devices": [
404+
{
405+
"driver": "nvidia",
406+
"device_ids": "all",
407+
"capabilities": ["gpu"],
408+
}
409+
]
410+
}
411+
}
389412
}
390413

391414
args = await container_to_args(c, cnt)
@@ -404,11 +427,23 @@ async def test_gpu(self):
404427
],
405428
)
406429

407-
# device_ids: 1,3
408-
cnt["deploy"]["resources"]["reservations"]["devices"][0] = {
409-
"driver": "nvidia",
410-
"device_ids": [1, 3],
411-
"capabilities": ["gpu"],
430+
async def test_gpu_device_ids_specific(self):
431+
c = create_compose_mock()
432+
433+
cnt = get_minimal_container()
434+
cnt["command"] = ["nvidia-smi"]
435+
cnt["deploy"] = {
436+
"resources": {
437+
"reservations": {
438+
"devices": [
439+
{
440+
"driver": "nvidia",
441+
"device_ids": [1, 3],
442+
"capabilities": ["gpu"],
443+
}
444+
]
445+
}
446+
}
412447
}
413448

414449
args = await container_to_args(c, cnt)

0 commit comments

Comments
 (0)