-
-
Notifications
You must be signed in to change notification settings - Fork 996
Add SQS & SNS integration tests #2505
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
rlaunch
wants to merge
21
commits into
celery:main
Choose a base branch
from
rlaunch:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
41dec39
Fixed locking deadlock and refactored to improve maintainability. Add…
73dc4ba
Fixed flake issue
7d9f26c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b9d6822
Merge branch 'main' into main
auvipy 7b4e017
Merge branch 'main' into main
auvipy 63bfe1c
Update t/unit/transport/SQS/test_SQS_SNS.py
auvipy 16002ed
Docstring fix
6407803
Merge branch 'main' of https://github.com/rlaunch/kombu
rlaunch f434cac
Added basic SQS & SNS integration tests
rlaunch 6eab05d
Fixed incorrect handling of None values when handling async SQS reque…
rlaunch 2432e38
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a0b211e
Update tox.ini
auvipy 67ede48
Update t/unit/asynchronous/aws/sqs/test_connection.py
auvipy ae3621b
Update kombu/asynchronous/aws/sqs/connection.py
auvipy ad8222b
Update t/unit/asynchronous/aws/sqs/test_connection.py
auvipy ee2ce63
Update t/integration/test_sqs.py
rlaunch ed5e721
Merge branch 'celery:main' into main
rlaunch 1871f6b
Fixed Copilot auto-merged fix in devcontainer PR, which tried to inst…
rlaunch ab7ecf6
Fixed potential issue when running tests in parallel. Addressed issue…
rlaunch 341b4a7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0037a04
Fixed import naming issue with the SNS module, preventing mocking of …
rlaunch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import os | ||
| from unittest.mock import patch | ||
|
|
||
| import pytest | ||
|
|
||
| import kombu | ||
| import kombu.asynchronous | ||
|
|
||
| from .common import BaseExchangeTypes, BaseMessage, BasicFunctionality | ||
|
|
||
|
|
||
| def get_connection(hostname, port): | ||
| return kombu.Connection( | ||
| f'sqs://{hostname}:{port}', | ||
| userid="TestUsername", # This can be anything | ||
| password="TestPassword", # This can be anything | ||
| transport_options={ | ||
| "supports_fanout": True, | ||
| "client-config": { | ||
| "region_name": "us-east-1", | ||
| } | ||
| }, | ||
| ) | ||
|
rlaunch marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def hub(): | ||
| """Provide a Kombu hub (event loop) for async I/O and callbacks.""" | ||
| h = kombu.asynchronous.Hub() | ||
| kombu.asynchronous.set_event_loop(h) | ||
| yield h | ||
| h.close() | ||
| kombu.asynchronous.set_event_loop(None) | ||
|
rlaunch marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def invalid_connection(): | ||
| return kombu.Connection('sqs://localhost:12345') | ||
|
|
||
|
rlaunch marked this conversation as resolved.
|
||
|
|
||
| @pytest.fixture() | ||
| def connection(hub): | ||
| conn = get_connection( | ||
| hostname=os.environ.get('SQS_HOST', 'localhost'), | ||
| port=os.environ.get('SQS_PORT', '4100'), | ||
| ) | ||
|
rlaunch marked this conversation as resolved.
Outdated
|
||
| conn.transport_options['hub'] = hub | ||
| return conn | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def mock_set_policy(): | ||
| """Mock the _set_policy_on_sqs_queue method as this is not supported by GoAws.""" | ||
| with patch("kombu.transport.SQS.SNS._SnsSubscription._set_policy_on_sqs_queue") as mock: | ||
| yield mock | ||
|
|
||
|
|
||
| @pytest.mark.env('sqs') | ||
| @pytest.mark.flaky(reruns=5, reruns_delay=2) | ||
| class test_SQSBasicFunctionality(BasicFunctionality): | ||
| pass | ||
|
|
||
|
|
||
| @pytest.mark.env('sqs') | ||
| @pytest.mark.flaky(reruns=5, reruns_delay=2) | ||
| class test_SQSBaseExchangeTypes(BaseExchangeTypes): | ||
| def test_fanout(self, connection): | ||
| ex = kombu.Exchange('test_fanout', type='fanout') | ||
| test_queue1 = kombu.Queue('fanout1', exchange=ex) | ||
| consumer1 = self._create_consumer(connection, test_queue1) | ||
| test_queue2 = kombu.Queue('fanout2', exchange=ex) | ||
| consumer2 = self._create_consumer(connection, test_queue2) | ||
|
|
||
| with connection as conn: | ||
| with conn.channel() as channel: | ||
| self._publish(channel, ex, [test_queue1, test_queue2]) | ||
|
|
||
| self._consume_from(conn, consumer1) | ||
| self._consume_from(conn, consumer2) | ||
|
|
||
|
|
||
| @pytest.mark.env('sqs') | ||
| @pytest.mark.flaky(reruns=5, reruns_delay=2) | ||
| class test_SQSMessage(BaseMessage): | ||
| pass | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.