[Test] Fix test_log (#24004)

The test verifies the first line 43~51 bytes are "dashboard"

But due to recent code addition to head.py, the line where logs are written became 2 digits -> 3 digits

Previously,
2022-04-18 23:23:56,946	INFO head.py:[less than 100] -- Dashboard head grpc address: 127.0.0.1:57208
 
Now
2022-04-18 23:23:56,946	INFO head.py:101 -- Dashboard head grpc address: 127.0.0.1:57208
So we should increase the bytes range.
This commit is contained in:
SangBin Cho 2022-04-19 20:59:30 +09:00 committed by GitHub
parent 717e60cb4d
commit 082baa2342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,6 +40,12 @@ def test_log(disable_aiohttp_cache, ray_start_with_dashboard):
test_log_text = "test_log_text"
ray.get(write_log.remote(test_log_text))
test_file = "test.log"
with open(
f"{ray.worker.global_worker.node.get_logs_dir_path()}/{test_file}", "w"
) as f:
f.write(test_log_text)
assert wait_until_server_available(ray_start_with_dashboard["webui_url"]) is True
webui_url = ray_start_with_dashboard["webui_url"]
webui_url = format_web_url(webui_url)
@ -81,10 +87,10 @@ def test_log(disable_aiohttp_cache, ray_start_with_dashboard):
# Test range request.
response = requests.get(
webui_url + "/logs/dashboard.log", headers={"Range": "bytes=43-51"}
webui_url + f"/logs/{test_file}", headers={"Range": "bytes=2-5"}
)
response.raise_for_status()
assert response.text == "Dashboard"
assert response.text == test_log_text[2:6]
# Test logUrl in node info.
response = requests.get(webui_url + f"/nodes/{node_id}")
@ -118,16 +124,22 @@ def test_log_proxy(ray_start_with_dashboard):
timeout_seconds = 5
start_time = time.time()
last_ex = None
test_log_text = "test_log_text"
test_file = "test.log"
with open(
f"{ray.worker.global_worker.node.get_logs_dir_path()}/{test_file}", "w"
) as f:
f.write(test_log_text)
while True:
time.sleep(1)
try:
# Test range request.
response = requests.get(
f"{webui_url}/log_proxy?url={webui_url}/logs/dashboard.log",
headers={"Range": "bytes=43-51"},
f"{webui_url}/log_proxy?url={webui_url}/logs/{test_file}",
headers={"Range": "bytes=2-5"},
)
response.raise_for_status()
assert response.text == "Dashboard"
assert response.text == test_log_text[2:6]
# Test 404.
response = requests.get(
f"{webui_url}/log_proxy?" f"url={webui_url}/logs/not_exist_file.log"