@@ -24,6 +24,25 @@ def test_invalid_gpu(args: argparse.Namespace):
2424 assert "ERROR: unsupported GPU invalid" in err .value .code
2525
2626
27+ @pytest .mark .parametrize (
28+ "gpu, resources" ,
29+ [
30+ (
31+ "v100" ,
32+ {
33+ "requests" : {"nvidia.com/gpu" : "1" },
34+ "limits" : {"nvidia.com/gpu" : "1" },
35+ },
36+ ),
37+ (
38+ "none" ,
39+ {
40+ "requests" : {"cpu" : "1" , "memory" : "1Gi" },
41+ "limits" : {"cpu" : "1" , "memory" : "1Gi" },
42+ },
43+ ),
44+ ],
45+ )
2746@mock .patch ("openshift_client.create" , name = "create" )
2847@mock .patch ("openshift_client.selector" , name = "selector" )
2948@mock .patch ("socket.gethostname" , name = "gethostname" )
@@ -33,6 +52,8 @@ def test_create_job_nowait(
3352 mock_gethostname ,
3453 mock_selector ,
3554 mock_create ,
55+ gpu ,
56+ resources ,
3657 args : argparse .Namespace ,
3758 tempdir ,
3859 parser ,
@@ -41,11 +62,13 @@ def test_create_job_nowait(
4162 CreateJobCommand .build_parser (subparsers )
4263 args = parser .parse_args (["br" ])
4364 args .wait = False
44- args .job_id = 123
65+ args .job_id = "test"
4566 args .image = "test-image"
46- args .gpu = "v100"
67+ args .gpu = gpu
4768 args .command = ["true" ]
4869
70+ queue_name = "dummy-localqueue" if gpu == "none" else f"{ gpu } -localqueue"
71+
4972 mock_getcwd .return_value = tempdir
5073 mock_gethostname .return_value = "testhost"
5174
@@ -66,9 +89,9 @@ def test_create_job_nowait(
6689 "apiVersion" : "batch/v1" ,
6790 "kind" : "Job" ,
6891 "metadata" : {
69- "name" : "job-v100-123 " ,
92+ "name" : f "job-{ gpu } -test " ,
7093 "labels" : {
71- "kueue.x-k8s.io/queue-name" : "v100-localqueue" ,
94+ "kueue.x-k8s.io/queue-name" : queue_name ,
7295 "test_name" : "kueue_test" ,
7396 },
7497 },
@@ -82,17 +105,14 @@ def test_create_job_nowait(
82105 "restartPolicy" : "Never" ,
83106 "containers" : [
84107 {
85- "name" : "job-v100-123-container" ,
86108 "command" : [
87109 "/bin/bash" ,
88110 "-c" ,
89111 f"testcommand { ' ' .join (args .command ).strip ()} " ,
90112 ],
113+ "name" : f"job-{ gpu } -test-container" ,
91114 "image" : "test-image" ,
92- "resources" : {
93- "requests" : {"nvidia.com/gpu" : "1" },
94- "limits" : {"nvidia.com/gpu" : "1" },
95- },
115+ "resources" : resources ,
96116 }
97117 ],
98118 }
0 commit comments