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

Fix flakiness for gui unit_tests #7077

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
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
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
Loading