def test_tempdir_commandline(): shutil.rmtree(ray.utils.get_ray_temp_dir(), ignore_errors=True) check_call_ray([ "start", "--head", "--temp-dir=" + os.path.join( ray.utils.get_user_temp_dir(), "i_am_a_temp_dir2") ]) assert os.path.exists( os.path.join(ray.utils.get_user_temp_dir(), "i_am_a_temp_dir2")), "Specified temp dir not found." assert not os.path.exists( ray.utils.get_ray_temp_dir()), "Default temp dir should not exist." check_call_ray(["stop"]) shutil.rmtree( os.path.join(ray.utils.get_user_temp_dir(), "i_am_a_temp_dir2"), ignore_errors=True)
def test_ray_stack(ray_start_2_cpus): def unique_name_1(): time.sleep(1000) @ray.remote def unique_name_2(): time.sleep(1000) @ray.remote def unique_name_3(): unique_name_1() unique_name_2.remote() unique_name_3.remote() success = False start_time = time.time() while time.time() - start_time < 30: # Attempt to parse the "ray stack" call. output = ray._private.utils.decode( check_call_ray(["stack"], capture_stdout=True)) if ("unique_name_1" in output and "unique_name_2" in output and "unique_name_3" in output): success = True break if not success: raise Exception("Failed to find necessary information with " "'ray stack'")
def ray_start_cli_tracing(scope="function"): """Start ray with tracing-startup-hook, and clean up at end of test.""" check_call_ray(["stop", "--force"], ) check_call_ray( ["start", "--head", "--tracing-startup-hook", setup_tracing_path], ) ray.init(address="auto") yield ray.shutdown() check_call_ray(["stop", "--force"])
def test_calling_start_ray_head(call_ray_stop_only): # Test that we can call ray start with various command line # parameters. TODO(rkn): This test only tests the --head code path. We # should also test the non-head node code path. # Test starting Ray with no arguments. check_call_ray(["start", "--head"]) check_call_ray(["stop"]) # Test starting Ray with a redis port specified. check_call_ray(["start", "--head"]) check_call_ray(["stop"]) # Test starting Ray with a node IP address specified. check_call_ray(["start", "--head", "--node-ip-address", "127.0.0.1"]) check_call_ray(["stop"]) # Test starting Ray with the object manager and node manager ports # specified. check_call_ray([ "start", "--head", "--object-manager-port", "12345", "--node-manager-port", "54321" ]) check_call_ray(["stop"]) # Test starting Ray with the worker port range specified. check_call_ray([ "start", "--head", "--min-worker-port", "50000", "--max-worker-port", "51000" ]) check_call_ray(["stop"]) # Test starting Ray with the number of CPUs specified. check_call_ray(["start", "--head", "--num-cpus", "2"]) check_call_ray(["stop"]) # Test starting Ray with the number of GPUs specified. check_call_ray(["start", "--head", "--num-gpus", "100"]) check_call_ray(["stop"]) # Test starting Ray with the max redis clients specified. check_call_ray(["start", "--head", "--redis-max-clients", "100"]) check_call_ray(["stop"]) if "RAY_USE_NEW_GCS" not in os.environ: # Test starting Ray with redis shard ports specified. check_call_ray( ["start", "--head", "--redis-shard-ports", "6380,6381,6382"]) check_call_ray(["stop"]) # Test starting Ray with all arguments specified. check_call_ray([ "start", "--head", "--redis-shard-ports", "6380,6381,6382", "--object-manager-port", "12345", "--num-cpus", "2", "--num-gpus", "0", "--redis-max-clients", "100", "--resources", "{\"Custom\": 1}" ]) check_call_ray(["stop"]) # Test starting Ray with invalid arguments. with pytest.raises(subprocess.CalledProcessError): check_call_ray(["start", "--head", "--address", "127.0.0.1:6379"]) check_call_ray(["stop"]) # Test --block. Killing a child process should cause the command to exit. blocked = subprocess.Popen(["ray", "start", "--head", "--block"]) wait_for_children_of_pid(blocked.pid, num_children=7, timeout=30) blocked.poll() assert blocked.returncode is None kill_process_by_name("raylet") wait_for_children_of_pid_to_exit(blocked.pid, timeout=30) blocked.wait() assert blocked.returncode != 0, "ray start shouldn't return 0 on bad exit" # Test --block. Killing the command should clean up all child processes. blocked = subprocess.Popen(["ray", "start", "--head", "--block"]) blocked.poll() assert blocked.returncode is None wait_for_children_of_pid(blocked.pid, num_children=7, timeout=30) blocked.terminate() wait_for_children_of_pid_to_exit(blocked.pid, timeout=30) blocked.wait() assert blocked.returncode != 0, "ray start shouldn't return 0 on bad exit"
def test_calling_start_ray_head(call_ray_stop_only): # Test that we can call ray start with various command line # parameters. TODO(rkn): This test only tests the --head code path. We # should also test the non-head node code path. # Test starting Ray with a redis port specified. check_call_ray(["start", "--head", "--port", "0"]) check_call_ray(["stop"]) # Test starting Ray with a node IP address specified. check_call_ray( ["start", "--head", "--node-ip-address", "127.0.0.1", "--port", "0"]) check_call_ray(["stop"]) # Test starting Ray with a system config parameter set. check_call_ray([ "start", "--head", "--system-config", "{\"metrics_report_interval_ms\":100}", "--port", "0" ]) check_call_ray(["stop"]) # Test starting Ray with the object manager and node manager ports # specified. check_call_ray([ "start", "--head", "--object-manager-port", "12345", "--node-manager-port", "54321", "--port", "0" ]) check_call_ray(["stop"]) # Test starting Ray with the worker port range specified. check_call_ray([ "start", "--head", "--min-worker-port", "50000", "--max-worker-port", "51000", "--port", "0" ]) check_call_ray(["stop"]) # Test starting Ray with a worker port list. check_call_ray(["start", "--head", "--worker-port-list", "10002,10003"]) check_call_ray(["stop"]) # Test starting Ray with a non-int in the worker port list. with pytest.raises(subprocess.CalledProcessError): check_call_ray(["start", "--head", "--worker-port-list", "10002,a"]) check_call_ray(["stop"]) # Test starting Ray with an invalid port in the worker port list. with pytest.raises(subprocess.CalledProcessError): check_call_ray(["start", "--head", "--worker-port-list", "100"]) check_call_ray(["stop"]) # Test starting Ray with the number of CPUs specified. check_call_ray(["start", "--head", "--num-cpus", "2", "--port", "0"]) check_call_ray(["stop"]) # Test starting Ray with the number of GPUs specified. check_call_ray(["start", "--head", "--num-gpus", "100", "--port", "0"]) check_call_ray(["stop"]) # Test starting Ray with redis shard ports specified. check_call_ray([ "start", "--head", "--redis-shard-ports", "6380,6381,6382", "--port", "0" ]) check_call_ray(["stop"]) # Test starting Ray with all arguments specified. check_call_ray([ "start", "--head", "--redis-shard-ports", "6380,6381,6382", "--object-manager-port", "12345", "--num-cpus", "2", "--num-gpus", "0", "--resources", "{\"Custom\": 1}", "--port", "0" ]) check_call_ray(["stop"]) # Test starting Ray with invalid external address. # It will fall back to creating a new one. check_call_ray( ["start", "--head", "--address", "127.0.0.1:6379", "--port", "0"]) check_call_ray(["stop"]) # Test --block. Killing a child process should cause the command to exit. blocked = subprocess.Popen( ["ray", "start", "--head", "--block", "--port", "0"]) wait_for_children_names_of_pid(blocked.pid, ["raylet"], timeout=30) blocked.poll() assert blocked.returncode is None kill_process_by_name("raylet") wait_for_children_of_pid_to_exit(blocked.pid, timeout=30) blocked.wait() assert blocked.returncode != 0, "ray start shouldn't return 0 on bad exit" # Test --block. Killing the command should clean up all child processes. blocked = subprocess.Popen( ["ray", "start", "--head", "--block", "--port", "0"]) blocked.poll() assert blocked.returncode is None wait_for_children_of_pid(blocked.pid, num_children=7, timeout=30) blocked.terminate() wait_for_children_of_pid_to_exit(blocked.pid, timeout=30) blocked.wait() assert blocked.returncode != 0, "ray start shouldn't return 0 on bad exit"
def test_project_no_validation(): with _chdir_and_back(TEST_DIR): with pytest.raises(subprocess.CalledProcessError): check_call_ray(["project", "validate"])
def test_project_validation(): with _chdir_and_back(os.path.join(TEST_DIR, "project1")): check_call_ray(["project", "validate"])
def test_calling_start_ray_head(call_ray_stop_only): # Test that we can call ray start with various command line # parameters. TODO(rkn): This test only tests the --head code path. We # should also test the non-head node code path. # Test starting Ray with a redis port specified. check_call_ray(["start", "--head", "--port", "0"]) check_call_ray(["stop"]) # Test starting Ray with a node IP address specified. check_call_ray( ["start", "--head", "--node-ip-address", "127.0.0.1", "--port", "0"]) check_call_ray(["stop"]) # Test starting Ray with a system config parameter set. check_call_ray([ "start", "--head", "--system-config", "{\"metrics_report_interval_ms\":100}", "--port", "0" ]) check_call_ray(["stop"]) # Test starting Ray with the object manager and node manager ports # specified. check_call_ray([ "start", "--head", "--object-manager-port", "12345", "--node-manager-port", "54321", "--port", "0" ]) check_call_ray(["stop"]) # Test starting Ray with the worker port range specified. check_call_ray([ "start", "--head", "--min-worker-port", "50000", "--max-worker-port", "51000", "--port", "0" ]) check_call_ray(["stop"]) # Test starting Ray with the number of CPUs specified. check_call_ray(["start", "--head", "--num-cpus", "2", "--port", "0"]) check_call_ray(["stop"]) # Test starting Ray with the number of GPUs specified. check_call_ray(["start", "--head", "--num-gpus", "100", "--port", "0"]) check_call_ray(["stop"])
"51000", "--port", "0" ]) check_call_ray(["stop"]) # Test starting Ray with the number of CPUs specified. check_call_ray(["start", "--head", "--num-cpus", "2", "--port", "0"]) check_call_ray(["stop"]) # Test starting Ray with the number of GPUs specified. check_call_ray(["start", "--head", "--num-gpus", "100", "--port", "0"]) check_call_ray(["stop"]) # Test starting Ray with redis shard ports specified. <<<<<<< HEAD check_call_ray([ "start", "--head", "--redis-shard-ports", "6380,6381,6382", "--port", "0" ]) ======= check_call_ray( ["start", "--head", "--redis-shard-ports", "6380,6381,6382"]) >>>>>>> upstream/releases/1.0.0 check_call_ray(["stop"]) # Test starting Ray with all arguments specified. check_call_ray([ "start", "--head", "--redis-shard-ports", "6380,6381,6382", "--object-manager-port", "12345", "--num-cpus", "2", "--num-gpus", "0", <<<<<<< HEAD "--resources", "{\"Custom\": 1}", "--port", "0" ======= "--resources", "{\"Custom\": 1}"