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

Add a submit-test for LSF-driver #6672

Closed
wants to merge 1 commit into from
Closed
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
33 changes: 30 additions & 3 deletions tests/unit_tests/scheduler/test_lsf_driver.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import os
import stat
from argparse import ArgumentParser
Expand All @@ -12,9 +13,9 @@
from ert.__main__ import ert_parser
from ert.cli import ENSEMBLE_EXPERIMENT_MODE
from ert.cli.main import run_cli
from ert.config import QueueSystem
from ert.config import QueueConfig, QueueSystem
from ert.run_arg import RunArg
from ert.scheduler import Driver, QueueableRealization
from ert.scheduler import Driver, QueueableRealization, RealizationState
from ert.storage import EnsembleAccessor

DUMMY_CONFIG: Dict[str, Any] = {
Expand Down Expand Up @@ -125,7 +126,7 @@ def make_mock_bsub(script_path):
print(f"Job <{_id}> is submitted to default queue <normal>.")

# Launch job-dispatch
subprocess.Popen([job_dispatch_path, run_path])
#subprocess.Popen([job_dispatch_path, run_path])
"""
)
)
Expand Down Expand Up @@ -260,3 +261,29 @@ def test_num_cpu_submitted_correctly_lsf(tmpdir, simple_script):
found_cpu_arg = True

assert found_cpu_arg is True


@pytest.mark.usefixtures(mock_bsub)
async def test_submit(tmpdir):
os.chdir(tmpdir)
print(tmpdir)
config = QueueConfig.from_dict(
{
"QUEUE_SYSTEM": QueueSystem.LSF,
"QUEUE_OPTION": [(QueueSystem.LSF, "BSUB_CMD", str(tmpdir) + "/mock_bsub")],
}
)

class MockedQueue:
_statechanges_to_publish = None
driver = Driver.create_driver(config)

runarg = RunArg(
run_id=1, ensemble_storage=None, iens=1, itr=0, runpath=".", job_name="foo"
)
real0 = RealizationState(MockedQueue, QueueableRealization("script.sh", runarg))
real0.activate()
real0.submit()
while not Path("bsub_log").exists():
await asyncio.sleep(0.001)
assert len(Path("bsub_log").read_text(encoding="utf-8").splitlines()) == 1
Loading