@@ -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,9 +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"
66+ args .image = "test-image"
67+ args .gpu = gpu
4568 args .command = ["true" ]
4669
70+ queue_name = "dummy-localqueue" if gpu == "none" else f"{ gpu } -localqueue"
71+
4772 mock_getcwd .return_value = tempdir
4873 mock_gethostname .return_value = "testhost"
4974
@@ -64,9 +89,9 @@ def test_create_job_nowait(
6489 "apiVersion" : "batch/v1" ,
6590 "kind" : "Job" ,
6691 "metadata" : {
67- "name" : "job-v100-123 " ,
92+ "name" : f "job-{ gpu } -test " ,
6893 "labels" : {
69- "kueue.x-k8s.io/queue-name" : "v100-localqueue" ,
94+ "kueue.x-k8s.io/queue-name" : queue_name ,
7095 "test_name" : "kueue_test" ,
7196 },
7297 },
@@ -80,17 +105,14 @@ def test_create_job_nowait(
80105 "restartPolicy" : "Never" ,
81106 "containers" : [
82107 {
83- "name" : "job-v100-123-container" ,
84108 "command" : [
85109 "/bin/bash" ,
86110 "-c" ,
87111 f"testcommand { ' ' .join (args .command ).strip ()} " ,
88112 ],
89- "image" : "image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/csw-run-f25:latest" ,
90- "resources" : {
91- "requests" : {"nvidia.com/gpu" : "1" },
92- "limits" : {"nvidia.com/gpu" : "1" },
93- },
113+ "name" : f"job-{ gpu } -test-container" ,
114+ "image" : "test-image" ,
115+ "resources" : resources ,
94116 }
95117 ],
96118 }
0 commit comments