Skip to content

Commit

Permalink
Move integration tests to tests/integration_tests
Browse files Browse the repository at this point in the history
Prior to this commit, the tests in tests/unit_tests were a mix of actual unit-tests and integration tests. This commit moves all integration tests (the ones marked with pytest.mark.integration_tests atleast) to a new directory tests/integration_tests.
The commit also adds pytest scheduler mark and simular fixture to integration tests which
should be ran with both scheduler and job queue.
  • Loading branch information
jonathan-eq committed Dec 13, 2023
1 parent fd4b902 commit 83f0daf
Show file tree
Hide file tree
Showing 26 changed files with 2,645 additions and 1,698 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ markers = [
"script",
"slow",
"unstable",
"scheduler"
]
log_cli = "false"
asyncio_mode = "auto"
Expand Down
14 changes: 14 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,20 @@ def excepthook(cls, exc, tb):
monkeypatch.setattr(sys, "excepthook", excepthook)


@pytest.fixture(params=[False, True])
def try_queue_and_scheduler(request, monkeypatch):
should_enable_scheduler = request.param
scheduler_mark = request.node.get_closest_marker("scheduler")
assert scheduler_mark
if scheduler_mark.kwargs.get("skip") and should_enable_scheduler:
pytest.skip("Skipping running test with scheduler enabled")
monkeypatch.setattr(
FeatureToggling._conf["scheduler"], "is_enabled", should_enable_scheduler
)
yield
monkeypatch.undo()


def pytest_collection_modifyitems(config, items):
for item in items:
fixtures = getattr(item, "fixturenames", ())
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ def run_cli_ES_with_case(poly_config):
return prior_sample, posterior_sample


@pytest.mark.scheduler
@pytest.mark.integration_test
def test_that_adaptive_localization_with_cutoff_1_equals_ensemble_prior(copy_poly_case):
def test_that_adaptive_localization_with_cutoff_1_equals_ensemble_prior(
copy_poly_case, try_queue_and_scheduler
):
set_adaptive_localization_1 = dedent(
"""
ANALYSIS_SET_VAR STD_ENKF LOCALIZATION True
Expand All @@ -65,8 +68,11 @@ def test_that_adaptive_localization_with_cutoff_1_equals_ensemble_prior(copy_pol
assert np.allclose(posterior_sample, prior_sample)


@pytest.mark.scheduler
@pytest.mark.integration_test
def test_that_adaptive_localization_with_cutoff_0_equals_ESupdate(copy_poly_case):
def test_that_adaptive_localization_with_cutoff_0_equals_ESupdate(
copy_poly_case, try_queue_and_scheduler
):
"""
Note that "RANDOM_SEED" in both ert configs needs to be the same to obtain
the same sample from the prior.
Expand Down Expand Up @@ -101,8 +107,11 @@ def test_that_adaptive_localization_with_cutoff_0_equals_ESupdate(copy_poly_case
assert np.allclose(posterior_sample_loc0, posterior_sample_noloc)


@pytest.mark.scheduler
@pytest.mark.integration_test
def test_that_posterior_generalized_variance_increases_in_cutoff(copy_poly_case):
def test_that_posterior_generalized_variance_increases_in_cutoff(
copy_poly_case, try_queue_and_scheduler
):
rng = np.random.default_rng(42)
cutoff1 = rng.uniform(0, 1)
cutoff2 = rng.uniform(cutoff1, 1)
Expand Down
Loading

0 comments on commit 83f0daf

Please sign in to comment.