From b1d0aa97982f9e566f35b692efc2dd70bd347a0d Mon Sep 17 00:00:00 2001 From: Kai Fricke Date: Fri, 26 Feb 2021 23:40:09 +0100 Subject: [PATCH] Add unit test for ray cluster-dump (#14389) --- python/ray/tests/test_cli.py | 24 +++++++++++++++++++ .../test_ray_cluster_dump.txt | 16 +++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 python/ray/tests/test_cli_patterns/test_ray_cluster_dump.txt diff --git a/python/ray/tests/test_cli.py b/python/ray/tests/test_cli.py index f5628701f..b1f68c3c2 100644 --- a/python/ray/tests/test_cli.py +++ b/python/ray/tests/test_cli.py @@ -443,5 +443,29 @@ def test_ray_status(): _check_output_via_pattern("test_ray_status.txt", result_env_arg) +@pytest.mark.skipif( + sys.platform == "darwin" and "travis" in os.environ.get("USER", ""), + reason=("Mac builds don't provide proper locale support")) +@mock_ec2 +@mock_iam +def test_ray_cluster_dump(configure_lang, configure_aws, _unlink_test_ssh_key): + def commands_mock(command, stdin): + print("This is a test!") + return PopenBehaviour(stdout=b"This is a test!") + + with _setup_popen_mock(commands_mock): + runner = CliRunner() + result = runner.invoke(scripts.up, [ + DEFAULT_TEST_CONFIG_PATH, "--no-config-cache", "-y", + "--log-style=pretty", "--log-color", "False" + ]) + _die_on_error(result) + + result = runner.invoke(scripts.cluster_dump, + [DEFAULT_TEST_CONFIG_PATH, "--no-processes"]) + + _check_output_via_pattern("test_ray_cluster_dump.txt", result) + + if __name__ == "__main__": sys.exit(pytest.main(["-v", __file__])) diff --git a/python/ray/tests/test_cli_patterns/test_ray_cluster_dump.txt b/python/ray/tests/test_cli_patterns/test_ray_cluster_dump.txt new file mode 100644 index 000000000..59624eb51 --- /dev/null +++ b/python/ray/tests/test_cli_patterns/test_ray_cluster_dump.txt @@ -0,0 +1,16 @@ +You are about to create a cluster dump\. This will collect data from cluster nodes\. + +The dump will contain this information: + + - The logfiles of your Ray session + This usually includes Python outputs \(stdout/stderr\) + - Debug state information on your Ray cluster + e\.g\. number of workers, drivers, objects, etc\. + - Your installed Python packages \(`pip freeze`\) + +If you are concerned about leaking private information, extract the archive and inspect its contents before sharing it with anyone\. +Retrieving cluster information from ray cluster file: .+ +Checking AWS environment settings +Collecting data from remote node: .+ +This is a test! +Created archive: .+