fix(tests): prevent tag inheritance tests from polluting dev Celery queue#14493
Merged
valentijnscholten merged 1 commit intoDefectDojo:bugfixfrom Mar 12, 2026
Conversation
…elery queue product_tags_post_add_remove dispatches propagate_tags_on_product via dojo_dispatch_task. When the signal fires outside a request context (e.g. during test setUp), get_current_user() returns None, so we_want_async() always returns True regardless of block_execution — the task goes to the shared Redis queue. The real Celery worker then picks it up and runs against the live database, causing multi-hour tag propagation runs over large products. Fix: add @override_settings(CELERY_TASK_ALWAYS_EAGER=True) to the three test classes that enable system-wide product tag inheritance. This makes Celery run tasks inline in the test process, keeping tasks off the shared Redis queue and ensuring assertions see propagated tags.
Maffooch
approved these changes
Mar 11, 2026
blakeaowens
approved these changes
Mar 11, 2026
dogboat
approved these changes
Mar 12, 2026
b339824
into
DefectDojo:bugfix
544 of 546 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When you are running DD locally in dev mode and run the test_tags unit test, it will dispatch a celery task via
propagate_tags_on_product(4). In dev mode this means the celery worker will pick it up and apply it to product 4 in the local DD (non-test) database. In my case this was a product with 10002 findings from the JFrog Unified unit test sample file. If you have tag inheritance enabled, this task will run for hours on end updating each finding with the inherited tags.This PR ensures all celery tasks are executed synchronously in test_tags.py so that it gets executed in the test database.
product_tags_post_add_removedispatchespropagate_tags_on_productviadojo_dispatch_task. When the signal fires outside a request context (e.g. during testsetUp),get_current_user()returnsNone, sowe_want_async()always returnsTrueregardless ofblock_execution— the task goes to the shared Redis queue@override_settings(CELERY_TASK_ALWAYS_EAGER=True)to the three test classes that enable system-wide product tag inheritance (InheritedTagsTests,InheritedTagsImportTestAPI,InheritedTagsImportTestUI). This makes Celery run tasks inline in the test process, keeping tasks off the shared Redis queue and ensuring assertions see the results of tag propagation before checking them