Skip to content

Commit 38b67cf

Browse files
authored
[core] test_job_isolation passes even when exceptions are thrown (#51694)
`call_ray_start` uses an unusual method to obtain the GCS address. It executes a `ray start` command and then parses the command's STDOUT. However, this method will return "None" as address. See the following screenshot for more details. https://github.com/ray-project/ray/blob/a5bab234e651d19b91d5860be0606d4c6c01d118/python/ray/tests/conftest.py#L771-L789 --------- Signed-off-by: Kai-Hsun Chen <kaihsun@anyscale.com>
1 parent 9095f4c commit 38b67cf

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

python/ray/tests/test_job.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ def test_invalid_gcs_address():
5656
JobSubmissionClient("abc:abc")
5757

5858

59-
@pytest.mark.skipif(
60-
sys.version_info >= (3, 12), reason="lib is not supported on Python 3.12"
61-
)
62-
def test_job_isolation(call_ray_start):
59+
def test_job_isolation(ray_start_regular):
6360
# Make sure two jobs with same module name
6461
# don't interfere with each other
6562
# (https://github.com/ray-project/ray/issues/19358).
66-
address = call_ray_start
63+
gcs_address = ray_start_regular.address_info["gcs_address"]
64+
6765
lib_template = """
6866
import ray
6967
@@ -88,19 +86,34 @@ def subtask():
8886
with open(v1_lib, "w") as f:
8987
f.write(lib_template.format(1))
9088
with open(v1_driver, "w") as f:
91-
f.write(driver_template.format(address, 1))
89+
f.write(driver_template.format(gcs_address, 1))
9290

9391
os.makedirs(os.path.join(tmpdir, "v2"))
9492
v2_lib = os.path.join(tmpdir, "v2", "lib.py")
9593
v2_driver = os.path.join(tmpdir, "v2", "driver.py")
9694
with open(v2_lib, "w") as f:
9795
f.write(lib_template.format(2))
9896
with open(v2_driver, "w") as f:
99-
f.write(driver_template.format(address, 2))
97+
f.write(driver_template.format(gcs_address, 2))
10098

10199
subprocess.check_call([sys.executable, v1_driver])
102100
subprocess.check_call([sys.executable, v2_driver])
103101

102+
dashboard_url = ray_start_regular.dashboard_url
103+
client = JobSubmissionClient(f"http://{dashboard_url}")
104+
jobs = client.list_jobs()
105+
assert len(jobs) == 3 # ray_start_regular, v1, v2
106+
107+
num_succeeded = 0
108+
num_running = 0
109+
for job in jobs:
110+
if job.status == "SUCCEEDED":
111+
num_succeeded += 1
112+
elif job.status == "RUNNING":
113+
num_running += 1
114+
assert num_succeeded == 2
115+
assert num_running == 1
116+
104117

105118
def test_job_observability(ray_start_regular):
106119
driver_template = """

0 commit comments

Comments
 (0)