Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[ServiceBus] enable sovereign cloud testing #29202

Merged
11 commits merged into from
Mar 25, 2023
2 changes: 1 addition & 1 deletion sdk/servicebus/azure-servicebus/dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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')
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,7 +21,9 @@
ServiceBusNamespacePreparer,
ServiceBusTopicPreparer,
CachedServiceBusNamespacePreparer,
CachedServiceBusTopicPreparer
CachedServiceBusTopicPreparer,
CachedServiceBusResourceGroupPreparer,
SERVICEBUS_ENDPOINT_SUFFIX
)
from utilities import get_logger, print_message

Expand All @@ -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):
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from sb_env_loader import (
ServiceBusPreparer
)
from servicebus_preparer import (
SERVICEBUS_ENDPOINT_SUFFIX
)

from mgmt_test_utilities_async import (
AsyncMgmtQueueListTestHelper,
Expand Down Expand Up @@ -276,8 +279,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)
Expand All @@ -295,8 +298,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
Expand Down Expand Up @@ -438,8 +441,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
Expand All @@ -461,8 +464,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}{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}"
queue_description.forward_dead_lettered_messages_to = f"sb://{servicebus_fully_qualified_namespace}{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}"
#queue_description.requires_duplicate_detection = True # Read only
#queue_description.requires_session = True # Cannot be changed after creation

Expand All @@ -479,9 +482,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

Expand Down Expand Up @@ -688,8 +691,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}{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}"
queue_description_dict["forward_dead_lettered_messages_to"] = f"sb://{servicebus_fully_qualified_namespace}{SERVICEBUS_ENDPOINT_SUFFIX}/{queue_name}"
#queue_description_dict["requires_duplicate_detection"] = True # Read only
#queue_description_dict["requires_session"] = True # Cannot be changed after creation

Expand All @@ -706,9 +709,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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

Expand Down Expand Up @@ -120,8 +123,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)
Expand Down Expand Up @@ -191,17 +194,17 @@ 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
subscription_description.forward_dead_lettered_messages_to = queue_name
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
Expand Down Expand Up @@ -457,8 +460,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(
Expand Down
Loading