Skip to content
Closed
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
17 changes: 7 additions & 10 deletions .github/workflows/test_pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,21 @@ jobs:
pip install numpy --upgrade
pytest rocketpy --doctest-modules --cov=rocketpy --cov-append

# Isolate flaky_vtk (#1078): native VTK/OpenGL crashes (SIGBUS/SIGSEGV)
# kill the pytest process, so keep them out of the main integration job
# and retry them in the dedicated step below.
- name: Run Integration Tests
run: |
pytest tests/integration \
--deselect tests/integration/test_plots.py::test_flight_animations_run_off_screen \
--deselect tests/integration/test_plots.py::test_flight_animations_render_all_scene_options \
--deselect tests/integration/test_plots.py::test_flight_animation_export_gif \
-m "not flaky_vtk" \
--cov=rocketpy --cov-append

- name: Run VTK animation tests
run: |
tests=(
tests/integration/test_plots.py::test_flight_animations_run_off_screen
tests/integration/test_plots.py::test_flight_animations_render_all_scene_options
tests/integration/test_plots.py::test_flight_animation_export_gif
)
attempts=3
# flaky_vtk marker selects the three PyVista flight animation tests.
attempts=5
for attempt in $(seq 1 "$attempts"); do
if pytest "${tests[@]}" --cov=rocketpy --cov-append; then
if pytest tests/integration -m flaky_vtk --cov=rocketpy --cov-append; then
exit 0
else
status=$?
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ exclude_also = [
]


[tool.pytest.ini_options]
markers = [
"slow: mark test as slow to run",
"flaky_vtk: VTK/PyVista off-screen animation tests that can SIGBUS/SIGSEGV on headless CI (#1078)",
]


[tool.ruff]
target-version = "py310"
line-length = 88
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def pytest_configure(config):
Config object to which the marker is added.
"""
config.addinivalue_line("markers", "slow: mark test as slow to run")
config.addinivalue_line(
"markers",
"flaky_vtk: VTK/PyVista off-screen animation tests that can "
"SIGBUS/SIGSEGV on headless CI (#1078)",
)


def pytest_collection_modifyitems(config, items):
Expand Down
26 changes: 17 additions & 9 deletions tests/integration/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from rocketpy.plots.compare import CompareFlights


@pytest.mark.flaky_vtk
def test_flight_animations_run_off_screen(flight_calisto):
"""Ensure both PyVista flight animations render successfully off screen."""

Expand All @@ -33,6 +34,7 @@ def test_flight_animations_run_off_screen(flight_calisto):
assert rotation_result is None


@pytest.mark.flaky_vtk
def test_flight_animations_render_all_scene_options(flight_calisto):
"""Exercise the animation scene builders with the full set of overlays.

Expand Down Expand Up @@ -70,21 +72,27 @@ def test_flight_animations_render_all_scene_options(flight_calisto):
assert rotation_result is None


@pytest.mark.flaky_vtk
def test_flight_animation_export_gif(flight_calisto, tmp_path):
"""Cover the deterministic GIF export path of ``_run_animation``."""
pytest.importorskip("pyvista")
pytest.importorskip("imageio")
export_file = tmp_path / "trajectory.gif"

result = flight_calisto.plots.animate_trajectory(
start=0,
stop=0.3,
time_step=0.1,
backend="none",
window_size=(240, 180),
color_by="speed",
export_file=str(export_file),
)
try:
result = flight_calisto.plots.animate_trajectory(
start=0,
stop=0.3,
time_step=0.1,
backend="none",
window_size=(240, 180),
color_by="speed",
export_file=str(export_file),
)
except OSError as exc:
# EnvironmentError is an alias of OSError. Skip only when the off-screen
# renderer is unavailable; assertion failures below still fail the test.
pytest.skip(f"Off-screen VTK rendering unavailable: {exc}")

assert result == str(export_file)
assert export_file.is_file()
Expand Down
Loading