Skip to content

Commit b89959a

Browse files
ci: Fix nightly dev test run workflow (#4201)
Add timeout loop in the following tests: 1. test_solver_monitors 2. test_monitors_list_set_data_637_974_1744_2188 Workflow - https://github.com/ansys/pyfluent/actions/runs/15780686928/job/44485332936 --------- Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 4696a5c commit b89959a

File tree

3 files changed

+56
-35
lines changed

3 files changed

+56
-35
lines changed

doc/changelog.d/4201.maintenance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix nightly dev test run workflow

tests/test_fluent_fixes.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import pytest
2424

2525
from ansys.fluent.core import examples
26+
from ansys.fluent.core.utils.execution import timeout_loop
2627

2728

2829
@pytest.mark.nightly
@@ -73,13 +74,17 @@ def test_monitors_list_set_data_637_974_1744_2188(new_solver_session):
7374

7475
monitors_list = solver_session.monitors.get_monitor_set_names()
7576

76-
assert monitors_list == [
77-
"residual",
78-
"mass-bal-rplot",
79-
"mass-tot-rplot",
80-
"mass-in-rplot",
81-
"point-vel-rplot",
82-
]
77+
assert timeout_loop(
78+
lambda: monitors_list
79+
== [
80+
"residual",
81+
"mass-bal-rplot",
82+
"mass-tot-rplot",
83+
"mass-in-rplot",
84+
"point-vel-rplot",
85+
],
86+
5,
87+
)
8388

8489
mp = solver_session.monitors.get_monitor_set_data(monitor_set_name="residual")
8590

@@ -95,14 +100,18 @@ def test_monitors_list_set_data_637_974_1744_2188(new_solver_session):
95100

96101
new_monitors_list = solver_session.monitors.get_monitor_set_names()
97102

98-
assert new_monitors_list == [
99-
"residual",
100-
"mass-bal-rplot",
101-
"mass-tot-rplot",
102-
"mass-in-rplot",
103-
"point-vel-rplot",
104-
"sample-report-plot",
105-
]
103+
assert timeout_loop(
104+
lambda: new_monitors_list
105+
== [
106+
"residual",
107+
"mass-bal-rplot",
108+
"mass-tot-rplot",
109+
"mass-in-rplot",
110+
"point-vel-rplot",
111+
"sample-report-plot",
112+
],
113+
5,
114+
)
106115

107116

108117
@pytest.mark.fluent_version(">=24.2")

tests/test_solver_monitors.py

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ def test_solver_monitors(new_solver_session):
4444
"point-vel-rplot",
4545
]
4646

47-
assert (
48-
sorted(solver.settings.solution.monitor.report_plots())
49-
== ordered_report_plot_names
47+
assert timeout_loop(
48+
lambda: sorted(solver.settings.solution.monitor.report_plots())
49+
== ordered_report_plot_names,
50+
5,
5051
)
5152

5253
# monitor set names unavailable without data
53-
assert len(solver.monitors.get_monitor_set_names()) == 0
54+
assert timeout_loop(lambda: len(solver.monitors.get_monitor_set_names()) == 0, 5)
5455

5556
import_data = examples.download_file(
5657
file_name="exhaust_system.dat.h5", directory="pyfluent/exhaust_system"
@@ -59,34 +60,44 @@ def test_solver_monitors(new_solver_session):
5960
solver.file.read_data(file_name=import_data)
6061

6162
# monitor set names remains unavailable after loading data
62-
assert len(solver.monitors.get_monitor_set_names()) == 0
63+
assert timeout_loop(lambda: len(solver.monitors.get_monitor_set_names()) == 0, 5)
6364

6465
# monitor set names becomes available after initializing
6566
solver.solution.initialization.hybrid_initialize()
6667

6768
monitor_set_names = ordered_report_plot_names + ["residual"]
68-
assert sorted(solver.monitors.get_monitor_set_names()) == sorted(monitor_set_names)
69+
assert timeout_loop(
70+
lambda: sorted(solver.monitors.get_monitor_set_names())
71+
== sorted(monitor_set_names),
72+
5,
73+
)
6974

7075
# no data in monitors at this point
71-
assert all(
72-
all(
73-
len(elem) == 0
74-
for elem in solver.monitors.get_monitor_set_data(monitor_set_name=name)
75-
)
76-
for name in monitor_set_names
77-
), "One or more monitor sets contain non-empty elements."
76+
def all_elements_empty(name):
77+
monitor_data = solver.monitors.get_monitor_set_data(monitor_set_name=name)
78+
return all(len(elem) == 0 for elem in monitor_data)
79+
80+
for name in monitor_set_names:
81+
assert timeout_loop(
82+
all_elements_empty,
83+
timeout=5,
84+
args=(name,),
85+
), f"Monitor set '{name}' contains non-empty elements."
7886

7987
# run the solver...
8088
solver.solution.run_calculation.iterate(iter_count=1)
8189

8290
# ...data is in monitors
83-
assert all(
84-
all(
85-
len(elem) != 0
86-
for elem in solver.monitors.get_monitor_set_data(monitor_set_name=name)
87-
)
88-
for name in monitor_set_names
89-
), "One or more monitor sets contain empty elements."
91+
def all_elements_non_empty(name):
92+
monitor_data = solver.monitors.get_monitor_set_data(monitor_set_name=name)
93+
return all(len(elem) != 0 for elem in monitor_data)
94+
95+
for name in monitor_set_names:
96+
assert timeout_loop(
97+
all_elements_non_empty,
98+
timeout=5,
99+
args=(name,),
100+
), f"Monitor set '{name}' contains one or more empty elements."
90101

91102
def monitor_callback():
92103
monitor_callback.called = True

0 commit comments

Comments
 (0)