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

Fix everest logging test #9454

Merged
merged 1 commit into from
Dec 5, 2024
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
31 changes: 15 additions & 16 deletions tests/everest/test_logging.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pathlib import Path

import pytest

Expand All @@ -13,14 +14,12 @@
CONFIG_FILE = "config_fm_failure.yml"


def string_exists_in_file(file_path, string):
with open(file_path, "r", encoding="utf-8") as f:
txt = f.read()
return string in txt
def _string_exists_in_file(file_path, string):
return string in Path(file_path).read_text(encoding="utf-8")


@pytest.mark.flaky(reruns=5)
@pytest.mark.timeout(60) # Simulation might not finish
@pytest.mark.timeout(70) # Simulation might not finish
@pytest.mark.integration_test
@pytest.mark.xdist_group(name="starts_everest")
async def test_logging_setup(copy_math_func_test_data_to_tmp):
Expand All @@ -35,8 +34,8 @@ async def server_running():
makedirs_if_needed(everest_config.output_dir, roll_if_exists=True)
driver = await start_server(everest_config, debug=True)
try:
wait_for_server(everest_config.output_dir, 120)
except SystemExit as e:
wait_for_server(everest_config.output_dir, 60)
except (SystemExit, RuntimeError) as e:
raise e
await server_running()

Expand All @@ -56,16 +55,16 @@ async def server_running():
assert os.path.exists(everest_log_path)
assert os.path.exists(endpoint_log_path)

assert string_exists_in_file(everest_log_path, "everest DEBUG:")
assert string_exists_in_file(
forward_model_log_path,
"Exception: Failing simulation_2 by request!",
assert _string_exists_in_file(everest_log_path, "everest DEBUG:")
assert _string_exists_in_file(
forward_model_log_path, "Exception: Failing simulation_2 by request!"
)
assert string_exists_in_file(
assert _string_exists_in_file(
forward_model_log_path, "Exception: Failing simulation_2" " by request!"
)

assert string_exists_in_file(
endpoint_log_path,
"everserver INFO: / entered from",
)
endpoint_logs = Path(endpoint_log_path).read_text(encoding="utf-8")
# Avoid cases where optimization finished before we get a chance to check that
# the everest server has started
if endpoint_logs:
assert "everserver INFO: / entered from" in endpoint_logs
Loading