From df6a3038891fdfd670f41242532d8be912544b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eide?= Date: Fri, 10 Jan 2025 10:42:52 +0100 Subject: [PATCH] Refine tests --- tests/everest/test_res_initialization.py | 54 ++++++++---------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/tests/everest/test_res_initialization.py b/tests/everest/test_res_initialization.py index 926aa5f975a..0a42edbe3e6 100644 --- a/tests/everest/test_res_initialization.py +++ b/tests/everest/test_res_initialization.py @@ -10,6 +10,12 @@ import everest from ert.config import ExtParamConfig from ert.config.parsing import ConfigKeys as ErtConfigKeys +from ert.config.queue_config import ( + LocalQueueOptions, + LsfQueueOptions, + SlurmQueueOptions, + TorqueQueueOptions, +) from everest import ConfigKeys as CK from everest.config import EverestConfig, EverestValidationError from everest.simulator.everest_to_ert import ( @@ -24,7 +30,7 @@ @pytest.mark.parametrize( - "config, expected", + "config, config_class", [ [ { @@ -34,6 +40,9 @@ "project_code": "", "activate_script": "activate_script", }, + LocalQueueOptions, + ], + [ { "name": "torque", "qsub_cmd": "qsub", @@ -44,14 +53,7 @@ "job_prefix": "job_prefix", "keep_qsub_output": False, }, - { - "project_code": "snake_oil_pc", - "qsub_cmd": "qsub", - "qstat_cmd": "qstat", - "qdel_cmd": "qdel", - "keep_qsub_output": True, - "queue_name": "permanent_8", - }, + TorqueQueueOptions, ], [ { @@ -67,17 +69,7 @@ "squeue_timeout": 2.0, "max_runtime": 10, }, - { - "exclude_hosts": "host1,host2,host3,host4", - "include_hosts": "host5,host6,host7,host8", - "queue_name": "default-queue", - "sacct_cmd": "sacct", - "sbatch_cmd": "sbatch", - "scancel_cmd": "scancel", - "scontrol_cmd": "scontrol", - "squeue_cmd": "squeue", - "squeue_timeout": 2, - }, + SlurmQueueOptions, ], [ { @@ -90,37 +82,25 @@ "lsf_queue": "lsf_queue", "lsf_resource": "", }, - { - "queue_name": "mr", - "resource_requirement": "span = 1 && select[x86 and GNU/Linux]", - }, + LsfQueueOptions, ], ], ) -def test_everest_to_ert_queue_config(config, expected): +def test_everest_to_ert_queue_config(config, config_class): """Note that these objects are used directly in the Everest config, and if you have to make changes to this test, it is likely that it is a breaking change to Everest""" general_queue_options = {"max_running": 10} general_options = {"resubmit_limit": 7} - + config |= general_queue_options ever_config = EverestConfig.with_defaults( **{ - "simulator": {"queue_system": config | general_queue_options} - | general_options, + "simulator": {"queue_system": config} | general_options, "model": {"realizations": [0]}, } ) ert_config = everest_to_ert_config(ever_config) - - qc = ert_config.queue_config - qo = qc.queue_options - assert str(qc.queue_system) == config["name"] - driver_options = qo.driver_options - driver_options.pop("activate_script") - assert {k: v for k, v in driver_options.items() if v is not None} == expected - assert qc.max_submit == general_options["resubmit_limit"] + 1 - assert qo.max_running == general_queue_options["max_running"] + assert ert_config.queue_config.queue_options == config_class(**config) def test_everest_to_ert_controls():