Skip to content

fix(taskworker): Check registry before creating task namespace in tests #94659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

enochtangg
Copy link
Member

This test is currently broken. This PR is responsible for fixing the set up for TestTaskworkerRollout by ensuring to not re-create the task namespace if it already exists.

@enochtangg enochtangg changed the title check registry before create task namespace fix(taskworker): Check registry before creating task namespace in tests Jun 30, 2025
Copy link

codecov bot commented Jun 30, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
tests/sentry/tasks/test_taskworker_rollout.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #94659      +/-   ##
==========================================
+ Coverage   79.24%   85.24%   +6.00%     
==========================================
  Files       10422    10424       +2     
  Lines      603079   603103      +24     
  Branches    23470    23470              
==========================================
+ Hits       477893   514111   +36218     
+ Misses     124680    88240   -36440     
- Partials      506      752     +246     

Copy link
Member

@john-z-yang john-z-yang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good temporary fix to unblock us, but maybe there was another test that created the test_namespace but did not unregister it in the tearDown method. When the tests got shuffled, that test did not run first so it caused this one to fail.

Let me see if I can find tests that are doing that

Comment on lines 14 to +19
def setUp(self):
super().setUp()
self.namespace = registry.create_namespace(name="test_namespace")
if not registry.contains("test_namespace"):
self.namespace = registry.create_namespace(name="test_namespace")
else:
self.namespace = registry.get("test_namespace")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests shouldn't be irreversibly modifying global state -- the correct fix is to undo the mutation in a teardown rather than making this idempotent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants