Skip to content

Commit

Permalink
Fix LSF drivers ability to send to non-default queue
Browse files Browse the repository at this point in the history
The Python LSF driver had a bug in a regexp causing it
to crash if one tried to use a queue other than the default.
  • Loading branch information
berland committed Mar 15, 2024
1 parent fd5a365 commit a195daa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions ci/testkomodo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ start_tests () {

# Using presence of "bsub" in PATH to detect onprem vs azure
if which bsub >/dev/null && basetemp=$(mktemp -d -p ~/pytest-tmp); then
export _ERT_TESTS_ALTERNATIVE_QUEUE=short
pytest -v --lsf --basetemp="$basetemp" integration_tests/scheduler
rm -rf "$basetemp"
fi
Expand Down
2 changes: 1 addition & 1 deletion src/ert/scheduler/lsf_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ async def submit(
if not process_success:
raise RuntimeError(process_message)

match = re.search("Job <([0-9]+)> is submitted to .+ queue", process_message)
match = re.search("Job <([0-9]+)> is submitted to .*queue", process_message)
if match is None:
raise RuntimeError(f"Could not understand '{process_message}' from bsub")
job_id = match[1]
Expand Down
5 changes: 4 additions & 1 deletion tests/integration_tests/scheduler/bin/bsub
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ set -e

name="STDIN"

while getopts "J:" opt
while getopts "J:q:" opt
do
case "$opt" in
J)
name=$OPTARG
;;
q)
queue=$OPTARG
;;
*)
echo "Unprocessed option ${opt}"
;;
Expand Down
15 changes: 15 additions & 0 deletions tests/integration_tests/scheduler/test_lsf_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ async def test_job_name():
assert "my_job" in stdout.decode()


@pytest.mark.integration_test
async def test_submit_to_named_queue(tmp_path, caplog):
"""If the environment variable _ERT_TEST_ALTERNATIVE_QUEUE is defined
a job will be attempted submitted to that queue.
As Ert does not keep track of which queue a job is executed in, we can only
test for success for the job."""
os.chdir(tmp_path)
driver = LsfDriver(queue_name=os.getenv("_ERT_TESTS_ALTERNATIVE_QUEUE"))
await driver.submit(0, "sh", "-c", f"echo test > {tmp_path}/test")
await poll(driver, {0})

assert (tmp_path / "test").read_text(encoding="utf-8") == "test\n"


@pytest.mark.parametrize(
"actual_returncode, returncode_that_ert_sees",
[
Expand Down

0 comments on commit a195daa

Please sign in to comment.