Skip to content

Commit

Permalink
Extend license retry to more error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Jan 15, 2024
1 parent 3db8f4e commit 7ef6fd6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ def runEclipse(self, eclrun_config=None, retries_left=2, backoff_sleep=None):
try:
self.assertECLEND()
except RuntimeError as err:
if "LICENSE FAILURE" in err.args[0] and retries_left > 0:
if (
"LICENSE ERROR" in err.args[0] or "LICENSE FAILURE" in err.args[0]
) and retries_left > 0:
time_to_wait = backoff_sleep + int(
random() * self.LICENSE_RETRY_STAGGER_FACTOR
)
Expand Down
38 changes: 26 additions & 12 deletions tests/unit_tests/shared/share/test_ecl_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,26 @@ def test_slurm_env_parsing():


@pytest.mark.skipif(sys.platform.startswith("darwin"), reason="Flaky bash mock on mac")
def test_ecl100_retries_once_on_license_failure(tmp_path, monkeypatch):
@pytest.mark.parametrize(
"error_text",
[
"""\
Errors 1
Bugs 0
@-- ERROR AT TIME 0.0 DAYS ( 1-JAN-2000):
@ LICENSE ERROR -1 FOR MULTI-SEGMENT WELL OPTION
@ FEATURE IS INVALID. CHECK YOUR LICENSE FILE AND
@ THE LICENSE LOG FILE
""",
"""\
Errors 1
Bugs 0
@-- ERROR AT TIME 0.0 DAYS ( 1-JAN-2000):
@ LICENSE FAILURE: ERROR NUMBER IS -33
""",
],
)
def test_ecl100_retries_once_on_license_failure(error_text, tmp_path, monkeypatch):
mock_eclipse_path = tmp_path / "mock_eclipse100"
with open(tmp_path / "mock_config.yaml", "w", encoding="utf-8") as fp:
yaml.dump(
Expand All @@ -583,18 +602,13 @@ def test_ecl100_retries_once_on_license_failure(tmp_path, monkeypatch):
case_path = tmp_path / "CASE.DATA"
case_path.write_text("", encoding="utf-8")
mock_eclipse_path.write_text(
dedent(
"""\
#!/usr/bin/bash
echo 'Errors 1
Bugs 0
@-- ERROR AT TIME 0.0 DAYS ( 1-JAN-2000):
@ LICENSE FAILURE: ERROR NUMBER IS -33' > CASE.PRT
echo 'Called mock' >> mock_log
"""
),
f"""#!/usr/bin/bash
echo '{error_text}' > CASE.PRT
echo 'Called mock' >> mock_log
""",
encoding="utf-8",
)
print(mock_eclipse_path.read_text())
mock_eclipse_path.chmod(
stat.S_IEXEC | stat.S_IWUSR | mock_eclipse_path.stat().st_mode
)
Expand All @@ -605,7 +619,7 @@ def test_ecl100_retries_once_on_license_failure(tmp_path, monkeypatch):
erun.LICENSE_FAILURE_SLEEP_FACTOR = 1
erun.LICENSE_RETRY_STAGGER_FACTOR = 1

with pytest.raises(RuntimeError, match="LICENSE FAILURE"):
with pytest.raises(RuntimeError, match="LICENSE"):
erun.runEclipse()
max_attempts = 3
assert (tmp_path / "mock_log").read_text() == "Called mock\n" * max_attempts

0 comments on commit 7ef6fd6

Please sign in to comment.