Skip to content

Commit

Permalink
Fix flakiness for integration_test and gui unit_tests (#7077)
Browse files Browse the repository at this point in the history
* Fix flakiness unit_tests/gui timeout

Improves flakiness of unit_tests/gui/test_main_window::test_that_run_dialog_can_be_closed_after_used_to_open_plots by increasing timeout time for done_button to be enabled. This also applies to unit_tests/gui/simulation/test_run_dialog.py::test_that_run_dialog_can_be_closed_while_file_plot_is_open. In a different fixture, the timeout for running the experiment is set to 200.000, while here it was only 20.000. This commit increases this timeout to 200.000.

* Fix flaky unit test gui plotapi sharing storage

When running some of the gui unit tests in parallell, they would share storage. This was very prevalent for the test unit_tests/gui/test_main_window.py::test_that_gui_plotter_works_when_no_data, where the PlotApi would return data from the other tests (which running esmda). This is fixed in this commit by mocking the return value from PlotApi.

* Increase timeout on flaky test

Increase timeout to 60s for integration_tests/scheduler/test_integration_local_driver.py::test_subprocesses_live_on_after_ert_dies.
  • Loading branch information
jonathan-eq authored Feb 2, 2024
1 parent 98a43cc commit 848c2be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ async def test_subprocesses_live_on_after_ert_dies(tmp_path, try_queue_and_sched
create_ert_config(tmp_path)

ert_process = subprocess.Popen(["ert", "test_run", "ert_config.ert"], cwd=tmp_path)
check_path_retry, check_path_max_retries = 0, 50
check_path_retry, check_path_max_retries = 0, 60
expected_path = Path(tmp_path, "test_out/realization-0/iter-0/forward_model_pid")
while not expected_path.exists() and check_path_retry < check_path_max_retries:
check_path_retry += 1
await asyncio.sleep(0.5)
await asyncio.sleep(1)

assert ert_process.poll() is None
assert expected_path.exists()
child_process_id = expected_path.read_text(encoding="utf-8").strip()
assert child_process_id
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/gui/simulation/test_run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def handle_dialog():
qtbot.mouseClick(run_dialog.show_details_button, Qt.LeftButton)
job_view = run_dialog._job_view
qtbot.waitUntil(job_view.isVisible, timeout=20000)
qtbot.waitUntil(run_dialog.done_button.isVisible, timeout=20000)
qtbot.waitUntil(run_dialog.done_button.isVisible, timeout=200000)

realization_widget = run_dialog.findChild(RealizationWidget)

Expand Down
9 changes: 4 additions & 5 deletions tests/unit_tests/gui/test_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
CaseSelectCheckButton,
CaseSelectionWidget,
)
from ert.gui.tools.plot.plot_window import PlotWindow
from ert.gui.tools.plot.plot_window import PlotApi, PlotWindow
from ert.run_models import SingleTestRun
from ert.services import StorageService
from ert.shared.plugins.plugin_manager import ErtPluginManager
Expand Down Expand Up @@ -279,7 +279,7 @@ def handle_dialog():
assert not run_dialog.isModal()

qtbot.mouseClick(run_dialog.plot_button, Qt.LeftButton)
qtbot.waitUntil(run_dialog.done_button.isVisible, timeout=20000)
qtbot.waitUntil(run_dialog.done_button.isVisible, timeout=200000)
qtbot.mouseClick(run_dialog.done_button, Qt.LeftButton)

# Ensure that once the run dialog is closed
Expand Down Expand Up @@ -765,13 +765,13 @@ def handle_error_dialog(run_dialog):


@pytest.mark.usefixtures("use_tmpdir")
def test_that_gui_plotter_works_when_no_data(qtbot, storage):
def test_that_gui_plotter_works_when_no_data(qtbot, storage, monkeypatch):
monkeypatch.setattr(PlotApi, "_get_all_cases", lambda _: [])
config_file = "minimal_config.ert"
with open(config_file, "w", encoding="utf-8") as f:
f.write("NUM_REALIZATIONS 1")
args_mock = Mock()
args_mock.config = config_file

ert_config = ErtConfig.from_file(config_file)
enkf_main = EnKFMain(ert_config)
with StorageService.init_service(
Expand All @@ -782,7 +782,6 @@ def test_that_gui_plotter_works_when_no_data(qtbot, storage):
gui.notifier.set_storage(storage)
qtbot.addWidget(gui)
gui.tools["Create plot"].trigger()

plot_window = wait_for_child(gui, qtbot, PlotWindow)
case_selection = get_child(plot_window, CaseSelectionWidget)
assert isinstance(case_selection, CaseSelectionWidget)
Expand Down

0 comments on commit 848c2be

Please sign in to comment.