mirror of
https://github.com/wassname/ray.git
synced 2026-07-14 11:17:54 +08:00
[Projects] Start multiple sessions via session start (#5740)
This commit is contained in:
@@ -165,6 +165,10 @@ def test_session_execute_default_project():
|
||||
|
||||
assert expected_commands == commands_executed
|
||||
|
||||
result, mock_calls, test_dir = run_test_project(
|
||||
"session-tests/project-pass", session_execute, ["--shell", "uptime"])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_session_start_docker_fail():
|
||||
result, _, _ = run_test_project("session-tests/with-docker-fail",
|
||||
@@ -200,3 +204,36 @@ def test_session_create_command():
|
||||
if "Starting ray job with 1 and 2" in kwargs["cmd"]:
|
||||
found_command = True
|
||||
assert found_command
|
||||
|
||||
|
||||
def test_session_create_multiple():
|
||||
for args in [{"a": "*", "b": "2"}, {"a": "1", "b": "*"}]:
|
||||
result, mock_calls, test_dir = run_test_project(
|
||||
"session-tests/commands-test", session_start,
|
||||
["first", "--a", args["a"], "--b", args["b"]])
|
||||
|
||||
loaded_project = ray.projects.ProjectDefinition(test_dir)
|
||||
assert result.exit_code == 0
|
||||
|
||||
exec_cluster_call = mock_calls["exec_cluster"]
|
||||
commands_executed = []
|
||||
for _, kwargs in exec_cluster_call.call_args_list:
|
||||
commands_executed.append(kwargs["cmd"].replace(
|
||||
"cd {}; ".format(loaded_project.working_directory()), ""))
|
||||
assert commands_executed.count("echo \"Setting up\"") == 2
|
||||
if args["a"] == "*":
|
||||
assert commands_executed.count(
|
||||
"echo \"Starting ray job with 1 and 2\"") == 1
|
||||
assert commands_executed.count(
|
||||
"echo \"Starting ray job with 2 and 2\"") == 1
|
||||
if args["b"] == "*":
|
||||
assert commands_executed.count(
|
||||
"echo \"Starting ray job with 1 and 1\"") == 1
|
||||
assert commands_executed.count(
|
||||
"echo \"Starting ray job with 1 and 2\"") == 1
|
||||
|
||||
# Using multiple wildcards shouldn't work
|
||||
result, mock_calls, test_dir = run_test_project(
|
||||
"session-tests/commands-test", session_start,
|
||||
["first", "--a", "*", "--b", "*"])
|
||||
assert result.exit_code == 1
|
||||
|
||||
Reference in New Issue
Block a user