@@ -498,40 +498,6 @@ def test_namespace_explicit_override(mocker):
498498 assert rayjob .namespace == "explicit-ns"
499499
500500
501- def test_shutdown_behavior_with_cluster_config (mocker ):
502- """Test that shutdown_after_job_finishes is True when cluster_config is provided."""
503- mocker .patch ("kubernetes.config.load_kube_config" )
504- mocker .patch ("codeflare_sdk.ray.rayjobs.rayjob.RayjobApi" )
505- mocker .patch ("codeflare_sdk.ray.rayjobs.rayjob.RayClusterApi" )
506-
507- cluster_config = ManagedClusterConfig ()
508-
509- rayjob = RayJob (
510- job_name = "test-job" ,
511- entrypoint = "python script.py" ,
512- cluster_config = cluster_config ,
513- namespace = "test-namespace" ,
514- )
515-
516- assert rayjob .shutdown_after_job_finishes is True
517-
518-
519- def test_shutdown_behavior_with_existing_cluster (mocker ):
520- """Test that shutdown_after_job_finishes is False when using existing cluster."""
521- mocker .patch ("kubernetes.config.load_kube_config" )
522- mocker .patch ("codeflare_sdk.ray.rayjobs.rayjob.RayjobApi" )
523- mocker .patch ("codeflare_sdk.ray.rayjobs.rayjob.RayClusterApi" )
524-
525- rayjob = RayJob (
526- job_name = "test-job" ,
527- entrypoint = "python script.py" ,
528- cluster_name = "existing-cluster" ,
529- namespace = "test-namespace" ,
530- )
531-
532- assert rayjob .shutdown_after_job_finishes is False
533-
534-
535501def test_rayjob_with_rayjob_cluster_config (mocker ):
536502 """Test RayJob with the new ManagedClusterConfig."""
537503 mocker .patch ("kubernetes.config.load_kube_config" )
@@ -935,48 +901,6 @@ def test_build_ray_cluster_spec_with_image_pull_secrets(mocker):
935901 assert worker_secrets [1 ].name == "another-secret"
936902
937903
938- def test_rayjob_user_override_shutdown_behavior (mocker ):
939- """Test that user can override the auto-detected shutdown behavior."""
940- mocker .patch ("kubernetes.config.load_kube_config" )
941- mocker .patch ("codeflare_sdk.ray.rayjobs.rayjob.RayjobApi" )
942- mocker .patch ("codeflare_sdk.ray.rayjobs.rayjob.RayClusterApi" )
943-
944- # Test 1: User overrides shutdown to True even when using existing cluster
945- rayjob_existing_override = RayJob (
946- job_name = "test-job" ,
947- entrypoint = "python script.py" ,
948- cluster_name = "existing-cluster" ,
949- shutdown_after_job_finishes = True , # User override
950- namespace = "test-namespace" , # Explicitly specify namespace
951- )
952-
953- assert rayjob_existing_override .shutdown_after_job_finishes is True
954-
955- # Test 2: User overrides shutdown to False even when creating new cluster
956- cluster_config = ManagedClusterConfig ()
957-
958- rayjob_new_override = RayJob (
959- job_name = "test-job" ,
960- entrypoint = "python script.py" ,
961- cluster_config = cluster_config ,
962- shutdown_after_job_finishes = False , # User override
963- namespace = "test-namespace" , # Explicitly specify namespace
964- )
965-
966- assert rayjob_new_override .shutdown_after_job_finishes is False
967-
968- # Test 3: User override takes precedence over auto-detection
969- rayjob_override_priority = RayJob (
970- job_name = "test-job" ,
971- entrypoint = "python script.py" ,
972- cluster_config = cluster_config ,
973- shutdown_after_job_finishes = True , # Should override auto-detection
974- namespace = "test-namespace" , # Explicitly specify namespace
975- )
976-
977- assert rayjob_override_priority .shutdown_after_job_finishes is True
978-
979-
980904class TestRayVersionValidation :
981905 """Test Ray version validation in RayJob."""
982906
@@ -2353,7 +2277,7 @@ def test_rayjob_init_missing_cluster_name_with_no_config(mocker):
23532277 rayjob .runtime_env = None
23542278 rayjob .ttl_seconds_after_finished = 0
23552279 rayjob .active_deadline_seconds = None
2356- rayjob .shutdown_after_job_finishes = False
2280+ rayjob .shutdown_after_job_finishes = True
23572281 rayjob .namespace = "test-namespace"
23582282 rayjob ._cluster_name = None
23592283 rayjob ._cluster_config = None
0 commit comments