@@ -240,6 +240,23 @@ def test_cluster_creation():
240
240
return cluster
241
241
242
242
243
+ def test_default_cluster_creation (mocker ):
244
+ mocker .patch (
245
+ "codeflare_sdk.cluster.cluster.get_current_namespace" ,
246
+ return_value = "opendatahub" ,
247
+ )
248
+ default_config = ClusterConfiguration (
249
+ name = "unit-test-default-cluster" ,
250
+ )
251
+ cluster = Cluster (default_config )
252
+
253
+ assert cluster .app_wrapper_yaml == "unit-test-default-cluster.yaml"
254
+ assert cluster .app_wrapper_name == "unit-test-default-cluster"
255
+ assert cluster .config .namespace == "opendatahub"
256
+
257
+ return cluster
258
+
259
+
243
260
def arg_check_apply_effect (* args ):
244
261
assert args [0 ] == "apply"
245
262
assert args [1 ] == ["-f" , "unit-test-cluster.yaml" ]
@@ -1593,22 +1610,6 @@ def test_wait_ready(mocker, capsys):
1593
1610
)
1594
1611
1595
1612
1596
- def test_cmd_line_generation ():
1597
- os .system (
1598
- f"python3 { parent } /src/codeflare_sdk/utils/generate_yaml.py --name=unit-cmd-cluster --min-cpu=1 --max-cpu=1 --min-memory=2 --max-memory=2 --gpu=1 --workers=2 --template=src/codeflare_sdk/templates/new-template.yaml"
1599
- )
1600
- assert filecmp .cmp (
1601
- "unit-cmd-cluster.yaml" , f"{ parent } /tests/test-case-cmd.yaml" , shallow = True
1602
- )
1603
- os .remove ("unit-test-cluster.yaml" )
1604
- os .remove ("unit-cmd-cluster.yaml" )
1605
-
1606
-
1607
- def test_cleanup ():
1608
- os .remove ("test.yaml" )
1609
- os .remove ("raytest2.yaml" )
1610
-
1611
-
1612
1613
def test_jobdefinition_coverage ():
1613
1614
abstract = JobDefinition ()
1614
1615
cluster = Cluster (test_config_creation ())
@@ -1673,7 +1674,6 @@ def test_DDPJobDefinition_dry_run():
1673
1674
assert type (ddp_job ._scheduler ) == type (str ())
1674
1675
1675
1676
assert ddp_job .request .app_id .startswith ("test" )
1676
- assert ddp_job .request .working_dir .startswith ("/tmp/torchx_workspace" )
1677
1677
assert ddp_job .request .cluster_name == "unit-test-cluster"
1678
1678
assert ddp_job .request .requirements == "test"
1679
1679
@@ -1916,3 +1916,22 @@ def parse_j(cmd):
1916
1916
max_worker = args [1 ]
1917
1917
gpu = args [3 ]
1918
1918
return f"{ max_worker } x{ gpu } "
1919
+
1920
+
1921
+ # Make sure to keep this function and the efollowing function at the end of the file
1922
+ def test_cmd_line_generation ():
1923
+ os .system (
1924
+ f"python3 { parent } /src/codeflare_sdk/utils/generate_yaml.py --name=unit-cmd-cluster --min-cpu=1 --max-cpu=1 --min-memory=2 --max-memory=2 --gpu=1 --workers=2 --template=src/codeflare_sdk/templates/new-template.yaml"
1925
+ )
1926
+ assert filecmp .cmp (
1927
+ "unit-cmd-cluster.yaml" , f"{ parent } /tests/test-case-cmd.yaml" , shallow = True
1928
+ )
1929
+ os .remove ("unit-test-cluster.yaml" )
1930
+ os .remove ("unit-test-default-cluster.yaml" )
1931
+ os .remove ("unit-cmd-cluster.yaml" )
1932
+
1933
+
1934
+ # Make sure to always keep this function last
1935
+ def test_cleanup ():
1936
+ os .remove ("test.yaml" )
1937
+ os .remove ("raytest2.yaml" )
0 commit comments