From 909663425fc9931099f7b0d9dc417144cc66b5e9 Mon Sep 17 00:00:00 2001 From: Grant Gainey Date: Mon, 21 Sep 2026 10:31:47 -0400 Subject: [PATCH] [PULP_2425] Fixed pytest.mark.long_running to skip correctly. Previously, would always-run on nightly even if timeout wasn't "long enough", causing regular transient failures in nightly CI. This also fixes a discovered timing-window in the task-cleanup code, where a missing worker's task wouldn't be cleaned up until a new task entered the system. Fixes PULP-2425. Co-authored-by: Matthias Dellweg --- CHANGES/+fix_pytest_long_running.bugfix | 3 +++ pulpcore/pytest_plugin.py | 15 +++++++-------- pulpcore/tasking/worker.py | 4 +--- 3 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 CHANGES/+fix_pytest_long_running.bugfix diff --git a/CHANGES/+fix_pytest_long_running.bugfix b/CHANGES/+fix_pytest_long_running.bugfix new file mode 100644 index 00000000000..0a8f0f32af2 --- /dev/null +++ b/CHANGES/+fix_pytest_long_running.bugfix @@ -0,0 +1,3 @@ +Fixed the `long_running` pytest-mark, so that it correctly applies even when "nightly" +is selected. This includes fixing a window in the task-cleanup path, where a missing +worker's jobs were not getting cleaned up until a new task entered the system. diff --git a/pulpcore/pytest_plugin.py b/pulpcore/pytest_plugin.py index bd159acad66..2257b2990d1 100644 --- a/pulpcore/pytest_plugin.py +++ b/pulpcore/pytest_plugin.py @@ -43,15 +43,7 @@ def pytest_addoption(parser): ) def pytest_collection_modifyitems(config, items): - # Skip nightly tests by default # https://docs.pytest.org/en/7.1.x/example/simple.html#control-skipping-of-tests-according-to-command-line-option - if config.getoption("--nightly"): - # Run all tests unmodified - return - skip_nightly = pytest.mark.skip(reason="need --nightly option to run") - for item in items: - if "nightly" in item.keywords: - item.add_marker(skip_nightly) # Skip long_running tests if --timeout is below 600 timeout = config.getoption("--timeout", default=None) @@ -61,6 +53,13 @@ def pytest_collection_modifyitems(config, items): if "long_running" in item.keywords: item.add_marker(skip_long) + # Skip anything labeled "nightly" unless --nightly specified + if not config.getoption("--nightly"): + skip_nightly = pytest.mark.skip(reason="need --nightly option to run") + for item in items: + if "nightly" in item.keywords: + item.add_marker(skip_nightly) + class PulpTaskTimeoutError(Exception): """Exception to describe task and taskgroup timeout errors.""" diff --git a/pulpcore/tasking/worker.py b/pulpcore/tasking/worker.py index eae0d248cc7..236afaf4c9f 100644 --- a/pulpcore/tasking/worker.py +++ b/pulpcore/tasking/worker.py @@ -345,9 +345,7 @@ def unblock_tasks(self): self.wakeup_unblock = False result = self._unblock_tasks() if result is not None and ( - Task.objects.filter( - state__in=[TASK_STATES.WAITING, TASK_STATES.CANCELING], app_lock=None - ) + Task.objects.filter(state__in=TASK_INCOMPLETE_STATES, app_lock=None) .exclude(unblocked_at=None) .exists() ):