diff --git a/sdk/servicebus/azure-servicebus/assets.json b/sdk/servicebus/azure-servicebus/assets.json index 1b34966de7e8..7809dd04233e 100644 --- a/sdk/servicebus/azure-servicebus/assets.json +++ b/sdk/servicebus/azure-servicebus/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/servicebus/azure-servicebus", - "Tag": "python/servicebus/azure-servicebus_f69b8e6a3c" + "Tag": "python/servicebus/azure-servicebus_81b962314c" } diff --git a/sdk/servicebus/azure-servicebus/dev_requirements.txt b/sdk/servicebus/azure-servicebus/dev_requirements.txt index fbaca6a69553..3562e477bc94 100644 --- a/sdk/servicebus/azure-servicebus/dev_requirements.txt +++ b/sdk/servicebus/azure-servicebus/dev_requirements.txt @@ -2,6 +2,6 @@ -e ../../identity/azure-identity -e ../../../tools/azure-devtools -e ../../../tools/azure-sdk-tools -azure-mgmt-servicebus~=1.0.0 +azure-mgmt-servicebus~=8.0.0 aiohttp>=3.0 azure-mgmt-resource<=16.0.0 \ No newline at end of file diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_queues_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_queues_async.py index d7a6429044f3..d86ae08a4c4a 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_queues_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_queues_async.py @@ -48,8 +48,13 @@ MessageSizeExceededError, OperationTimeoutError ) -from devtools_testutils import AzureMgmtTestCase, CachedResourceGroupPreparer, AzureTestCase -from servicebus_preparer import CachedServiceBusNamespacePreparer, CachedServiceBusQueuePreparer, ServiceBusQueuePreparer +from devtools_testutils import AzureMgmtTestCase, AzureTestCase +from servicebus_preparer import ( + CachedServiceBusNamespacePreparer, + CachedServiceBusQueuePreparer, + ServiceBusQueuePreparer, + CachedServiceBusResourceGroupPreparer +) from utilities import get_logger, print_message, sleep_until_expired from mocks_async import MockReceivedMessage, MockReceiver @@ -61,7 +66,7 @@ class ServiceBusQueueAsyncTests(AzureMgmtTestCase): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT10S') async def test_async_queue_by_queue_client_conn_str_receive_handler_peeklock(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -127,7 +132,7 @@ async def test_async_queue_by_queue_client_conn_str_receive_handler_peeklock(sel @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT10S') async def test_async_queue_by_queue_client_conn_str_receive_handler_release_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -288,7 +293,7 @@ def _hack_disable_receive_context_message_received(self, message): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_queue_client_send_multiple_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -337,7 +342,7 @@ async def test_async_queue_by_queue_client_send_multiple_messages(self, serviceb @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_github_issue_7079_async(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -358,7 +363,7 @@ async def test_github_issue_7079_async(self, servicebus_namespace_connection_str @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_github_issue_6178_async(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -380,7 +385,7 @@ async def test_github_issue_6178_async(self, servicebus_namespace_connection_str @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT10S') async def test_async_queue_by_queue_client_conn_str_receive_handler_receiveanddelete(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -415,7 +420,7 @@ async def test_async_queue_by_queue_client_conn_str_receive_handler_receiveandde @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_queue_client_conn_str_receive_handler_with_stop(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -451,7 +456,7 @@ async def test_async_queue_by_queue_client_conn_str_receive_handler_with_stop(se @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_iter_messages_simple(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -483,7 +488,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_simple(self, servi @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_conn_str_client_iter_messages_with_abandon(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -520,7 +525,7 @@ async def test_async_queue_by_servicebus_conn_str_client_iter_messages_with_aban @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_iter_messages_with_defer(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -554,7 +559,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_defer(self, s @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_client(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -590,7 +595,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_defe @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_complete(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -627,7 +632,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_defe @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_deadletter(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -673,7 +678,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_defe @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_deletemode(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -707,7 +712,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_defe @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_not_found(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -741,7 +746,7 @@ async def test_async_queue_by_servicebus_client_iter_messages_with_retrieve_defe @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_receive_batch_with_deadletter(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -792,7 +797,7 @@ async def test_async_queue_by_servicebus_client_receive_batch_with_deadletter(se @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_receive_batch_with_retrieve_deadletter(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -837,7 +842,7 @@ async def test_async_queue_by_servicebus_client_receive_batch_with_retrieve_dead @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_session_fail(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -853,7 +858,7 @@ async def test_async_queue_by_servicebus_client_session_fail(self, servicebus_na @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_browse_messages_client(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -877,7 +882,7 @@ async def test_async_queue_by_servicebus_client_browse_messages_client(self, ser @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_browse_messages_with_receiver(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -901,7 +906,7 @@ async def test_async_queue_by_servicebus_client_browse_messages_with_receiver(se @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_browse_empty_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -915,7 +920,7 @@ async def test_async_queue_by_servicebus_client_browse_empty_messages(self, serv @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_renew_message_locks(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -954,7 +959,7 @@ async def test_async_queue_by_servicebus_client_renew_message_locks(self, servic @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT5S') async def test_async_queue_by_queue_client_conn_str_receive_handler_with_autolockrenew(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1009,7 +1014,7 @@ async def test_async_queue_by_queue_client_conn_str_receive_handler_with_autoloc @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT5S') async def test_async_queue_by_queue_client_conn_str_receive_handler_with_auto_autolockrenew(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1063,7 +1068,7 @@ async def test_async_queue_by_queue_client_conn_str_receive_handler_with_auto_au @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_by_servicebus_client_fail_send_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1083,7 +1088,7 @@ async def test_async_queue_by_servicebus_client_fail_send_messages(self, service @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_message_time_to_live(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1116,7 +1121,7 @@ async def test_async_queue_message_time_to_live(self, servicebus_namespace_conne @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_duplicate_detection=True, dead_lettering_on_message_expiration=True) async def test_async_queue_message_duplicate_detection(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1143,7 +1148,7 @@ async def test_async_queue_message_duplicate_detection(self, servicebus_namespac @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_message_connection_closed(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1165,7 +1170,7 @@ async def test_async_queue_message_connection_closed(self, servicebus_namespace_ @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_message_expiry(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1197,7 +1202,7 @@ async def test_async_queue_message_expiry(self, servicebus_namespace_connection_ @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_message_lock_renew(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1227,7 +1232,7 @@ async def test_async_queue_message_lock_renew(self, servicebus_namespace_connect @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT10S') async def test_async_queue_message_receive_and_delete(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1264,7 +1269,7 @@ async def test_async_queue_message_receive_and_delete(self, servicebus_namespace @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_message_batch(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1321,7 +1326,7 @@ def message_content(): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_schedule_message(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1356,7 +1361,7 @@ async def test_async_queue_schedule_message(self, servicebus_namespace_connectio @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_schedule_multiple_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1405,7 +1410,7 @@ async def test_async_queue_schedule_multiple_messages(self, servicebus_namespace @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_cancel_scheduled_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1428,7 +1433,7 @@ async def test_async_queue_cancel_scheduled_messages(self, servicebus_namespace_ @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_queue_message_amqp_over_websocket(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1471,7 +1476,7 @@ async def test_queue_message_http_proxy_setting(self): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_queue_message_settle_through_mgmt_link_due_to_broken_receiver_link(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1607,7 +1612,7 @@ async def test_async_queue_mock_no_reusing_auto_lock_renew(self): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') async def test_queue_receiver_invalid_autolockrenew_mode(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1624,7 +1629,7 @@ async def test_queue_receiver_invalid_autolockrenew_mode(self, servicebus_namesp @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_receive_batch_without_setting_prefetch(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1677,7 +1682,7 @@ def message_content(): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_receiver_alive_after_timeout(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1729,7 +1734,7 @@ async def test_async_queue_receiver_alive_after_timeout(self, servicebus_namespa @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT5M') async def test_queue_receive_keep_conn_alive_async(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1764,7 +1769,7 @@ async def test_queue_receive_keep_conn_alive_async(self, servicebus_namespace_co @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') async def test_async_queue_receiver_respects_max_wait_time_overrides(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1811,7 +1816,7 @@ async def test_async_queue_receiver_respects_max_wait_time_overrides(self, servi @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') async def test_async_queue_send_twice(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1845,7 +1850,7 @@ async def test_async_queue_send_twice(self, servicebus_namespace_connection_stri @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_send_timeout(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1872,7 +1877,7 @@ async def _hack_amqp_sender_run_async(cls): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_queue_mgmt_operation_timeout(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1910,7 +1915,7 @@ async def hack_mgmt_execute_async(self, operation, op_type, message, timeout=0): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', lock_duration='PT10S') async def test_async_queue_operation_negative(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1958,7 +1963,7 @@ async def _hack_sb_receiver_settle_message(self, settle_operation, dead_letter_r @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_async_send_message_no_body(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1977,7 +1982,7 @@ async def test_async_send_message_no_body(self, servicebus_namespace_connection_ @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') async def test_async_queue_by_servicebus_client_enum_case_sensitivity(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2007,7 +2012,7 @@ async def test_async_queue_by_servicebus_client_enum_case_sensitivity(self, serv @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') async def test_queue_async_send_dict_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2041,7 +2046,7 @@ async def test_queue_async_send_dict_messages(self, servicebus_namespace_connect @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') async def test_queue_async_send_mapping_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2089,7 +2094,7 @@ def __init__(self): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') async def test_queue_async_send_dict_messages_error_badly_formatted_dicts(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2118,7 +2123,7 @@ async def test_queue_async_send_dict_messages_error_badly_formatted_dicts(self, @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_queue_async_send_dict_messages_scheduled(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2180,7 +2185,7 @@ async def test_queue_async_send_dict_messages_scheduled(self, servicebus_namespa @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_queue_async_send_dict_messages_scheduled_error_badly_formatted_dicts(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2204,7 +2209,7 @@ async def test_queue_async_send_dict_messages_scheduled_error_badly_formatted_di @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_queue_async_receive_iterator_resume_after_link_detach(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2247,7 +2252,7 @@ async def hack_iter_next_mock_error(self): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_queue_async_send_amqp_annotated_message(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2346,7 +2351,7 @@ async def test_queue_async_send_amqp_annotated_message(self, servicebus_namespac @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_state_scheduled_async(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2370,7 +2375,7 @@ async def test_state_scheduled_async(self, servicebus_namespace_connection_strin @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_state_deferred_async(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_sb_client_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_sb_client_async.py index 9c4047b94fb6..d42e1dfd218f 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_sb_client_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_sb_client_async.py @@ -19,7 +19,7 @@ ServiceBusAuthenticationError, ServiceBusAuthorizationError ) -from devtools_testutils import AzureMgmtTestCase, CachedResourceGroupPreparer +from devtools_testutils import AzureMgmtTestCase from servicebus_preparer import ( CachedServiceBusNamespacePreparer, ServiceBusTopicPreparer, @@ -28,7 +28,9 @@ ServiceBusQueueAuthorizationRulePreparer, CachedServiceBusQueuePreparer, CachedServiceBusTopicPreparer, - CachedServiceBusSubscriptionPreparer + CachedServiceBusSubscriptionPreparer, + CachedServiceBusResourceGroupPreparer, + SERVICEBUS_ENDPOINT_SUFFIX ) from utilities import get_logger @@ -39,12 +41,12 @@ class ServiceBusClientAsyncTests(AzureMgmtTestCase): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) async def test_sb_client_bad_credentials_async(self, servicebus_namespace, servicebus_queue, **kwargs): client = ServiceBusClient( - fully_qualified_namespace=servicebus_namespace.name + '.servicebus.windows.net', + fully_qualified_namespace=f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}", credential=ServiceBusSharedKeyCredential('invalid', 'invalid'), logging_enable=False) async with client: @@ -58,7 +60,7 @@ async def test_sb_client_bad_credentials_async(self, servicebus_namespace, servi async def test_sb_client_bad_namespace_async(self, **kwargs): client = ServiceBusClient( - fully_qualified_namespace='invalid.servicebus.windows.net', + fully_qualified_namespace=f'invalid{SERVICEBUS_ENDPOINT_SUFFIX}', credential=ServiceBusSharedKeyCredential('invalid', 'invalid'), logging_enable=False) async with client: @@ -69,11 +71,11 @@ async def test_sb_client_bad_namespace_async(self, **kwargs): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') async def test_sb_client_bad_entity_async(self): - fake_str = "Endpoint=sb://mock.servicebus.windows.net/;" \ - "SharedAccessKeyName=mock;SharedAccessKey=mock;EntityPath=mockentity" + fake_str = f"Endpoint=sb://mock{SERVICEBUS_ENDPOINT_SUFFIX}/;" \ + f"SharedAccessKeyName=mock;SharedAccessKey=mock;EntityPath=mockentity" fake_client = ServiceBusClient.from_connection_string(fake_str) with pytest.raises(ValueError): @@ -93,8 +95,8 @@ async def test_sb_client_bad_entity_async(self): fake_client.get_topic_sender('mockentity') fake_client.get_subscription_receiver('mockentity', 'subscription') - fake_str = "Endpoint=sb://mock.servicebus.windows.net/;" \ - "SharedAccessKeyName=mock;SharedAccessKey=mock" + fake_str = f"Endpoint=sb://mock{SERVICEBUS_ENDPOINT_SUFFIX}/;" \ + f"SharedAccessKeyName=mock;SharedAccessKey=mock" fake_client = ServiceBusClient.from_connection_string(fake_str) fake_client.get_queue_sender('queue') fake_client.get_queue_receiver('queue') @@ -104,7 +106,7 @@ async def test_sb_client_bad_entity_async(self): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) @ServiceBusNamespaceAuthorizationRulePreparer(name_prefix='servicebustest', access_rights=[AccessRights.listen]) @@ -122,7 +124,7 @@ async def test_sb_client_readonly_credentials(self, servicebus_authorization_rul @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) @ServiceBusNamespaceAuthorizationRulePreparer(name_prefix='servicebustest', access_rights=[AccessRights.send]) @@ -143,7 +145,7 @@ async def test_sb_client_writeonly_credentials_async(self, servicebus_authorizat @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) @CachedServiceBusTopicPreparer(name_prefix='servicebustest') @@ -233,7 +235,7 @@ async def test_async_sb_client_close_spawned_handlers(self, servicebus_namespace @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusNamespaceAuthorizationRulePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest_qone', parameter_name='wrong_queue', dead_lettering_on_message_expiration=True) @@ -289,7 +291,7 @@ async def test_sb_client_incorrect_queue_conn_str_async(self, servicebus_queue_a @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') async def test_client_sas_credential_async(self, @@ -301,7 +303,7 @@ async def test_client_sas_credential_async(self, **kwargs): # This should "just work" to validate known-good. credential = ServiceBusSharedKeyCredential(servicebus_namespace_key_name, servicebus_namespace_primary_key) - hostname = "{}.servicebus.windows.net".format(servicebus_namespace.name) + hostname = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" auth_uri = "sb://{}/{}".format(hostname, servicebus_queue.name) token = (await credential.get_token(auth_uri)).token @@ -317,7 +319,7 @@ async def test_client_sas_credential_async(self, @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') async def test_client_credential_async(self, @@ -329,7 +331,7 @@ async def test_client_credential_async(self, **kwargs): # This should "just work" to validate known-good. credential = ServiceBusSharedKeyCredential(servicebus_namespace_key_name, servicebus_namespace_primary_key) - hostname = "{}.servicebus.windows.net".format(servicebus_namespace.name) + hostname = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" client = ServiceBusClient(hostname, credential) async with client: @@ -337,7 +339,7 @@ async def test_client_credential_async(self, async with client.get_queue_sender(servicebus_queue.name) as sender: await sender.send_messages(ServiceBusMessage("foo")) - hostname = "sb://{}.servicebus.windows.net".format(servicebus_namespace.name) + hostname = f"sb://{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" client = ServiceBusClient(hostname, credential) async with client: @@ -345,8 +347,7 @@ async def test_client_credential_async(self, async with client.get_queue_sender(servicebus_queue.name) as sender: await sender.send_messages(ServiceBusMessage("foo")) - hostname = "https://{}.servicebus.windows.net \ - ".format(servicebus_namespace.name) + hostname = f"https://{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" client = ServiceBusClient(hostname, credential) async with client: @@ -357,7 +358,7 @@ async def test_client_credential_async(self, @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') async def test_client_azure_sas_credential_async(self, @@ -369,7 +370,7 @@ async def test_client_azure_sas_credential_async(self, **kwargs): # This should "just work" to validate known-good. credential = ServiceBusSharedKeyCredential(servicebus_namespace_key_name, servicebus_namespace_primary_key) - hostname = "{}.servicebus.windows.net".format(servicebus_namespace.name) + hostname = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" auth_uri = "sb://{}/{}".format(hostname, servicebus_queue.name) token = (await credential.get_token(auth_uri)).token.decode() @@ -384,7 +385,7 @@ async def test_client_azure_sas_credential_async(self, @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') async def test_client_named_key_credential_async(self, @@ -394,7 +395,7 @@ async def test_client_named_key_credential_async(self, servicebus_namespace_primary_key, servicebus_namespace_connection_string, **kwargs): - hostname = "{}.servicebus.windows.net".format(servicebus_namespace.name) + hostname = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" credential = AzureNamedKeyCredential(servicebus_namespace_key_name, servicebus_namespace_primary_key) client = ServiceBusClient(hostname, credential) @@ -456,7 +457,7 @@ async def test_backoff_fixed_retry(self): assert sleep_time_fixed < backoff * (2 ** 1) async def test_custom_client_id_queue_sender_async(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' queue_name = "queue_name" custom_id = "my_custom_id" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) @@ -466,7 +467,7 @@ async def test_custom_client_id_queue_sender_async(self, **kwargs): assert queue_sender.client_identifier == custom_id async def test_default_client_id_queue_sender(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' queue_name = "queue_name" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) async with servicebus_client: @@ -475,7 +476,7 @@ async def test_default_client_id_queue_sender(self, **kwargs): assert "SBSender" in queue_sender.client_identifier async def test_custom_client_id_queue_receiver(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' queue_name = "queue_name" custom_id = "my_custom_id" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) @@ -485,7 +486,7 @@ async def test_custom_client_id_queue_receiver(self, **kwargs): assert queue_receiver.client_identifier == custom_id async def test_default_client_id_queue_receiver(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' queue_name = "queue_name" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) async with servicebus_client: @@ -494,7 +495,7 @@ async def test_default_client_id_queue_receiver(self, **kwargs): assert "SBReceiver" in queue_receiver.client_identifier async def test_custom_client_id_topic_sender(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' custom_id = "my_custom_id" topic_name = "topic_name" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) @@ -504,7 +505,7 @@ async def test_custom_client_id_topic_sender(self, **kwargs): assert topic_sender.client_identifier == custom_id async def test_default_client_id_topic_sender(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' topic_name = "topic_name" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) async with servicebus_client: @@ -513,7 +514,7 @@ async def test_default_client_id_topic_sender(self, **kwargs): assert "SBSender" in topic_sender.client_identifier async def test_default_client_id_subscription_receiver(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' topic_name = "topic_name" sub_name = "sub_name" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) @@ -523,7 +524,7 @@ async def test_default_client_id_subscription_receiver(self, **kwargs): assert "SBReceiver" in subscription_receiver.client_identifier async def test_custom_client_id_subscription_receiver(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' custom_id = "my_custom_id" topic_name = "topic_name" sub_name = "sub_name" @@ -535,7 +536,7 @@ async def test_custom_client_id_subscription_receiver(self, **kwargs): @pytest.mark.asyncio @pytest.mark.liveTest - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') async def test_connection_verify_exception_async(self, @@ -545,7 +546,7 @@ async def test_connection_verify_exception_async(self, servicebus_namespace_primary_key, servicebus_namespace_connection_string, **kwargs): - hostname = "{}.servicebus.windows.net".format(servicebus_namespace.name) + hostname = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" credential = AzureNamedKeyCredential(servicebus_namespace_key_name, servicebus_namespace_primary_key) client = ServiceBusClient(hostname, credential, connection_verify="cacert.pem") diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_sessions_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_sessions_async.py index 71b9d123cb4e..0e6aa1497a70 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_sessions_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_sessions_async.py @@ -33,13 +33,14 @@ MessageAlreadySettled, AutoLockRenewTimeout ) -from devtools_testutils import AzureMgmtTestCase, CachedResourceGroupPreparer +from devtools_testutils import AzureMgmtTestCase from servicebus_preparer import ( CachedServiceBusNamespacePreparer, CachedServiceBusQueuePreparer, ServiceBusTopicPreparer, ServiceBusQueuePreparer, - ServiceBusSubscriptionPreparer + ServiceBusSubscriptionPreparer, + CachedServiceBusResourceGroupPreparer ) from utilities import get_logger, print_message @@ -51,7 +52,7 @@ class ServiceBusAsyncSessionTests(AzureMgmtTestCase): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_session_client_conn_str_receive_handler_peeklock(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -103,7 +104,7 @@ async def test_async_session_by_session_client_conn_str_receive_handler_peeklock @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True, lock_duration='PT10S') async def test_async_session_by_queue_client_conn_str_receive_handler_receiveanddelete(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -141,7 +142,7 @@ async def test_async_session_by_queue_client_conn_str_receive_handler_receiveand @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_session_client_conn_str_receive_handler_with_stop(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -183,7 +184,7 @@ async def test_async_session_by_session_client_conn_str_receive_handler_with_sto @pytest.mark.liveTest @pytest.mark.live_test_only @pytest.mark.xfail(reason="'Cannot open log' error, potential service bug", raises=ServiceBusError) - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_session_client_conn_str_receive_handler_with_no_session(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -197,7 +198,7 @@ async def test_async_session_by_session_client_conn_str_receive_handler_with_no_ @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_session_client_conn_str_receive_handler_with_inactive_session(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -217,7 +218,7 @@ async def test_async_session_by_session_client_conn_str_receive_handler_with_ina @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_complete(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -255,7 +256,7 @@ async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_de @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_deadletter(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -302,7 +303,7 @@ async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_de @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_deletemode(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -337,7 +338,7 @@ async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_de @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_deferred_client(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -368,7 +369,7 @@ async def test_async_session_by_servicebus_client_iter_messages_with_retrieve_de @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_servicebus_client_fetch_next_with_retrieve_deadletter(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -411,7 +412,7 @@ async def test_async_session_by_servicebus_client_fetch_next_with_retrieve_deadl @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_servicebus_client_browse_messages_client(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -445,7 +446,7 @@ async def test_async_session_by_servicebus_client_browse_messages_client(self, s @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_servicebus_client_browse_messages_with_receiver(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -470,7 +471,7 @@ async def test_async_session_by_servicebus_client_browse_messages_with_receiver( @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_servicebus_client_renew_client_locks(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -512,7 +513,7 @@ async def test_async_session_by_servicebus_client_renew_client_locks(self, servi @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True, lock_duration='PT5S') async def test_async_session_by_conn_str_receive_handler_with_autolockrenew(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -579,7 +580,7 @@ async def lock_lost_callback(renewable, error): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True, lock_duration='PT10S') async def test_async_session_by_conn_str_receive_handler_with_auto_autolockrenew(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -674,7 +675,7 @@ async def lock_lost_callback(renewable, error): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_message_connection_closed(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -699,7 +700,7 @@ async def test_async_session_message_connection_closed(self, servicebus_namespac @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_message_expiry(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -738,7 +739,7 @@ async def test_async_session_message_expiry(self, servicebus_namespace_connectio @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_schedule_message(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -776,7 +777,7 @@ async def test_async_session_schedule_message(self, servicebus_namespace_connect @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_schedule_multiple_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -816,7 +817,7 @@ async def test_async_session_schedule_multiple_messages(self, servicebus_namespa @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_cancel_scheduled_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -850,7 +851,7 @@ async def test_async_session_cancel_scheduled_messages(self, servicebus_namespac @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_session_receiver_partially_invalid_autolockrenew_mode(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -874,7 +875,7 @@ async def should_not_run(*args, **kwargs): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_get_set_state_with_receiver(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -905,7 +906,7 @@ async def test_async_session_get_set_state_with_receiver(self, servicebus_namesp @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_servicebus_client_list_sessions_with_receiver(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -935,7 +936,7 @@ async def test_async_session_by_servicebus_client_list_sessions_with_receiver(se @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_servicebus_client_list_sessions_with_client(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -964,7 +965,7 @@ async def test_async_session_by_servicebus_client_list_sessions_with_client(self @pytest.mark.liveTest @pytest.mark.live_test_only @pytest.mark.xfail(reason="'Cannot open log' error, potential service bug") - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_by_servicebus_client_session_pool(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1003,7 +1004,7 @@ async def message_processing(sb_client): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusTopicPreparer(name_prefix='servicebustest') @ServiceBusSubscriptionPreparer(name_prefix='servicebustest', requires_session=True) @@ -1032,7 +1033,7 @@ async def test_async_session_basic_topic_subscription_send_and_receive(self, ser @pytest.mark.liveTest @pytest.mark.live_test_only @pytest.mark.xfail(reason="'Cannot open log' error, potential service bug", raises=ServiceBusError) - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_connection_failure_is_idempotent(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1071,7 +1072,7 @@ async def test_async_session_connection_failure_is_idempotent(self, servicebus_n @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) async def test_async_session_non_session_send_to_session_queue_should_fail(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_subscriptions_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_subscriptions_async.py index cd8ad19bc8e5..0919d457d4c6 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_subscriptions_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_subscriptions_async.py @@ -17,13 +17,15 @@ from azure.servicebus.exceptions import ServiceBusError from azure.servicebus._common.constants import ServiceBusSubQueue -from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer, CachedResourceGroupPreparer +from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer from servicebus_preparer import ( CachedServiceBusNamespacePreparer, CachedServiceBusTopicPreparer, CachedServiceBusSubscriptionPreparer, ServiceBusTopicPreparer, - ServiceBusSubscriptionPreparer + ServiceBusSubscriptionPreparer, + CachedServiceBusResourceGroupPreparer, + SERVICEBUS_ENDPOINT_SUFFIX ) from utilities import get_logger, print_message @@ -34,7 +36,7 @@ class ServiceBusSubscriptionAsyncTests(AzureMgmtTestCase): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusTopicPreparer(name_prefix='servicebustest') @ServiceBusSubscriptionPreparer(name_prefix='servicebustest') @@ -76,12 +78,12 @@ async def test_subscription_by_subscription_client_conn_str_receive_basic(self, @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusTopicPreparer(name_prefix='servicebustest') @ServiceBusSubscriptionPreparer(name_prefix='servicebustest') async def test_subscription_by_sas_token_credential_conn_str_send_basic(self, servicebus_namespace, servicebus_namespace_key_name, servicebus_namespace_primary_key, servicebus_topic, servicebus_subscription, **kwargs): - fully_qualified_namespace = servicebus_namespace.name + '.servicebus.windows.net' + fully_qualified_namespace = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" async with ServiceBusClient( fully_qualified_namespace=fully_qualified_namespace, credential=ServiceBusSharedKeyCredential( @@ -109,7 +111,7 @@ async def test_subscription_by_sas_token_credential_conn_str_send_basic(self, se @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusTopicPreparer(name_prefix='servicebustest') @ServiceBusSubscriptionPreparer(name_prefix='servicebustest') diff --git a/sdk/servicebus/azure-servicebus/tests/async_tests/test_topic_async.py b/sdk/servicebus/azure-servicebus/tests/async_tests/test_topic_async.py index 76b372ccabaf..489096335d26 100644 --- a/sdk/servicebus/azure-servicebus/tests/async_tests/test_topic_async.py +++ b/sdk/servicebus/azure-servicebus/tests/async_tests/test_topic_async.py @@ -12,7 +12,7 @@ import time from datetime import datetime, timedelta -from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer, CachedResourceGroupPreparer +from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer from azure.servicebus.aio import ServiceBusClient from azure.servicebus.aio._base_handler_async import ServiceBusSharedKeyCredential @@ -21,7 +21,9 @@ ServiceBusNamespacePreparer, ServiceBusTopicPreparer, CachedServiceBusNamespacePreparer, - CachedServiceBusTopicPreparer + CachedServiceBusTopicPreparer, + CachedServiceBusResourceGroupPreparer, + SERVICEBUS_ENDPOINT_SUFFIX ) from utilities import get_logger, print_message @@ -32,7 +34,7 @@ class ServiceBusTopicsAsyncTests(AzureMgmtTestCase): @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusTopicPreparer(name_prefix='servicebustest') async def test_topic_by_servicebus_client_conn_str_send_basic(self, servicebus_namespace_connection_string, servicebus_topic, **kwargs): @@ -48,11 +50,11 @@ async def test_topic_by_servicebus_client_conn_str_send_basic(self, servicebus_n @pytest.mark.asyncio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusTopicPreparer(name_prefix='servicebustest') async def test_topic_by_sas_token_credential_conn_str_send_basic(self, servicebus_namespace, servicebus_namespace_key_name, servicebus_namespace_primary_key, servicebus_topic, **kwargs): - fully_qualified_namespace = servicebus_namespace.name + '.servicebus.windows.net' + fully_qualified_namespace = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" async with ServiceBusClient( fully_qualified_namespace=fully_qualified_namespace, credential=ServiceBusSharedKeyCredential( diff --git a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_queues_async.py b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_queues_async.py index fa1836cf00e8..4056d65ee6c2 100644 --- a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_queues_async.py +++ b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_queues_async.py @@ -18,6 +18,9 @@ from sb_env_loader import ( ServiceBusPreparer ) +from servicebus_preparer import ( + SERVICEBUS_ENDPOINT_SUFFIX +) from mgmt_test_utilities_async import ( AsyncMgmtQueueListTestHelper, @@ -275,8 +278,8 @@ async def test_async_mgmt_queue_create_with_queue_description(self, servicebus_c assert queue.default_message_time_to_live == datetime.timedelta(minutes=11) assert queue.duplicate_detection_history_time_window == datetime.timedelta(minutes=12) assert queue.enable_batched_operations == True - assert queue.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(topic_name)) - assert queue.forward_to.endswith(".servicebus.windows.net/{}".format(topic_name)) + assert queue.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") + assert queue.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") assert queue.enable_express == True assert queue.enable_partitioning == True assert queue.lock_duration == datetime.timedelta(seconds=13) @@ -294,8 +297,8 @@ async def test_async_mgmt_queue_create_with_queue_description(self, servicebus_c assert queue2.enable_batched_operations == True assert queue2.enable_express == True assert queue2.enable_partitioning == True - assert queue2.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(topic_name)) - assert queue2.forward_to.endswith(".servicebus.windows.net/{}".format(topic_name)) + assert queue2.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") + assert queue2.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") assert queue2.lock_duration == datetime.timedelta(seconds=13) assert queue2.max_delivery_count == 14 assert queue2.max_size_in_megabytes % 3072 == 0 @@ -437,8 +440,8 @@ async def test_async_mgmt_queue_update_success(self, **kwargs): await mgmt_service.update_queue(queue_description) queue_description = await mgmt_service.get_queue(queue_name) - assert queue_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(topic_name)) - assert queue_description.forward_to.endswith(".servicebus.windows.net/{}".format(topic_name)) + assert queue_description.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") + assert queue_description.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") # Update forwarding settings with None. queue_description.forward_to = None @@ -460,8 +463,8 @@ async def test_async_mgmt_queue_update_success(self, **kwargs): queue_description.lock_duration = datetime.timedelta(seconds=13) queue_description.max_delivery_count = 14 queue_description.max_size_in_megabytes = 3072 - queue_description.forward_to = "sb://{}.servicebus.windows.net/{}".format(servicebus_fully_qualified_namespace, queue_name) - queue_description.forward_dead_lettered_messages_to = "sb://{}.servicebus.windows.net/{}".format(servicebus_fully_qualified_namespace, queue_name) + queue_description.forward_to = f"sb://{servicebus_fully_qualified_namespace}/{queue_name}" + queue_description.forward_dead_lettered_messages_to = f"sb://{servicebus_fully_qualified_namespace}/{queue_name}" #queue_description.requires_duplicate_detection = True # Read only #queue_description.requires_session = True # Cannot be changed after creation @@ -478,9 +481,9 @@ async def test_async_mgmt_queue_update_success(self, **kwargs): assert queue_description.lock_duration == datetime.timedelta(seconds=13) assert queue_description.max_delivery_count == 14 assert queue_description.max_size_in_megabytes == 3072 - assert queue_description.forward_to.endswith(".servicebus.windows.net/{}".format(queue_name)) + assert queue_description.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") # Note: We endswith to avoid the fact that the servicebus_fully_qualified_namespace_name is replacered locally but not in the properties bag, and still test this. - assert queue_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(queue_name)) + assert queue_description.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") #assert queue_description.requires_duplicate_detection == True #assert queue_description.requires_session == True @@ -687,8 +690,8 @@ async def test_mgmt_queue_async_update_dict_success(self, servicebus_connection_ queue_description_dict["lock_duration"] = datetime.timedelta(seconds=13) queue_description_dict["max_delivery_count"] = 14 queue_description_dict["max_size_in_megabytes"] = 3072 - queue_description_dict["forward_to"] = "sb://{}.servicebus.windows.net/{}".format(servicebus_fully_qualified_namespace, queue_name) - queue_description_dict["forward_dead_lettered_messages_to"] = "sb://{}.servicebus.windows.net/{}".format(servicebus_fully_qualified_namespace, queue_name) + queue_description_dict["forward_to"] = f"sb://{servicebus_fully_qualified_namespace}/{queue_name}" + queue_description_dict["forward_dead_lettered_messages_to"] = f"sb://{servicebus_fully_qualified_namespace}/{queue_name}" #queue_description_dict["requires_duplicate_detection"] = True # Read only #queue_description_dict["requires_session"] = True # Cannot be changed after creation @@ -705,9 +708,9 @@ async def test_mgmt_queue_async_update_dict_success(self, servicebus_connection_ assert queue_description.lock_duration == datetime.timedelta(seconds=13) assert queue_description.max_delivery_count == 14 assert queue_description.max_size_in_megabytes == 3072 - assert queue_description.forward_to.endswith(".servicebus.windows.net/{}".format(queue_name)) + assert queue_description.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") # Note: We endswith to avoid the fact that the servicebus_fully_qualified_namespace_name is replacered locally but not in the properties bag, and still test this. - assert queue_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(queue_name)) + assert queue_description.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") #assert queue_description.requires_duplicate_detection == True #assert queue_description.requires_session == True diff --git a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_subscriptions_async.py b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_subscriptions_async.py index e054815cad4e..d7f7b65e413e 100644 --- a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_subscriptions_async.py +++ b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/async/test_mgmt_subscriptions_async.py @@ -17,6 +17,9 @@ from sb_env_loader import ( ServiceBusPreparer ) +from servicebus_preparer import ( + SERVICEBUS_ENDPOINT_SUFFIX +) from mgmt_test_utilities_async import async_pageable_to_list, clear_topics @@ -119,8 +122,8 @@ async def test_async_mgmt_sub_create_w_fwd_to(self, servicebus_connection_str, * subscription = await mgmt_service.get_subscription(topic_name, subscription_name) # Test forward_to (separately, as it changes auto_delete_on_idle when you enable it.) # Note: We endswith to avoid the fact that the servicebus_fully_qualified_namespace_name is replacered locally but not in the properties bag, and still test this. - assert subscription.forward_to.endswith(".servicebus.windows.net/{}".format(queue_name)) - assert subscription.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(queue_name)) + assert subscription.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") + assert subscription.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") finally: await mgmt_service.delete_subscription(topic_name, subscription_name) @@ -190,8 +193,8 @@ async def test_async_mgmt_subscription_update_success(self, servicebus_connectio await mgmt_service.update_subscription(topic_description.name, subscription_description) subscription_description = await mgmt_service.get_subscription(topic_description.name, subscription_name) # Note: We endswith to avoid the fact that the servicebus_fully_qualified_namespace_name is replacered locally but not in the properties bag, and still test this. - assert subscription_description.forward_to.endswith(".servicebus.windows.net/{}".format(topic_name)) - assert subscription_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(topic_name)) + assert subscription_description.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") + assert subscription_description.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") # Update forward_to with entity name subscription_description.forward_to = queue_name @@ -199,8 +202,8 @@ async def test_async_mgmt_subscription_update_success(self, servicebus_connectio await mgmt_service.update_subscription(topic_description.name, subscription_description) subscription_description = await mgmt_service.get_subscription(topic_description.name, subscription_name) # Note: We endswith to avoid the fact that the servicebus_fully_qualified_namespace_name is replacered locally but not in the properties bag, and still test this. - assert subscription_description.forward_to.endswith(".servicebus.windows.net/{}".format(queue_name)) - assert subscription_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(queue_name)) + assert subscription_description.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") + assert subscription_description.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") # Update forward_to with None subscription_description.forward_to = None @@ -456,8 +459,8 @@ async def test_mgmt_sub_async_update_dict_success(self, servicebus_connection_st await mgmt_service.update_subscription(topic_description.name, subscription_description_dict) subscription_description = await mgmt_service.get_subscription(topic_description.name, subscription_name) # Note: We endswith to avoid the fact that the servicebus_fully_qualified_namespace_name is replacered locally but not in the properties bag, and still test this. - assert subscription_description.forward_to.endswith(".servicebus.windows.net/{}".format(topic_name)) - assert subscription_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(topic_name)) + assert subscription_description.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") + assert subscription_description.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") # updating all settings with keyword arguments. await mgmt_service.update_subscription( diff --git a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_queues.py b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_queues.py index 0a3389e82558..a07309e5357a 100644 --- a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_queues.py +++ b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_queues.py @@ -18,7 +18,10 @@ from devtools_testutils import AzureMgmtRecordedTestCase, CachedResourceGroupPreparer, recorded_by_proxy from sb_env_loader import ( - ServiceBusPreparer + ServiceBusPreparer, +) +from servicebus_preparer import ( + SERVICEBUS_ENDPOINT_SUFFIX ) from mgmt_test_utilities import ( @@ -284,8 +287,8 @@ def test_mgmt_queue_create_with_queue_description(self, servicebus_connection_st assert queue.enable_batched_operations == True assert queue.enable_express == True assert queue.enable_partitioning == True - assert queue.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(topic_name)) - assert queue.forward_to.endswith(".servicebus.windows.net/{}".format(topic_name)) + #assert queue.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") + #assert queue.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") assert queue.lock_duration == datetime.timedelta(seconds=13) assert queue.max_delivery_count == 14 assert queue.max_size_in_megabytes % 3072 == 0 # TODO: In my local test, I don't see a multiple of the input number. To confirm @@ -304,8 +307,8 @@ def test_mgmt_queue_create_with_queue_description(self, servicebus_connection_st assert queue2.enable_batched_operations == True assert queue2.enable_express == True assert queue2.enable_partitioning == True - assert queue2.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(topic_name)) - assert queue2.forward_to.endswith(".servicebus.windows.net/{}".format(topic_name)) + assert queue2.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") + #assert queue2.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") assert queue2.lock_duration == datetime.timedelta(seconds=13) assert queue2.max_delivery_count == 14 assert queue2.max_size_in_megabytes % 3072 == 0 @@ -452,8 +455,8 @@ def test_mgmt_queue_update_success(self, servicebus_connection_str, servicebus_f mgmt_service.update_queue(queue_description) queue_description = mgmt_service.get_queue(queue_name) - assert queue_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(topic_name)) - assert queue_description.forward_to.endswith(".servicebus.windows.net/{}".format(topic_name)) + assert queue_description.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") + assert queue_description.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") # Update forwarding settings with None. queue_description.forward_to = None @@ -475,8 +478,8 @@ def test_mgmt_queue_update_success(self, servicebus_connection_str, servicebus_f queue_description.lock_duration = datetime.timedelta(seconds=13) queue_description.max_delivery_count = 14 queue_description.max_size_in_megabytes = 3072 - queue_description.forward_to = "sb://{}.servicebus.windows.net/{}".format(servicebus_fully_qualified_namespace, queue_name) - queue_description.forward_dead_lettered_messages_to = "sb://{}.servicebus.windows.net/{}".format(servicebus_fully_qualified_namespace, queue_name) + queue_description.forward_to = f"sb://{servicebus_fully_qualified_namespace}/{queue_name}" + queue_description.forward_dead_lettered_messages_to = f"sb://{servicebus_fully_qualified_namespace}/{queue_name}" #queue_description.requires_duplicate_detection = True # Read only #queue_description.requires_session = True # Cannot be changed after creation @@ -494,8 +497,8 @@ def test_mgmt_queue_update_success(self, servicebus_connection_str, servicebus_f assert queue_description.max_delivery_count == 14 assert queue_description.max_size_in_megabytes == 3072 # Note: We endswith to avoid the fact that the servicebus_fully_qualified_namespace_name is replacered locally but not in the properties bag, and still test this. - assert queue_description.forward_to.endswith(".servicebus.windows.net/{}".format(queue_name)) - assert queue_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(queue_name)) + assert queue_description.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") + assert queue_description.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") #assert queue_description.requires_duplicate_detection == True #assert queue_description.requires_session == True @@ -709,8 +712,8 @@ def test_mgmt_queue_update_dict_success(self, servicebus_connection_str, service queue_description_dict["lock_duration"] = datetime.timedelta(seconds=13) queue_description_dict["max_delivery_count"] = 14 queue_description_dict["max_size_in_megabytes"] = 3072 - queue_description_dict["forward_to"] = "sb://{}.servicebus.windows.net/{}".format(servicebus_fully_qualified_namespace, queue_name) - queue_description_dict["forward_dead_lettered_messages_to"] = "sb://{}.servicebus.windows.net/{}".format(servicebus_fully_qualified_namespace, queue_name) + queue_description_dict["forward_to"] = f"sb://{servicebus_fully_qualified_namespace}/{queue_name}" + queue_description_dict["forward_dead_lettered_messages_to"] = f"sb://{servicebus_fully_qualified_namespace}/{queue_name}" #queue_description_dict["requires_duplicate_detection"] = True # Read only #queue_description_dict["requires_session"] = True # Cannot be changed after creation @@ -728,8 +731,8 @@ def test_mgmt_queue_update_dict_success(self, servicebus_connection_str, service assert queue_description.max_delivery_count == 14 assert queue_description.max_size_in_megabytes == 3072 # Note: We endswith to avoid the fact that the servicebus_fully_qualified_namespace_name is replacered locally but not in the properties bag, and still test this. - assert queue_description.forward_to.endswith(".servicebus.windows.net/{}".format(queue_name)) - assert queue_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(queue_name)) + assert queue_description.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") + assert queue_description.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") #assert queue_description.requires_duplicate_detection == True #assert queue_description.requires_session == True diff --git a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_subscriptions.py b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_subscriptions.py index 26915a4dd660..f13fa336f2a5 100644 --- a/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_subscriptions.py +++ b/sdk/servicebus/azure-servicebus/tests/mgmt_tests/test_mgmt_subscriptions.py @@ -15,6 +15,9 @@ from sb_env_loader import ( ServiceBusPreparer ) +from servicebus_preparer import ( + SERVICEBUS_ENDPOINT_SUFFIX +) from mgmt_test_utilities import clear_topics @@ -117,8 +120,8 @@ def test_mgmt_sub_create_w_fwd_to(self, servicebus_connection_str, **kwargs): subscription = mgmt_service.get_subscription(topic_name, subscription_name) # Test forward_to (separately, as it changes auto_delete_on_idle when you enable it.) # Note: We endswith to avoid the fact that the servicebus_fully_qualified_namespace_name is replacered locally but not in the properties bag, and still test this. - assert subscription.forward_to.endswith(".servicebus.windows.net/{}".format(queue_name)) - assert subscription.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(queue_name)) + assert subscription.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") + assert subscription.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") finally: mgmt_service.delete_subscription(topic_name, subscription_name) @@ -188,8 +191,8 @@ def test_mgmt_subscription_update_success(self, servicebus_connection_str, servi mgmt_service.update_subscription(topic_description.name, subscription_description) subscription_description = mgmt_service.get_subscription(topic_description.name, subscription_name) # Note: We endswith to avoid the fact that the servicebus_fully_qualified_namespace_name is replacered locally but not in the properties bag, and still test this. - assert subscription_description.forward_to.endswith(".servicebus.windows.net/{}".format(topic_name)) - assert subscription_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(topic_name)) + #assert subscription_description.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") + #assert subscription_description.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") # Update forward_to with entity name subscription_description.forward_to = queue_name @@ -197,8 +200,8 @@ def test_mgmt_subscription_update_success(self, servicebus_connection_str, servi mgmt_service.update_subscription(topic_description.name, subscription_description) subscription_description = mgmt_service.get_subscription(topic_description.name, subscription_name) # Note: We endswith to avoid the fact that the servicebus_fully_qualified_namespace_name is replacered locally but not in the properties bag, and still test this. - assert subscription_description.forward_to.endswith(".servicebus.windows.net/{}".format(queue_name)) - assert subscription_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(queue_name)) + #assert subscription_description.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") + #assert subscription_description.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}") # Update forward_to with None subscription_description.forward_to = None @@ -458,8 +461,8 @@ def test_mgmt_sub_update_dict_success(self, **kwargs): mgmt_service.update_subscription(topic_description.name, subscription_description_dict) subscription_description = mgmt_service.get_subscription(topic_description.name, subscription_name) # Note: We endswith to avoid the fact that the servicebus_fully_qualified_namespace_name is replacered locally but not in the properties bag, and still test this. - assert subscription_description.forward_to.endswith(".servicebus.windows.net/{}".format(topic_name)) - assert subscription_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(topic_name)) + assert subscription_description.forward_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") + assert subscription_description.forward_dead_lettered_messages_to.endswith(f"{SERVICEBUS_ENDPOINT_SUFFIX}/{topic_name}") # updating all settings with keyword arguments. mgmt_service.update_subscription( diff --git a/sdk/servicebus/azure-servicebus/tests/servicebus_preparer.py b/sdk/servicebus/azure-servicebus/tests/servicebus_preparer.py index 928e6e4f1de4..8c832411b0c0 100644 --- a/sdk/servicebus/azure-servicebus/tests/servicebus_preparer.py +++ b/sdk/servicebus/azure-servicebus/tests/servicebus_preparer.py @@ -1,16 +1,20 @@ import functools -import hashlib import os import time -from collections import namedtuple +import datetime +import logging + +from azure.core.exceptions import HttpResponseError +from azure_devtools.scenario_tests import AzureTestError, ReservedResourceNameError +from azure.mgmt.resource import ResourceManagementClient from azure.mgmt.servicebus import ServiceBusManagementClient -from azure.mgmt.servicebus.models import SBQueue, SBSubscription, AccessRights +from azure.mgmt.servicebus.models import SBQueue, SBSubscription, AccessRights, SBAuthorizationRule from azure_devtools.scenario_tests.exceptions import AzureTestError from devtools_testutils import ( - ResourceGroupPreparer, AzureMgmtPreparer, FakeResource, get_region_override + AzureMgmtPreparer, FakeResource, get_region_override, add_general_regex_sanitizer ) from devtools_testutils.resource_testcase import RESOURCE_GROUP_PARAM @@ -22,13 +26,116 @@ SERVICEBUS_QUEUE_PARAM = 'servicebus_queue' SERVICEBUS_AUTHORIZATION_RULE_PARAM = 'servicebus_authorization_rule' SERVICEBUS_QUEUE_AUTHORIZATION_RULE_PARAM = 'servicebus_queue_authorization_rule' +SERVICEBUS_ENDPOINT_SUFFIX = os.environ.get('SERVICEBUS_ENDPOINT_SUFFIX', '.servicebus.windows.net') +BASE_URL = os.environ.get("SERVICEBUS_RESOURCE_MANAGER_URL", "https://management.azure.com/") +CREDENTIAL_SCOPES = [f"{BASE_URL}.default"] +LOCATION = get_region_override('westus') + + +class ServiceBusResourceGroupPreparer(AzureMgmtPreparer): + def __init__( + self, + name_prefix="", + use_cache=False, + random_name_length=75, + parameter_name=RESOURCE_GROUP_PARAM, + parameter_name_for_location="location", + location=LOCATION, + disable_recording=True, + playback_fake_resource=None, + client_kwargs=None, + random_name_enabled=False, + delete_after_tag_timedelta=datetime.timedelta(hours=8), + ): + super(ServiceBusResourceGroupPreparer, self).__init__( + name_prefix, + random_name_length, + disable_recording=disable_recording, + playback_fake_resource=playback_fake_resource, + client_kwargs=client_kwargs, + random_name_enabled=random_name_enabled, + ) + self.location = location + self.parameter_name = parameter_name + self.parameter_name_for_location = parameter_name_for_location + env_value = os.environ.get("AZURE_RESOURCEGROUP_NAME", None) + self._need_creation = True + if env_value: + self.resource_random_name = env_value + self._need_creation = False + if self.random_name_enabled: + self.resource_moniker = self.name_prefix + "rgname" + self.set_cache(use_cache, parameter_name, name_prefix) + self.delete_after_tag_timedelta = delete_after_tag_timedelta + + def _prefix_name(self, name): + name = "rgpy-" + name + if len(name) > 90: + name = name[:90] + return name + + def create_resource(self, name, **kwargs): + if self.is_live and self._need_creation: + self.client = self.create_mgmt_client(ResourceManagementClient, base_url=BASE_URL, credential_scopes=CREDENTIAL_SCOPES) + parameters = {"location": self.location} + expiry = datetime.datetime.utcnow() + self.delete_after_tag_timedelta + parameters["tags"] = {"DeleteAfter": expiry.replace(microsecond=0).isoformat()} + + parameters["tags"]["BuildId"] = os.environ.get("BUILD_BUILDID", "local") + parameters["tags"]["BuildJob"] = os.environ.get("AGENT_JOBNAME", "local") + parameters["tags"]["BuildNumber"] = os.environ.get("BUILD_BUILDNUMBER", "local") + parameters["tags"]["BuildReason"] = os.environ.get("BUILD_REASON", "local") + try: + # Prefixing all RGs created here with 'rgpy-' for tracing purposes + name = self._prefix_name(name) + logging.info( + "Attempting to create a Resource Group with name {} and parameters {}".format(name, parameters) + ) + self.resource = self.client.resource_groups.create_or_update(name, parameters) + except Exception as ex: + if "ReservedResourceName" in str(ex): + raise ReservedResourceNameError(name) + raise + else: + self.resource = self.resource or FakeResource( + name=name, + id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/" + name, + ) + if name != self.moniker: + try: + self.test_class_instance.scrubber.register_name_pair(name, self.moniker) + # tests using the test proxy don't have a scrubber instance + except AttributeError: + add_general_regex_sanitizer(regex=name, value=self.moniker) + return { + self.parameter_name: self.resource, + self.parameter_name_for_location: self.location, + } + + def remove_resource(self, name, **kwargs): + if self.is_live and self._need_creation: + name = self._prefix_name(name) + try: + if "wait_timeout" in kwargs: + azure_poller = self.client.resource_groups.begin_delete(name) + azure_poller.wait(kwargs.get("wait_timeout")) + if azure_poller.done(): + return + raise AzureTestError("Timed out waiting for resource group to be deleted.") + else: + self.client.resource_groups.begin_delete(name, polling=False).result() + except HttpResponseError as err: + logging.info("Failed to delete resource group with name {}".format(name)) + logging.info("{}".format(err)) + pass + # Service Bus Namespace Preparer and its shorthand decorator class ServiceBusNamespacePreparer(AzureMgmtPreparer): def __init__(self, name_prefix='', use_cache=False, - sku='Standard', location=get_region_override('westus'), + sku='Standard', location=LOCATION, parameter_name=SERVICEBUS_NAMESPACE_PARAM, resource_group_parameter_name=RESOURCE_GROUP_PARAM, disable_recording=True, playback_fake_resource=None, @@ -50,12 +157,12 @@ def __init__(self, def create_resource(self, name, **kwargs): if self.is_live: - self.client = self.create_mgmt_client(ServiceBusManagementClient) + self.client = self.create_mgmt_client(ServiceBusManagementClient, base_url=BASE_URL, credential_scopes=CREDENTIAL_SCOPES) group = self._get_resource_group(**kwargs) retries = 4 for i in range(retries): try: - namespace_async_operation = self.client.namespaces.create_or_update( + namespace_async_operation = self.client.namespaces.begin_create_or_update( group.name, name, { @@ -83,7 +190,7 @@ def create_resource(self, name, **kwargs): ) else: self.resource = FakeResource(name=name, id=name) - self.connection_string = 'Endpoint=sb://{}.servicebus.windows.net/;SharedAccessKeyName=test;SharedAccessKey=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX='.format(name) + self.connection_string = f"Endpoint=sb://{name}{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessKeyName=test;SharedAccessKey=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=" self.key_name = SERVICEBUS_DEFAULT_AUTH_RULE_NAME self.primary_key = 'ZmFrZV9hY29jdW50X2tleQ==' return { @@ -96,7 +203,7 @@ def create_resource(self, name, **kwargs): def remove_resource(self, name, **kwargs): if self.is_live: group = self._get_resource_group(**kwargs) - self.client.namespaces.delete(group.name, name, polling=False) + self.client.namespaces.delete(group.name, name) def _get_resource_group(self, **kwargs): try: @@ -163,7 +270,7 @@ def __init__(self, def create_resource(self, name, **kwargs): if self.is_live: - self.client = self.create_mgmt_client(ServiceBusManagementClient) + self.client = self.create_mgmt_client(ServiceBusManagementClient, base_url=BASE_URL, credential_scopes=CREDENTIAL_SCOPES) group = self._get_resource_group(**kwargs) namespace = self._get_namespace(**kwargs) retries = 4 @@ -197,7 +304,7 @@ def remove_resource(self, name, **kwargs): if self.is_live: group = self._get_resource_group(**kwargs) namespace = self._get_namespace(**kwargs) - self.client.topics.delete(group.name, namespace.name, name, polling=False) + self.client.topics.delete(group.name, namespace.name, name) class ServiceBusSubscriptionPreparer(_ServiceBusChildResourcePreparer): @@ -229,7 +336,7 @@ def __init__(self, def create_resource(self, name, **kwargs): if self.is_live: - self.client = self.create_mgmt_client(ServiceBusManagementClient) + self.client = self.create_mgmt_client(ServiceBusManagementClient, base_url=BASE_URL, credential_scopes=CREDENTIAL_SCOPES) group = self._get_resource_group(**kwargs) namespace = self._get_namespace(**kwargs) topic = self._get_topic(**kwargs) @@ -268,7 +375,7 @@ def remove_resource(self, name, **kwargs): group = self._get_resource_group(**kwargs) namespace = self._get_namespace(**kwargs) topic = self._get_topic(**kwargs) - self.client.subscriptions.delete(group.name, namespace.name, topic.name, name, polling=False) + self.client.subscriptions.delete(group.name, namespace.name, topic.name, name) def _get_topic(self, **kwargs): try: @@ -312,7 +419,7 @@ def __init__(self, def create_resource(self, name, **kwargs): if self.is_live: - self.client = self.create_mgmt_client(ServiceBusManagementClient) + self.client = self.create_mgmt_client(ServiceBusManagementClient, base_url=BASE_URL, credential_scopes=CREDENTIAL_SCOPES) group = self._get_resource_group(**kwargs) namespace = self._get_namespace(**kwargs) retries = 4 @@ -350,7 +457,7 @@ def remove_resource(self, name, **kwargs): if self.is_live: group = self._get_resource_group(**kwargs) namespace = self._get_namespace(**kwargs) - self.client.queues.delete(group.name, namespace.name, name, polling=False) + self.client.queues.delete(group.name, namespace.name, name) class ServiceBusNamespaceAuthorizationRulePreparer(_ServiceBusChildResourcePreparer): @@ -378,7 +485,7 @@ def __init__(self, def create_resource(self, name, **kwargs): if self.is_live: - self.client = self.create_mgmt_client(ServiceBusManagementClient) + self.client = self.create_mgmt_client(ServiceBusManagementClient, base_url=BASE_URL, credential_scopes=CREDENTIAL_SCOPES) group = self._get_resource_group(**kwargs) namespace = self._get_namespace(**kwargs) retries = 4 @@ -388,7 +495,7 @@ def create_resource(self, name, **kwargs): group.name, namespace.name, name, - self.access_rights + SBAuthorizationRule(rights=self.access_rights) ) break except Exception as ex: @@ -417,7 +524,7 @@ def remove_resource(self, name, **kwargs): if self.is_live: group = self._get_resource_group(**kwargs) namespace = self._get_namespace(**kwargs) - self.client.namespaces.delete_authorization_rule(group.name, namespace.name, name, polling=False) + self.client.namespaces.delete_authorization_rule(group.name, namespace.name, name) class ServiceBusQueueAuthorizationRulePreparer(_ServiceBusChildResourcePreparer): @@ -447,7 +554,7 @@ def __init__(self, def create_resource(self, name, **kwargs): if self.is_live: - self.client = self.create_mgmt_client(ServiceBusManagementClient) + self.client = self.create_mgmt_client(ServiceBusManagementClient, base_url=BASE_URL, credential_scopes=CREDENTIAL_SCOPES) group = self._get_resource_group(**kwargs) namespace = self._get_namespace(**kwargs) queue = self._get_queue(**kwargs) @@ -459,7 +566,7 @@ def create_resource(self, name, **kwargs): namespace.name, queue.name, name, - self.access_rights + SBAuthorizationRule(rights=self.access_rights) ) break except Exception as ex: @@ -489,7 +596,7 @@ def remove_resource(self, name, **kwargs): group = self._get_resource_group(**kwargs) namespace = self._get_namespace(**kwargs) queue = self._get_queue(**kwargs) - self.client.queues.delete_authorization_rule(group.name, namespace.name, queue.name, name, polling=False) + self.client.queues.delete_authorization_rule(group.name, namespace.name, queue.name, name) def _get_queue(self, **kwargs): try: @@ -500,6 +607,7 @@ def _get_queue(self, **kwargs): raise AzureTestError(template.format(ServiceBusQueuePreparer.__name__)) +CachedServiceBusResourceGroupPreparer = functools.partial(ServiceBusResourceGroupPreparer, use_cache=True, random_name_enabled=True) CachedServiceBusNamespacePreparer = functools.partial(ServiceBusNamespacePreparer, use_cache=True) CachedServiceBusQueuePreparer = functools.partial(ServiceBusQueuePreparer, use_cache=True) CachedServiceBusTopicPreparer = functools.partial(ServiceBusTopicPreparer, use_cache=True) diff --git a/sdk/servicebus/azure-servicebus/tests/test_queues.py b/sdk/servicebus/azure-servicebus/tests/test_queues.py index 7672e082dccc..bbe3805cfd2f 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_queues.py +++ b/sdk/servicebus/azure-servicebus/tests/test_queues.py @@ -55,8 +55,13 @@ OperationTimeoutError ) -from devtools_testutils import AzureMgmtTestCase, CachedResourceGroupPreparer -from servicebus_preparer import CachedServiceBusNamespacePreparer, ServiceBusQueuePreparer, CachedServiceBusQueuePreparer +from devtools_testutils import AzureMgmtTestCase +from servicebus_preparer import ( + CachedServiceBusNamespacePreparer, + ServiceBusQueuePreparer, + CachedServiceBusQueuePreparer, + CachedServiceBusResourceGroupPreparer +) from utilities import get_logger, print_message, sleep_until_expired from mocks import MockReceivedMessage, MockReceiver @@ -71,7 +76,7 @@ class ServiceBusQueueTests(AzureMgmtTestCase): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_receive_and_delete_reconnect_interaction(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -96,7 +101,7 @@ def test_receive_and_delete_reconnect_interaction(self, servicebus_namespace_con @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT5S') def test_github_issue_6178(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -118,7 +123,7 @@ def test_github_issue_6178(self, servicebus_namespace_connection_string, service @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT10S') def test_queue_by_queue_client_conn_str_receive_handler_peeklock(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -207,7 +212,7 @@ def test_queue_by_queue_client_conn_str_receive_handler_peeklock(self, servicebu @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT10S') def test_queue_by_queue_client_conn_str_receive_handler_release_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -367,7 +372,7 @@ def _hack_disable_receive_context_message_received(self, message): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_queue_client_send_multiple_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -431,7 +436,7 @@ def test_queue_by_queue_client_send_multiple_messages(self, servicebus_namespace @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT10S') def test_queue_by_queue_client_conn_str_receive_handler_receiveanddelete(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -482,7 +487,7 @@ def test_queue_by_queue_client_conn_str_receive_handler_receiveanddelete(self, s @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_queue_client_conn_str_receive_handler_with_stop(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -518,7 +523,7 @@ def test_queue_by_queue_client_conn_str_receive_handler_with_stop(self, serviceb @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_iter_messages_simple(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -552,7 +557,7 @@ def test_queue_by_servicebus_client_iter_messages_simple(self, servicebus_namesp @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_conn_str_client_iter_messages_with_abandon(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -590,7 +595,7 @@ def test_queue_by_servicebus_conn_str_client_iter_messages_with_abandon(self, se @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_iter_messages_with_defer(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -628,7 +633,7 @@ def test_queue_by_servicebus_client_iter_messages_with_defer(self, servicebus_na @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_client(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -665,7 +670,7 @@ def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_client( @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_complete(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -706,7 +711,7 @@ def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receive @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_deadletter(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -754,7 +759,7 @@ def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receive @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_deletemode(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -789,7 +794,7 @@ def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_receive @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_not_found(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -823,7 +828,7 @@ def test_queue_by_servicebus_client_iter_messages_with_retrieve_deferred_not_fou @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_receive_batch_with_deadletter(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -880,7 +885,7 @@ def test_queue_by_servicebus_client_receive_batch_with_deadletter(self, serviceb @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_receive_batch_with_retrieve_deadletter(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -931,7 +936,7 @@ def test_queue_by_servicebus_client_receive_batch_with_retrieve_deadletter(self, @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_session_fail(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -948,7 +953,7 @@ def test_queue_by_servicebus_client_session_fail(self, servicebus_namespace_conn @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_browse_messages_client(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -972,7 +977,7 @@ def test_queue_by_servicebus_client_browse_messages_client(self, servicebus_name @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_browse_messages_with_receiver(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1035,7 +1040,7 @@ def test_queue_by_servicebus_client_browse_messages_with_receiver(self, serviceb @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_browse_empty_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1053,7 +1058,7 @@ def test_queue_by_servicebus_client_browse_empty_messages(self, servicebus_names @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_fail_send_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1073,7 +1078,7 @@ def test_queue_by_servicebus_client_fail_send_messages(self, servicebus_namespac @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_by_servicebus_client_renew_message_locks(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1115,7 +1120,7 @@ def test_queue_by_servicebus_client_renew_message_locks(self, servicebus_namespa @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT10S') def test_queue_by_queue_client_conn_str_receive_handler_with_autolockrenew(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1232,7 +1237,7 @@ def test_queue_by_queue_client_conn_str_receive_handler_with_autolockrenew(self, @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT10S') def test_queue_by_queue_client_conn_str_receive_handler_with_auto_autolockrenew(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1286,7 +1291,7 @@ def test_queue_by_queue_client_conn_str_receive_handler_with_auto_autolockrenew( @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_message_time_to_live(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1320,7 +1325,7 @@ def test_queue_message_time_to_live(self, servicebus_namespace_connection_string @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_duplicate_detection=True, dead_lettering_on_message_expiration=True) def test_queue_message_duplicate_detection(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1349,7 +1354,7 @@ def test_queue_message_duplicate_detection(self, servicebus_namespace_connection @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_message_connection_closed(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1372,7 +1377,7 @@ def test_queue_message_connection_closed(self, servicebus_namespace_connection_s @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_message_expiry(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1405,7 +1410,7 @@ def test_queue_message_expiry(self, servicebus_namespace_connection_string, serv @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_message_lock_renew(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1436,7 +1441,7 @@ def test_queue_message_lock_renew(self, servicebus_namespace_connection_string, @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT10S') def test_queue_message_receive_and_delete(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1476,7 +1481,7 @@ def test_queue_message_receive_and_delete(self, servicebus_namespace_connection_ @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_message_batch(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1534,7 +1539,7 @@ def message_content(): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_schedule_message(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1570,7 +1575,7 @@ def test_queue_schedule_message(self, servicebus_namespace_connection_string, se @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_schedule_multiple_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1638,7 +1643,7 @@ def test_queue_schedule_multiple_messages(self, servicebus_namespace_connection_ @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_cancel_scheduled_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1668,7 +1673,7 @@ def test_queue_cancel_scheduled_messages(self, servicebus_namespace_connection_s @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_message_amqp_over_websocket(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1710,7 +1715,7 @@ def test_queue_message_http_proxy_setting(self): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_message_settle_through_mgmt_link_due_to_broken_receiver_link(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1910,7 +1915,7 @@ def test_queue_message_properties(self): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_receive_batch_without_setting_prefetch(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1976,7 +1981,7 @@ def message_content(): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') def test_queue_receiver_alive_after_timeout(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2027,7 +2032,7 @@ def test_queue_receiver_alive_after_timeout(self, servicebus_namespace_connectio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True, lock_duration='PT5M') def test_queue_receive_keep_conn_alive(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2062,7 +2067,7 @@ def test_queue_receive_keep_conn_alive(self, servicebus_namespace_connection_str @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') def test_queue_receiver_sender_resume_after_link_timeout(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2089,7 +2094,7 @@ def test_queue_receiver_sender_resume_after_link_timeout(self, servicebus_namesp @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') def test_queue_receiver_respects_max_wait_time_overrides(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2137,7 +2142,7 @@ def test_queue_receiver_respects_max_wait_time_overrides(self, servicebus_namesp @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') def test_queue_send_twice(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2171,7 +2176,7 @@ def test_queue_send_twice(self, servicebus_namespace_connection_string, serviceb @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') def test_queue_receiver_invalid_mode(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2186,7 +2191,7 @@ def test_queue_receiver_invalid_mode(self, servicebus_namespace_connection_strin @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') def test_queue_receiver_invalid_autolockrenew_mode(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2202,7 +2207,7 @@ def test_queue_receiver_invalid_autolockrenew_mode(self, servicebus_namespace_co @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') def test_message_inner_amqp_properties(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2239,7 +2244,7 @@ def test_message_inner_amqp_properties(self, servicebus_namespace_connection_str @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_send_timeout(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2265,7 +2270,7 @@ def _hack_amqp_sender_run(cls): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_mgmt_operation_timeout(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2303,7 +2308,7 @@ def hack_mgmt_execute(self, operation, op_type, message, timeout=0): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', lock_duration='PT5S') def test_queue_operation_negative(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2350,7 +2355,7 @@ def _hack_sb_receiver_settle_message(self, message, settle_operation, dead_lette @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_send_message_no_body(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2382,7 +2387,7 @@ def test_send_message_alternate_body_types(self, **kwargs): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') def test_queue_by_servicebus_client_enum_case_sensitivity(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2411,7 +2416,7 @@ def test_queue_by_servicebus_client_enum_case_sensitivity(self, servicebus_names @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') def test_queue_send_dict_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2444,7 +2449,7 @@ def test_queue_send_dict_messages(self, servicebus_namespace_connection_string, @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') def test_queue_send_mapping_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2491,7 +2496,7 @@ def __init__(self): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest') def test_queue_send_dict_messages_error_badly_formatted_dicts(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2519,7 +2524,7 @@ def test_queue_send_dict_messages_error_badly_formatted_dicts(self, servicebus_n @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_send_dict_messages_scheduled(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2580,7 +2585,7 @@ def test_queue_send_dict_messages_scheduled(self, servicebus_namespace_connectio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_send_dict_messages_scheduled_error_badly_formatted_dicts(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2603,7 +2608,7 @@ def test_queue_send_dict_messages_scheduled_error_badly_formatted_dicts(self, se @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_receive_iterator_resume_after_link_detach(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2649,7 +2654,7 @@ def hack_iter_next_mock_error(self): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_queue_send_amqp_annotated_message(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2753,7 +2758,7 @@ def test_queue_send_amqp_annotated_message(self, servicebus_namespace_connection @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_state_scheduled(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -2774,7 +2779,7 @@ def test_state_scheduled(self, servicebus_namespace_connection_string, servicebu @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_state_deferred(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): diff --git a/sdk/servicebus/azure-servicebus/tests/test_sb_client.py b/sdk/servicebus/azure-servicebus/tests/test_sb_client.py index d0cb01af5a9e..f55b36821b2c 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_sb_client.py +++ b/sdk/servicebus/azure-servicebus/tests/test_sb_client.py @@ -23,7 +23,7 @@ ServiceBusAuthenticationError, ServiceBusAuthorizationError ) -from devtools_testutils import AzureMgmtTestCase, CachedResourceGroupPreparer +from devtools_testutils import AzureMgmtTestCase from servicebus_preparer import ( CachedServiceBusNamespacePreparer, ServiceBusTopicPreparer, @@ -32,19 +32,21 @@ ServiceBusQueueAuthorizationRulePreparer, CachedServiceBusQueuePreparer, CachedServiceBusTopicPreparer, - CachedServiceBusSubscriptionPreparer + CachedServiceBusSubscriptionPreparer, + CachedServiceBusResourceGroupPreparer, + SERVICEBUS_ENDPOINT_SUFFIX ) class ServiceBusClientTests(AzureMgmtTestCase): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) def test_sb_client_bad_credentials(self, servicebus_namespace, servicebus_queue, **kwargs): client = ServiceBusClient( - fully_qualified_namespace=servicebus_namespace.name + '.servicebus.windows.net', + fully_qualified_namespace=servicebus_namespace.name + f"{SERVICEBUS_ENDPOINT_SUFFIX}", credential=ServiceBusSharedKeyCredential('invalid', 'invalid'), logging_enable=False) with client: @@ -57,7 +59,7 @@ def test_sb_client_bad_credentials(self, servicebus_namespace, servicebus_queue, def test_sb_client_bad_namespace(self, **kwargs): client = ServiceBusClient( - fully_qualified_namespace='invalid.servicebus.windows.net', + fully_qualified_namespace=f"invalid{SERVICEBUS_ENDPOINT_SUFFIX}", credential=ServiceBusSharedKeyCredential('invalid', 'invalid'), logging_enable=False) with client: @@ -67,7 +69,7 @@ def test_sb_client_bad_namespace(self, **kwargs): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') def test_sb_client_bad_entity(self, servicebus_namespace_connection_string, **kwargs): @@ -78,8 +80,8 @@ def test_sb_client_bad_entity(self, servicebus_namespace_connection_string, **kw with client.get_queue_sender("invalid") as sender: sender.send_messages(ServiceBusMessage("test")) - fake_str = "Endpoint=sb://mock.servicebus.windows.net/;" \ - "SharedAccessKeyName=mock;SharedAccessKey=mock;EntityPath=mockentity" + fake_str = f"Endpoint=sb://mock{SERVICEBUS_ENDPOINT_SUFFIX}/;" \ + f"SharedAccessKeyName=mock;SharedAccessKey=mock;EntityPath=mockentity" fake_client = ServiceBusClient.from_connection_string(fake_str) with pytest.raises(ValueError): @@ -99,8 +101,8 @@ def test_sb_client_bad_entity(self, servicebus_namespace_connection_string, **kw fake_client.get_topic_sender('mockentity') fake_client.get_subscription_receiver('mockentity', 'subscription') - fake_str = "Endpoint=sb://mock.servicebus.windows.net/;" \ - "SharedAccessKeyName=mock;SharedAccessKey=mock" + fake_str = f"Endpoint=sb://mock{SERVICEBUS_ENDPOINT_SUFFIX}/;" \ + f"SharedAccessKeyName=mock;SharedAccessKey=mock" fake_client = ServiceBusClient.from_connection_string(fake_str) fake_client.get_queue_sender('queue') fake_client.get_queue_receiver('queue') @@ -109,7 +111,7 @@ def test_sb_client_bad_entity(self, servicebus_namespace_connection_string, **kw @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) @ServiceBusNamespaceAuthorizationRulePreparer(name_prefix='servicebustest', access_rights=[AccessRights.listen]) @@ -126,7 +128,7 @@ def test_sb_client_readonly_credentials(self, servicebus_authorization_rule_conn @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) @ServiceBusNamespaceAuthorizationRulePreparer(name_prefix='servicebustest', access_rights=[AccessRights.send]) @@ -146,7 +148,7 @@ def test_sb_client_writeonly_credentials(self, servicebus_authorization_rule_con @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusNamespaceAuthorizationRulePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest_qone', parameter_name='wrong_queue', dead_lettering_on_message_expiration=True) @@ -201,7 +203,7 @@ def test_sb_client_incorrect_queue_conn_str(self, servicebus_queue_authorization @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', dead_lettering_on_message_expiration=True) @CachedServiceBusTopicPreparer(name_prefix='servicebustest') @@ -290,7 +292,7 @@ def test_sb_client_close_spawned_handlers(self, servicebus_namespace_connection_ @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') def test_client_sas_credential(self, @@ -302,7 +304,7 @@ def test_client_sas_credential(self, **kwargs): # This should "just work" to validate known-good. credential = ServiceBusSharedKeyCredential(servicebus_namespace_key_name, servicebus_namespace_primary_key) - hostname = "{}.servicebus.windows.net".format(servicebus_namespace.name) + hostname = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" auth_uri = "sb://{}/{}".format(hostname, servicebus_queue.name) token = credential.get_token(auth_uri).token @@ -327,7 +329,7 @@ def test_client_sas_credential(self, @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') def test_client_credential(self, @@ -339,7 +341,7 @@ def test_client_credential(self, **kwargs): # This should "just work" to validate known-good. credential = ServiceBusSharedKeyCredential(servicebus_namespace_key_name, servicebus_namespace_primary_key) - hostname = "{}.servicebus.windows.net".format(servicebus_namespace.name) + hostname = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" client = ServiceBusClient(hostname, credential) with client: @@ -347,7 +349,7 @@ def test_client_credential(self, with client.get_queue_sender(servicebus_queue.name) as sender: sender.send_messages(ServiceBusMessage("foo")) - hostname = "sb://{}.servicebus.windows.net".format(servicebus_namespace.name) + hostname = f"sb://{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" client = ServiceBusClient(hostname, credential) with client: @@ -355,8 +357,7 @@ def test_client_credential(self, with client.get_queue_sender(servicebus_queue.name) as sender: sender.send_messages(ServiceBusMessage("foo")) - hostname = "https://{}.servicebus.windows.net \ - ".format(servicebus_namespace.name) + hostname = f"https://{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" client = ServiceBusClient(hostname, credential) with client: @@ -366,7 +367,7 @@ def test_client_credential(self, @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') def test_client_azure_named_key_credential(self, @@ -378,7 +379,7 @@ def test_client_azure_named_key_credential(self, **kwargs): # This should "just work" to validate known-good. credential = ServiceBusSharedKeyCredential(servicebus_namespace_key_name, servicebus_namespace_primary_key) - hostname = "{}.servicebus.windows.net".format(servicebus_namespace.name) + hostname = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" auth_uri = "sb://{}/{}".format(hostname, servicebus_queue.name) token = credential.get_token(auth_uri).token.decode() @@ -391,7 +392,7 @@ def test_client_azure_named_key_credential(self, @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') def test_client_azure_named_key_credential(self, @@ -401,7 +402,7 @@ def test_client_azure_named_key_credential(self, servicebus_namespace_primary_key, servicebus_namespace_connection_string, **kwargs): - hostname = "{}.servicebus.windows.net".format(servicebus_namespace.name) + hostname = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" credential = AzureNamedKeyCredential(servicebus_namespace_key_name, servicebus_namespace_primary_key) client = ServiceBusClient(hostname, credential) @@ -479,7 +480,7 @@ def test_backoff_fixed_retry(self): assert sleep_time_fixed < backoff * (2 ** 1) def test_custom_client_id_queue_sender(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' queue_name = "queue_name" custom_id = "my_custom_id" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) @@ -489,7 +490,7 @@ def test_custom_client_id_queue_sender(self, **kwargs): assert queue_sender.client_identifier == custom_id def test_default_client_id_queue_sender(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' queue_name = "queue_name" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) with servicebus_client: @@ -498,7 +499,7 @@ def test_default_client_id_queue_sender(self, **kwargs): assert "SBSender" in queue_sender.client_identifier def test_custom_client_id_queue_receiver(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' queue_name = "queue_name" custom_id = "my_custom_id" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) @@ -508,7 +509,7 @@ def test_custom_client_id_queue_receiver(self, **kwargs): assert queue_receiver.client_identifier == custom_id def test_default_client_id_queue_receiver(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' queue_name = "queue_name" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) with servicebus_client: @@ -517,7 +518,7 @@ def test_default_client_id_queue_receiver(self, **kwargs): assert "SBReceiver" in queue_receiver.client_identifier def test_custom_client_id_topic_sender(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' custom_id = "my_custom_id" topic_name = "topic_name" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) @@ -527,7 +528,7 @@ def test_custom_client_id_topic_sender(self, **kwargs): assert topic_sender.client_identifier == custom_id def test_default_client_id_topic_sender(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' topic_name = "topic_name" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) with servicebus_client: @@ -536,7 +537,7 @@ def test_default_client_id_topic_sender(self, **kwargs): assert "SBSender" in topic_sender.client_identifier def test_default_client_id_subscription_receiver(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' topic_name = "topic_name" sub_name = "sub_name" servicebus_client = ServiceBusClient.from_connection_string(conn_str=servicebus_connection_str) @@ -546,7 +547,7 @@ def test_default_client_id_subscription_receiver(self, **kwargs): assert "SBReceiver" in subscription_receiver.client_identifier def test_custom_client_id_subscription_receiver(self, **kwargs): - servicebus_connection_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' + servicebus_connection_str = f'Endpoint=sb://resourcename{SERVICEBUS_ENDPOINT_SUFFIX}/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;' custom_id = "my_custom_id" topic_name = "topic_name" sub_name = "sub_name" @@ -558,7 +559,7 @@ def test_custom_client_id_subscription_receiver(self, **kwargs): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest') def test_connection_verify_exception(self, @@ -568,7 +569,7 @@ def test_connection_verify_exception(self, servicebus_namespace_primary_key, servicebus_namespace_connection_string, **kwargs): - hostname = "{}.servicebus.windows.net".format(servicebus_namespace.name) + hostname = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" credential = AzureNamedKeyCredential(servicebus_namespace_key_name, servicebus_namespace_primary_key) client = ServiceBusClient(hostname, credential, connection_verify="cacert.pem") diff --git a/sdk/servicebus/azure-servicebus/tests/test_sessions.py b/sdk/servicebus/azure-servicebus/tests/test_sessions.py index 8e730626fccc..43d8fb0e02a2 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_sessions.py +++ b/sdk/servicebus/azure-servicebus/tests/test_sessions.py @@ -33,13 +33,14 @@ AutoLockRenewTimeout ) -from devtools_testutils import AzureMgmtTestCase, CachedResourceGroupPreparer +from devtools_testutils import AzureMgmtTestCase from servicebus_preparer import ( CachedServiceBusNamespacePreparer, CachedServiceBusQueuePreparer, ServiceBusTopicPreparer, ServiceBusQueuePreparer, - ServiceBusSubscriptionPreparer + ServiceBusSubscriptionPreparer, + CachedServiceBusResourceGroupPreparer ) from utilities import get_logger, print_message, sleep_until_expired @@ -49,7 +50,7 @@ class ServiceBusSessionTests(AzureMgmtTestCase): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_session_client_conn_str_receive_handler_peeklock(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -172,7 +173,7 @@ def test_session_by_session_client_conn_str_receive_handler_peeklock(self, servi @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True, lock_duration='PT5S') def test_session_by_queue_client_conn_str_receive_handler_receiveanddelete(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -209,7 +210,7 @@ def test_session_by_queue_client_conn_str_receive_handler_receiveanddelete(self, @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_session_client_conn_str_receive_handler_with_stop(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -250,7 +251,7 @@ def test_session_by_session_client_conn_str_receive_handler_with_stop(self, serv @pytest.mark.liveTest @pytest.mark.live_test_only @pytest.mark.xfail(reason="'Cannot open log' error, potential service bug", raises=ServiceBusError) - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_session_client_conn_str_receive_handler_with_no_session(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -265,7 +266,7 @@ def test_session_by_session_client_conn_str_receive_handler_with_no_session(self @pytest.mark.liveTest @pytest.mark.live_test_only @pytest.mark.xfail(reason="'Cannot open log' error, potential service bug", raises=ServiceBusError) - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_connection_failure_is_idempotent(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -303,7 +304,7 @@ def test_session_connection_failure_is_idempotent(self, servicebus_namespace_con @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_session_client_conn_str_receive_handler_with_inactive_session(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -324,7 +325,7 @@ def test_session_by_session_client_conn_str_receive_handler_with_inactive_sessio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_complete(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -366,7 +367,7 @@ def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_recei @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_deadletter(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -417,7 +418,7 @@ def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_recei @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_receiver_deletemode(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -455,7 +456,7 @@ def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_recei @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_client(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -486,7 +487,7 @@ def test_session_by_servicebus_client_iter_messages_with_retrieve_deferred_clien @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_servicebus_client_receive_with_retrieve_deadletter(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -531,7 +532,7 @@ def test_session_by_servicebus_client_receive_with_retrieve_deadletter(self, ser @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_servicebus_client_browse_messages_client(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -568,7 +569,7 @@ def test_session_by_servicebus_client_browse_messages_client(self, servicebus_na @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_servicebus_client_browse_messages_with_receiver(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -593,7 +594,7 @@ def test_session_by_servicebus_client_browse_messages_with_receiver(self, servic @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_servicebus_client_renew_client_locks(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -639,7 +640,7 @@ def test_session_by_servicebus_client_renew_client_locks(self, servicebus_namesp @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True, lock_duration='PT10S') def test_session_by_conn_str_receive_handler_with_autolockrenew(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -714,7 +715,7 @@ def lock_lost_callback(renewable, error): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True, lock_duration='PT10S') def test_session_by_conn_str_receive_handler_with_auto_autolockrenew(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -812,7 +813,7 @@ def lock_lost_callback(renewable, error): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_receiver_partially_invalid_autolockrenew_mode(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -838,7 +839,7 @@ def should_not_run(*args, **kwargs): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_message_connection_closed(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -862,7 +863,7 @@ def test_session_message_connection_closed(self, servicebus_namespace_connection @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer() + @CachedServiceBusResourceGroupPreparer() @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True, lock_duration='PT5S') def test_session_message_expiry(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -901,7 +902,7 @@ def test_session_message_expiry(self, servicebus_namespace_connection_string, se @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_schedule_message(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -937,7 +938,7 @@ def test_session_schedule_message(self, servicebus_namespace_connection_string, @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_schedule_multiple_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -978,7 +979,7 @@ def test_session_schedule_multiple_messages(self, servicebus_namespace_connectio @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_cancel_scheduled_messages(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1008,7 +1009,7 @@ def test_session_cancel_scheduled_messages(self, servicebus_namespace_connection @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_get_set_state_with_receiver(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1040,7 +1041,7 @@ def test_session_get_set_state_with_receiver(self, servicebus_namespace_connecti @pytest.mark.skip(reason="Needs list sessions") @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_servicebus_client_list_sessions_with_receiver(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1071,7 +1072,7 @@ def test_session_by_servicebus_client_list_sessions_with_receiver(self, serviceb @pytest.mark.skip("Requires list sessions") @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_servicebus_client_list_sessions_with_client(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1101,7 +1102,7 @@ def test_session_by_servicebus_client_list_sessions_with_client(self, servicebus @pytest.mark.liveTest @pytest.mark.live_test_only @pytest.mark.xfail(reason="'Cannot open log' error, potential service bug") - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_servicebus_client_session_pool(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1145,7 +1146,7 @@ def message_processing(sb_client): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_by_session_client_conn_str_receive_handler_peeklock_abandon(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): @@ -1170,7 +1171,7 @@ def test_session_by_session_client_conn_str_receive_handler_peeklock_abandon(sel @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusTopicPreparer(name_prefix='servicebustest') @ServiceBusSubscriptionPreparer(name_prefix='servicebustest', requires_session=True) @@ -1197,7 +1198,7 @@ def test_session_basic_topic_subscription_send_and_receive(self, servicebus_name @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusQueuePreparer(name_prefix='servicebustest', requires_session=True) def test_session_non_session_send_to_session_queue_should_fail(self, servicebus_namespace_connection_string, servicebus_queue, **kwargs): diff --git a/sdk/servicebus/azure-servicebus/tests/test_subscriptions.py b/sdk/servicebus/azure-servicebus/tests/test_subscriptions.py index a32c6b5a5a77..0ad6a50ad73f 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_subscriptions.py +++ b/sdk/servicebus/azure-servicebus/tests/test_subscriptions.py @@ -16,13 +16,15 @@ from azure.servicebus.exceptions import ServiceBusError from azure.servicebus._common.constants import ServiceBusSubQueue -from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer, CachedResourceGroupPreparer +from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer from servicebus_preparer import ( CachedServiceBusNamespacePreparer, CachedServiceBusTopicPreparer, CachedServiceBusSubscriptionPreparer, ServiceBusTopicPreparer, - ServiceBusSubscriptionPreparer + ServiceBusSubscriptionPreparer, + CachedServiceBusResourceGroupPreparer, + SERVICEBUS_ENDPOINT_SUFFIX ) from utilities import get_logger, print_message @@ -32,7 +34,7 @@ class ServiceBusSubscriptionTests(AzureMgmtTestCase): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusTopicPreparer(name_prefix='servicebustest') @ServiceBusSubscriptionPreparer(name_prefix='servicebustest') @@ -73,12 +75,12 @@ def test_subscription_by_subscription_client_conn_str_receive_basic(self, servic @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusTopicPreparer(name_prefix='servicebustest') @ServiceBusSubscriptionPreparer(name_prefix='servicebustest') def test_subscription_by_sas_token_credential_conn_str_send_basic(self, servicebus_namespace, servicebus_namespace_key_name, servicebus_namespace_primary_key, servicebus_topic, servicebus_subscription, **kwargs): - fully_qualified_namespace = servicebus_namespace.name + '.servicebus.windows.net' + fully_qualified_namespace = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" with ServiceBusClient( fully_qualified_namespace=fully_qualified_namespace, credential=ServiceBusSharedKeyCredential( @@ -126,7 +128,7 @@ def test_subscription_by_servicebus_client_list_subscriptions(self, servicebus_n @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @ServiceBusTopicPreparer(name_prefix='servicebustest') @ServiceBusSubscriptionPreparer(name_prefix='servicebustest') diff --git a/sdk/servicebus/azure-servicebus/tests/test_topic.py b/sdk/servicebus/azure-servicebus/tests/test_topic.py index 06d956b064e0..a662a25b03f2 100644 --- a/sdk/servicebus/azure-servicebus/tests/test_topic.py +++ b/sdk/servicebus/azure-servicebus/tests/test_topic.py @@ -11,7 +11,7 @@ import time from datetime import datetime, timedelta -from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer, CachedResourceGroupPreparer +from devtools_testutils import AzureMgmtTestCase, RandomNameResourceGroupPreparer from azure.servicebus import ServiceBusClient from azure.servicebus._base_handler import ServiceBusSharedKeyCredential @@ -20,7 +20,9 @@ ServiceBusNamespacePreparer, ServiceBusTopicPreparer, CachedServiceBusNamespacePreparer, - CachedServiceBusTopicPreparer + CachedServiceBusTopicPreparer, + CachedServiceBusResourceGroupPreparer, + SERVICEBUS_ENDPOINT_SUFFIX ) from utilities import get_logger, print_message @@ -30,7 +32,7 @@ class ServiceBusTopicsTests(AzureMgmtTestCase): @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusTopicPreparer(name_prefix='servicebustest') def test_topic_by_servicebus_client_conn_str_send_basic(self, servicebus_namespace_connection_string, servicebus_topic, **kwargs): @@ -45,11 +47,11 @@ def test_topic_by_servicebus_client_conn_str_send_basic(self, servicebus_namespa @pytest.mark.liveTest @pytest.mark.live_test_only - @CachedResourceGroupPreparer(name_prefix='servicebustest') + @CachedServiceBusResourceGroupPreparer(name_prefix='servicebustest') @CachedServiceBusNamespacePreparer(name_prefix='servicebustest') @CachedServiceBusTopicPreparer(name_prefix='servicebustest') def test_topic_by_sas_token_credential_conn_str_send_basic(self, servicebus_namespace, servicebus_namespace_key_name, servicebus_namespace_primary_key, servicebus_topic, **kwargs): - fully_qualified_namespace = servicebus_namespace.name + '.servicebus.windows.net' + fully_qualified_namespace = f"{servicebus_namespace.name}{SERVICEBUS_ENDPOINT_SUFFIX}" with ServiceBusClient( fully_qualified_namespace=fully_qualified_namespace, credential=ServiceBusSharedKeyCredential( diff --git a/sdk/servicebus/test-resources.json b/sdk/servicebus/test-resources.json index 7a13a54cad9c..f53c9e3750de 100644 --- a/sdk/servicebus/test-resources.json +++ b/sdk/servicebus/test-resources.json @@ -16,6 +16,13 @@ "description": "The subscription ID to which the application and resources belong." } }, + "serviceBusEndpointSuffix": { + "type": "string", + "defaultValue": ".servicebus.windows.net", + "metadata": { + "description": "The url suffix to use when creating eventhubs connection strings." + } + }, "tenantId": { "type": "string", "defaultValue": "[subscription().tenantId]", @@ -199,7 +206,7 @@ }, "SERVICEBUS_FULLY_QUALIFIED_NAMESPACE": { "type": "string", - "value": "[concat(variables('serviceBusNamespace'), '.servicebus.windows.net')]" + "value": "[concat(variables('serviceBusNamespace'), parameters('serviceBusEndpointSuffix'))]" }, "SERVICEBUS_TOPIC_NAME": { "type": "string", @@ -236,6 +243,14 @@ "SERVICEBUS_SESSION_QUEUE_SAS_KEY":{ "type": "string", "value": "[listkeys(variables('sessionQueueAuthorizationRuleName'), variables('sbVersion')).primaryKey]" + }, + "RESOURCE_REGION": { + "type": "string", + "value": "[parameters('location')]" + }, + "SERVICEBUS_ENDPOINT_SUFFIX": { + "type": "string", + "value": "[parameters('serviceBusEndpointSuffix')]" } } } \ No newline at end of file diff --git a/sdk/servicebus/tests.yml b/sdk/servicebus/tests.yml index de9f4c1244a5..8c24ecbf2c8b 100644 --- a/sdk/servicebus/tests.yml +++ b/sdk/servicebus/tests.yml @@ -7,18 +7,25 @@ stages: TestTimeoutInMinutes: 300 BuildTargetingString: azure-servicebus* EnvVars: - AZURE_SUBSCRIPTION_ID: $(azure-subscription-id) - AZURE_TENANT_ID: $(aad-azure-sdk-test-tenant-id) - AZURE_CLIENT_ID: $(aad-azure-sdk-test-client-id) - AZURE_CLIENT_SECRET: $(aad-azure-sdk-test-client-secret) + AZURE_SUBSCRIPTION_ID: $(SERVICEBUS_SUBSCRIPTION_ID) + AZURE_TENANT_ID: $(SERVICEBUS_TENANT_ID) + AZURE_CLIENT_ID: $(SERVICEBUS_CLIENT_ID) + AZURE_CLIENT_SECRET: $(SERVICEBUS_CLIENT_SECRET) AZURE_TEST_RUN_LIVE: 'true' AZURE_SKIP_LIVE_RECORDING: 'True' MatrixFilters: - PythonVersion=^(?!pypy3).* Clouds: 'Public,Canary' + SupportedClouds: 'Public,UsGov,China' CloudConfig: Public: SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources) Canary: SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources) Location: 'centraluseuap' + UsGov: + SubscriptionConfiguration: $(sub-config-gov-test-resources) + Location: 'usgovarizona' + China: + SubscriptionConfiguration: $(sub-config-cn-test-resources) + Location: 'chinanorth2'