Dashboard minor refactor and first unit tests (#8705)

This commit is contained in:
Max Fitton
2020-06-03 11:04:55 -05:00
committed by GitHub
parent b37a162076
commit b9f0f7ae5b
9 changed files with 369 additions and 297 deletions
+1
View File
@@ -0,0 +1 @@
from ray.tests.conftest import * # noqa
@@ -0,0 +1,32 @@
from ray.dashboard.node_stats import NodeStats
from ray.ray_constants import REDIS_DEFAULT_PASSWORD
from datetime import datetime
from time import sleep
import pytest
def test_basic(ray_start_with_dashboard):
"""Dashboard test that starts a Ray cluster with a dashboard server running,
then hits the dashboard API and asserts that it receives sensible data."""
redis_address = ray_start_with_dashboard["redis_address"]
redis_password = REDIS_DEFAULT_PASSWORD
node_stats = NodeStats(redis_address, redis_password)
node_stats.start()
# Wait for node stats to fire up.
MAX_START_TIME_S = 30
t_start = datetime.now()
while True:
try:
stats = node_stats.get_node_stats()
client_stats = stats and stats.get("clients")
if not client_stats:
sleep(3)
if (datetime.now() - t_start).seconds > MAX_START_TIME_S:
pytest.fail("Node stats took too long to start up")
continue
break
except Exception:
continue
assert len(client_stats) == 1
client = client_stats[0]
assert len(client["workers"]) == 1