@@ -245,7 +245,6 @@ def test_build_rayjob_cr_with_existing_cluster(auto_mock_setup):
245245 cluster_name = "existing-cluster" ,
246246 namespace = "test-namespace" ,
247247 entrypoint = "python main.py" ,
248- ttl_seconds_after_finished = 300 ,
249248 )
250249
251250 rayjob_cr = rayjob ._build_rayjob_cr ()
@@ -256,7 +255,6 @@ def test_build_rayjob_cr_with_existing_cluster(auto_mock_setup):
256255 spec = rayjob_cr ["spec" ]
257256 assert spec ["entrypoint" ] == "python main.py"
258257 assert spec ["shutdownAfterJobFinishes" ] is False
259- assert spec ["ttlSecondsAfterFinished" ] == 300
260258
261259 assert spec ["clusterSelector" ]["ray.io/cluster" ] == "existing-cluster"
262260 assert "rayClusterSpec" not in spec
@@ -526,12 +524,14 @@ def test_rayjob_with_runtime_env_dict(auto_mock_setup):
526524def test_rayjob_with_active_deadline_and_ttl (auto_mock_setup ):
527525 """
528526 Test RayJob with both active deadline and TTL settings.
527+ Note: TTL can only be set when creating a new cluster (via cluster_config).
529528 """
530529
530+ cluster_config = ManagedClusterConfig ()
531531 rayjob = RayJob (
532532 job_name = "test-job" ,
533533 entrypoint = "python -c 'print()'" ,
534- cluster_name = "test-cluster" ,
534+ cluster_config = cluster_config ,
535535 active_deadline_seconds = 300 ,
536536 ttl_seconds_after_finished = 600 ,
537537 namespace = "test-namespace" ,
@@ -594,11 +594,13 @@ def test_rayjob_error_handling_invalid_cluster_config(auto_mock_setup):
594594def test_rayjob_constructor_parameter_validation (auto_mock_setup ):
595595 """
596596 Test constructor parameter validation.
597+ Note: TTL can only be set when creating a new cluster (via cluster_config).
597598 """
599+ cluster_config = ManagedClusterConfig ()
598600 rayjob = RayJob (
599601 job_name = "test-job" ,
600602 entrypoint = "python -c 'print()'" ,
601- cluster_name = "test-cluster" ,
603+ cluster_config = cluster_config ,
602604 namespace = "test-ns" ,
603605 runtime_env = RuntimeEnv (pip = ["numpy" ]),
604606 ttl_seconds_after_finished = 300 ,
@@ -607,7 +609,7 @@ def test_rayjob_constructor_parameter_validation(auto_mock_setup):
607609
608610 assert rayjob .name == "test-job"
609611 assert rayjob .entrypoint == "python -c 'print()'"
610- assert rayjob .cluster_name == "test-cluster"
612+ assert rayjob .cluster_name == "test-job- cluster" # Generated from job name
611613 assert rayjob .namespace == "test-ns"
612614 # Check that runtime_env is a RuntimeEnv object and contains pip dependencies
613615 assert isinstance (rayjob .runtime_env , RuntimeEnv )
0 commit comments