Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Fix Test-Dashboard #14874

Merged
merged 1 commit into from
Mar 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions python/ray/tests/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
from ray import ray_constants


@pytest.mark.skip("Flaky test")
def test_ray_start_default_port_conflict(call_ray_stop_only, shutdown_only):
subprocess.check_call(["ray", "start", "--head"])
ray.init(address="auto")
assert str(ray_constants.DEFAULT_DASHBOARD_PORT) in ray.get_dashboard_url()

error_raised = False
try:
subprocess.check_output(
[
Expand All @@ -26,10 +26,14 @@ def test_ray_start_default_port_conflict(call_ray_stop_only, shutdown_only):
"--head",
"--port",
"9999", # use a different gcs port
"--include-dashboard=True"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simon-mo Is it okay that I added these? Without this the error is not raised.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

],
stderr=subprocess.PIPE)
except subprocess.CalledProcessError as e:
assert b"already in use" in e.stderr
assert b"already occupied" in e.stderr
error_raised = True

assert error_raised, "ray start should cause a conflict error"


def test_port_auto_increment(shutdown_only):
Expand Down Expand Up @@ -63,8 +67,7 @@ def dashboard_available():
""")


@pytest.mark.skip("Test fails on master")
def test_port_conflict(shutdown_only):
def test_port_conflict(call_ray_stop_only, shutdown_only):
sock = socket.socket()
if hasattr(socket, "SO_REUSEPORT"):
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 0)
Expand All @@ -73,18 +76,15 @@ def test_port_conflict(shutdown_only):
try:
subprocess.check_output(
[
"ray",
"start",
"--head",
"--dashboard-port",
"9999",
"ray", "start", "--head", "--port", "9989", "--dashboard-port",
"9999", "--include-dashboard=True"
],
stderr=subprocess.PIPE)
except subprocess.CalledProcessError as e:
assert b"already in use" in e.stderr
assert b"already occupied" in e.stderr

with pytest.raises(ValueError, match="already in use"):
ray.init(dashboard_port=9999)
with pytest.raises(ValueError, match="already occupied"):
ray.init(dashboard_port=9999, include_dashboard=True)

sock.close()

Expand Down