-
Notifications
You must be signed in to change notification settings - Fork 13
Feature/deferred task correlation #120
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -820,6 +820,38 @@ def setUp(self): | |
| "filtered_retry_count_2": 0, | ||
| } | ||
|
|
||
| def test_future_task_runner_sets_cid(self): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a test covering when
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. basically every existing test is checking that condition
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Thanks! |
||
| data = {"cid": None} | ||
|
|
||
| def set_correlation_id(cid): | ||
| data["cid"] = cid | ||
|
|
||
| conf = tasks.future_task_runner.app.conf | ||
| old_val = conf["task_always_eager"] | ||
| conf["task_always_eager"] = True | ||
|
|
||
| old_set_cid = tasks._set_correlation_id | ||
| old_get_cid = tasks._get_correlation_id | ||
| tasks._set_correlation_id = set_correlation_id | ||
| tasks._get_correlation_id = lambda: "cid-sentinel" | ||
| try: | ||
| expected_response = {"foo": "bar"} | ||
| endpoint = _TestEndpoint(expected_response) | ||
| manager = machinery.EndpointBinder.BoundEndpointManager( | ||
| machinery._EndpointRequestLifecycleManager(endpoint), endpoint | ||
| ) | ||
| machinery.EndpointBinder(endpoint).create_bound_endpoint( | ||
| manager, HttpRequest() | ||
| ) | ||
|
|
||
| manager.get_response() | ||
| finally: | ||
| tasks._set_correlation_id = old_set_cid | ||
| tasks._get_correlation_id = old_get_cid | ||
| conf["task_always_eager"] = old_val | ||
|
|
||
| self.assertEqual("cid-sentinel", data["cid"]) | ||
|
|
||
| def test_get_response_kombu_error_retried(self): | ||
| expected_response = {"foo": "bar"} | ||
| endpoint = _TestEndpoint(expected_response) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we use it in testing, should we add
django-cidto ouroptional-dependencies?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're actually mocking it in testing, so it's not necessary. What's the rule for putting things in
optional-dependencies? It doesn't seem to simplify installing things with pipThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh- maybe you overload the necessary method in testing. I'm trying to think about where, if anywhere,
django-cidshould go in our listed dependencies inpyproject.toml. Maybe nowhere, and (ideally) we would just document that DDA supports it somewhere (README or docs). That doesn't need to be in this PR.