diff --git a/CHANGES/+fix_pytest_long_running.bugfix b/CHANGES/+fix_pytest_long_running.bugfix new file mode 100644 index 0000000000..0a8f0f32af --- /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 bd159acad6..2257b2990d 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 eae0d248cc..236afaf4c9 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() ):