24
24
from codeflare_sdk .cluster import cluster
25
25
26
26
parent = Path (__file__ ).resolve ().parents [1 ]
27
+ aw_dir = os .path .expanduser ("~/.codeflare/appwrapper/" )
27
28
sys .path .append (str (parent ) + "/src" )
28
29
29
30
from kubernetes import client , config
@@ -261,10 +262,12 @@ def test_config_creation():
261
262
262
263
def test_cluster_creation (mocker ):
263
264
cluster = createClusterWithConfig (mocker )
264
- assert cluster .app_wrapper_yaml == " unit-test-cluster.yaml"
265
+ assert cluster .app_wrapper_yaml == f" { aw_dir } unit-test-cluster.yaml"
265
266
assert cluster .app_wrapper_name == "unit-test-cluster"
266
267
assert filecmp .cmp (
267
- "unit-test-cluster.yaml" , f"{ parent } /tests/test-case.yaml" , shallow = True
268
+ f"{ aw_dir } unit-test-cluster.yaml" ,
269
+ f"{ parent } /tests/test-case.yaml" ,
270
+ shallow = True ,
268
271
)
269
272
270
273
@@ -290,10 +293,10 @@ def test_cluster_creation_no_mcad(mocker):
290
293
config .name = "unit-test-cluster-ray"
291
294
config .mcad = False
292
295
cluster = Cluster (config )
293
- assert cluster .app_wrapper_yaml == " unit-test-cluster-ray.yaml"
296
+ assert cluster .app_wrapper_yaml == f" { aw_dir } unit-test-cluster-ray.yaml"
294
297
assert cluster .app_wrapper_name == "unit-test-cluster-ray"
295
298
assert filecmp .cmp (
296
- " unit-test-cluster-ray.yaml" ,
299
+ f" { aw_dir } unit-test-cluster-ray.yaml" ,
297
300
f"{ parent } /tests/test-case-no-mcad.yamls" ,
298
301
shallow = True ,
299
302
)
@@ -313,10 +316,12 @@ def test_cluster_creation_priority(mocker):
313
316
return_value = {"spec" : {"domain" : "apps.cluster.awsroute.org" }},
314
317
)
315
318
cluster = Cluster (config )
316
- assert cluster .app_wrapper_yaml == " prio-test-cluster.yaml"
319
+ assert cluster .app_wrapper_yaml == f" { aw_dir } prio-test-cluster.yaml"
317
320
assert cluster .app_wrapper_name == "prio-test-cluster"
318
321
assert filecmp .cmp (
319
- "prio-test-cluster.yaml" , f"{ parent } /tests/test-case-prio.yaml" , shallow = True
322
+ f"{ aw_dir } prio-test-cluster.yaml" ,
323
+ f"{ parent } /tests/test-case-prio.yaml" ,
324
+ shallow = True ,
320
325
)
321
326
322
327
@@ -335,7 +340,7 @@ def test_default_cluster_creation(mocker):
335
340
)
336
341
cluster = Cluster (default_config )
337
342
338
- assert cluster .app_wrapper_yaml == " unit-test-default-cluster.yaml"
343
+ assert cluster .app_wrapper_yaml == f" { aw_dir } unit-test-default-cluster.yaml"
339
344
assert cluster .app_wrapper_name == "unit-test-default-cluster"
340
345
assert cluster .config .namespace == "opendatahub"
341
346
@@ -365,21 +370,21 @@ def arg_check_apply_effect(group, version, namespace, plural, body, *args):
365
370
if plural == "appwrappers" :
366
371
assert group == "workload.codeflare.dev"
367
372
assert version == "v1beta1"
368
- with open (" unit-test-cluster.yaml" ) as f :
373
+ with open (f" { aw_dir } unit-test-cluster.yaml" ) as f :
369
374
aw = yaml .load (f , Loader = yaml .FullLoader )
370
375
assert body == aw
371
376
elif plural == "rayclusters" :
372
377
assert group == "ray.io"
373
378
assert version == "v1alpha1"
374
- with open (" unit-test-cluster-ray.yaml" ) as f :
379
+ with open (f" { aw_dir } unit-test-cluster-ray.yaml" ) as f :
375
380
yamls = yaml .load_all (f , Loader = yaml .FullLoader )
376
381
for resource in yamls :
377
382
if resource ["kind" ] == "RayCluster" :
378
383
assert body == resource
379
384
elif plural == "routes" :
380
385
assert group == "route.openshift.io"
381
386
assert version == "v1"
382
- with open (" unit-test-cluster-ray.yaml" ) as f :
387
+ with open (f" { aw_dir } unit-test-cluster-ray.yaml" ) as f :
383
388
yamls = yaml .load_all (f , Loader = yaml .FullLoader )
384
389
for resource in yamls :
385
390
if resource ["kind" ] == "Route" :
@@ -2408,7 +2413,7 @@ def parse_j(cmd):
2408
2413
2409
2414
2410
2415
def test_AWManager_creation ():
2411
- testaw = AWManager (" test.yaml" )
2416
+ testaw = AWManager (f" { aw_dir } test.yaml" )
2412
2417
assert testaw .name == "test"
2413
2418
assert testaw .namespace == "ns"
2414
2419
assert testaw .submitted == False
@@ -2432,7 +2437,7 @@ def arg_check_aw_apply_effect(group, version, namespace, plural, body, *args):
2432
2437
assert version == "v1beta1"
2433
2438
assert namespace == "ns"
2434
2439
assert plural == "appwrappers"
2435
- with open (" test.yaml" ) as f :
2440
+ with open (f" { aw_dir } test.yaml" ) as f :
2436
2441
aw = yaml .load (f , Loader = yaml .FullLoader )
2437
2442
assert body == aw
2438
2443
assert args == tuple ()
@@ -2448,7 +2453,7 @@ def arg_check_aw_del_effect(group, version, namespace, plural, name, *args):
2448
2453
2449
2454
2450
2455
def test_AWManager_submit_remove (mocker , capsys ):
2451
- testaw = AWManager (" test.yaml" )
2456
+ testaw = AWManager (f" { aw_dir } test.yaml" )
2452
2457
testaw .remove ()
2453
2458
captured = capsys .readouterr ()
2454
2459
assert (
@@ -2876,13 +2881,12 @@ def test_gen_app_wrapper_with_oauth(mocker: MockerFixture):
2876
2881
2877
2882
# Make sure to always keep this function last
2878
2883
def test_cleanup ():
2879
- os .remove ("unit-test-cluster.yaml" )
2880
- os .remove ("prio-test-cluster.yaml" )
2881
- os .remove ("unit-test-default-cluster.yaml" )
2882
- os .remove ("unit-test-cluster-ray.yaml" )
2883
- os .remove ("test.yaml" )
2884
- os .remove ("raytest2.yaml" )
2885
- os .remove ("quicktest.yaml" )
2884
+ os .remove (f"{ aw_dir } unit-test-cluster.yaml" )
2885
+ os .remove (f"{ aw_dir } prio-test-cluster.yaml" )
2886
+ os .remove (f"{ aw_dir } unit-test-default-cluster.yaml" )
2887
+ os .remove (f"{ aw_dir } test.yaml" )
2888
+ os .remove (f"{ aw_dir } raytest2.yaml" )
2889
+ os .remove (f"{ aw_dir } quicktest.yaml" )
2886
2890
os .remove ("tls-cluster-namespace/ca.crt" )
2887
2891
os .remove ("tls-cluster-namespace/tls.crt" )
2888
2892
os .remove ("tls-cluster-namespace/tls.key" )
0 commit comments