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

[Service Bus] Normalize management naming with other languages #12829

Merged
merged 19 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
AccessRights, EntityAvailabilityStatus, EntityStatus, \
NamespaceProperties, MessagingSku, NamespaceType

from ._models import QueueRuntimeInfo, QueueDescription, TopicRuntimeInfo, TopicDescription, \
SubscriptionDescription, SubscriptionRuntimeInfo, RuleDescription, \
from ._models import QueueRuntimeProperties, QueueProperties, TopicRuntimeProperties, TopicProperties, \
SubscriptionRuntimeProperties, SubscriptionProperties, RuleProperties, \
TrueRuleFilter, FalseRuleFilter, SqlRuleFilter, CorrelationRuleFilter, \
SqlRuleAction

__all__ = [
'ServiceBusManagementClient',
'AuthorizationRule',
'MessageCountDetails',
'QueueDescription',
'QueueRuntimeInfo',
'TopicDescription',
'TopicRuntimeInfo',
'SubscriptionDescription',
'SubscriptionRuntimeInfo',
'QueueProperties',
'QueueRuntimeProperties',
'TopicProperties',
'TopicRuntimeProperties',
'SubscriptionProperties',
'SubscriptionRuntimeProperties',
'AccessRights',
'EntityAvailabilityStatus',
'EntityStatus',
'RuleDescription',
'RuleProperties',
'CorrelationRuleFilter', 'SqlRuleFilter', 'TrueRuleFilter', 'FalseRuleFilter',
'SqlRuleAction',
'NamespaceProperties', 'MessagingSku', 'NamespaceType',
Expand Down

Large diffs are not rendered by default.

822 changes: 521 additions & 301 deletions sdk/servicebus/azure-servicebus/azure/servicebus/management/_models.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import msrest
from azure.core.exceptions import HttpResponseError, ResourceNotFoundError, ResourceExistsError
from azure.servicebus.aio.management import ServiceBusManagementClient
from azure.servicebus.management import QueueDescription
from azure.servicebus.management import QueueProperties
from azure.servicebus.aio import ServiceBusSharedKeyCredential
from azure.servicebus._common.utils import utc_now

Expand Down Expand Up @@ -213,22 +213,17 @@ async def test_async_mgmt_queue_create_with_invalid_name(self, servicebus_namesp
with pytest.raises(msrest.exceptions.ValidationError):
await mgmt_service.create_queue(Exception())

with pytest.raises(msrest.exceptions.ValidationError):
await mgmt_service.create_queue(QueueDescription(name=Exception()))

with pytest.raises(msrest.exceptions.ValidationError):
await mgmt_service.create_queue('')

with pytest.raises(msrest.exceptions.ValidationError):
await mgmt_service.create_queue(QueueDescription(name=''))

@CachedResourceGroupPreparer(name_prefix='servicebustest')
@CachedServiceBusNamespacePreparer(name_prefix='servicebustest')
async def test_async_mgmt_queue_create_with_queue_description(self, servicebus_namespace_connection_string, **kwargs):
mgmt_service = ServiceBusManagementClient.from_connection_string(servicebus_namespace_connection_string)
await clear_queues(mgmt_service)
queue_name = "dkldf"
await mgmt_service.create_queue(QueueDescription(name=queue_name,
await mgmt_service.create_queue(queue_name,
auto_delete_on_idle=datetime.timedelta(minutes=10),
dead_lettering_on_message_expiration=True,
default_message_time_to_live=datetime.timedelta(minutes=11),
Expand All @@ -243,7 +238,7 @@ async def test_async_mgmt_queue_create_with_queue_description(self, servicebus_n
#requires_duplicate_detection=True,
requires_session=True,
support_ordering=True
))
)
try:
queue = await mgmt_service.get_queue(queue_name)
assert queue.name == queue_name
Expand Down Expand Up @@ -392,16 +387,15 @@ async def test_async_mgmt_queue_list_runtime_info_basic(self, servicebus_namespa
info = queues_infos[0]

assert info.size_in_bytes == 0
assert info.created_at is not None
assert info.accessed_at is not None
assert info.updated_at is not None
assert info.message_count == 0

assert info.message_count_details
assert info.message_count_details.active_message_count == 0
assert info.message_count_details.dead_letter_message_count == 0
assert info.message_count_details.transfer_dead_letter_message_count == 0
assert info.message_count_details.transfer_message_count == 0
assert info.message_count_details.scheduled_message_count == 0
assert info.total_message_count == 0
assert info.active_message_count == 0
assert info.dead_letter_message_count == 0
assert info.transfer_dead_letter_message_count == 0
assert info.transfer_message_count == 0
assert info.scheduled_message_count == 0

await mgmt_service.delete_queue("test_queue")
queues_infos = await async_pageable_to_list(mgmt_service.list_queues_runtime_info())
Expand Down Expand Up @@ -435,14 +429,12 @@ async def test_async_mgmt_queue_get_runtime_info_basic(self, servicebus_namespac
assert queue_runtime_info.created_at is not None
assert queue_runtime_info.accessed_at is not None
assert queue_runtime_info.updated_at is not None
assert queue_runtime_info.message_count == 0

assert queue_runtime_info.message_count_details
assert queue_runtime_info.message_count_details.active_message_count == 0
assert queue_runtime_info.message_count_details.dead_letter_message_count == 0
assert queue_runtime_info.message_count_details.transfer_dead_letter_message_count == 0
assert queue_runtime_info.message_count_details.transfer_message_count == 0
assert queue_runtime_info.message_count_details.scheduled_message_count == 0
assert queue_runtime_info.total_message_count == 0
assert queue_runtime_info.active_message_count == 0
assert queue_runtime_info.dead_letter_message_count == 0
assert queue_runtime_info.transfer_dead_letter_message_count == 0
assert queue_runtime_info.transfer_message_count == 0
assert queue_runtime_info.scheduled_message_count == 0
await mgmt_service.delete_queue("test_queue")

@CachedResourceGroupPreparer(name_prefix='servicebustest')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import msrest
from azure.servicebus.aio.management import ServiceBusManagementClient
from azure.servicebus.management import RuleDescription, CorrelationRuleFilter, SqlRuleFilter, TrueRuleFilter, SqlRuleAction
from azure.servicebus.management import RuleProperties, CorrelationRuleFilter, SqlRuleFilter, TrueRuleFilter, SqlRuleAction
from azure.servicebus.management._constants import INT32_MAX_VALUE
from utilities import get_logger
from azure.core.exceptions import HttpResponseError, ResourceExistsError
Expand Down Expand Up @@ -48,21 +48,18 @@ async def test_async_mgmt_rule_create(self, servicebus_namespace_connection_stri
sql_rule_action = SqlRuleAction(sql_expression="SET Priority = @param", parameters={
"@param": datetime(2020, 7, 5, 11, 12, 13),
})
rule_1 = RuleDescription(name=rule_name_1, filter=correlation_fitler, action=sql_rule_action)

sql_filter = SqlRuleFilter("Priority = @param1", parameters={
"@param1": "str1",
})
rule_2 = RuleDescription(name=rule_name_2, filter=sql_filter)

bool_filter = TrueRuleFilter()
rule_3 = RuleDescription(name=rule_name_3, filter=bool_filter)

try:
await mgmt_service.create_topic(topic_name)
await mgmt_service.create_subscription(topic_name, subscription_name)

await mgmt_service.create_rule(topic_name, subscription_name, rule_1)
await mgmt_service.create_rule(topic_name, subscription_name, rule_name_1, filter=correlation_fitler, action=sql_rule_action)
rule_desc = await mgmt_service.get_rule(topic_name, subscription_name, rule_name_1)
rule_properties = rule_desc.filter.properties
assert type(rule_desc.filter) == CorrelationRuleFilter
Expand All @@ -76,13 +73,13 @@ async def test_async_mgmt_rule_create(self, servicebus_namespace_connection_stri
assert rule_properties["key_datetime"] == datetime(2020, 7, 5, 11, 12, 13)
assert rule_properties["key_duration"] == timedelta(days=1, hours=2, minutes=3)

await mgmt_service.create_rule(topic_name, subscription_name, rule_2)
await mgmt_service.create_rule(topic_name, subscription_name, rule_name_2, filter=sql_filter)
rule_desc = await mgmt_service.get_rule(topic_name, subscription_name, rule_name_2)
assert type(rule_desc.filter) == SqlRuleFilter
assert rule_desc.filter.sql_expression == "Priority = @param1"
assert rule_desc.filter.parameters["@param1"] == "str1"

await mgmt_service.create_rule(topic_name, subscription_name, rule_3)
await mgmt_service.create_rule(topic_name, subscription_name, rule_name_3, filter=bool_filter)
rule_desc = await mgmt_service.get_rule(topic_name, subscription_name, rule_name_3)
assert type(rule_desc.filter) == TrueRuleFilter

Expand All @@ -102,13 +99,12 @@ async def test_async_mgmt_rule_create_duplicate(self, servicebus_namespace_conne
subscription_name = 'kkaqo'
rule_name = 'rule'
sql_filter = SqlRuleFilter("Priority = 'low'")
rule = RuleDescription(name=rule_name, filter=sql_filter)
try:
await mgmt_service.create_topic(topic_name)
await mgmt_service.create_subscription(topic_name, subscription_name)
await mgmt_service.create_rule(topic_name, subscription_name, rule)
await mgmt_service.create_rule(topic_name, subscription_name, rule_name, filter=sql_filter)
with pytest.raises(ResourceExistsError):
await mgmt_service.create_rule(topic_name, subscription_name, rule)
await mgmt_service.create_rule(topic_name, subscription_name, rule_name, filter=sql_filter)
finally:
await mgmt_service.delete_rule(topic_name, subscription_name, rule_name)
await mgmt_service.delete_subscription(topic_name, subscription_name)
Expand All @@ -123,12 +119,11 @@ async def test_async_mgmt_rule_update_success(self, servicebus_namespace_connect
subscription_name = "eqkovc"
rule_name = 'rule'
sql_filter = SqlRuleFilter("Priority = 'low'")
rule = RuleDescription(name=rule_name, filter=sql_filter)

try:
topic_description = await mgmt_service.create_topic(topic_name)
subscription_description = await mgmt_service.create_subscription(topic_description, subscription_name)
await mgmt_service.create_rule(topic_name, subscription_name, rule)
await mgmt_service.create_rule(topic_name, subscription_name, rule_name, filter=sql_filter)

rule_desc = await mgmt_service.get_rule(topic_name, subscription_name, rule_name)

Expand Down Expand Up @@ -161,12 +156,11 @@ async def test_async_mgmt_rule_update_invalid(self, servicebus_namespace_connect
subscription_name = "eqkovc"
rule_name = 'rule'
sql_filter = SqlRuleFilter("Priority = 'low'")
rule = RuleDescription(name=rule_name, filter=sql_filter)

try:
topic_description = await mgmt_service.create_topic(topic_name)
subscription_description = await mgmt_service.create_subscription(topic_name, subscription_name)
await mgmt_service.create_rule(topic_name, subscription_name, rule)
await mgmt_service.create_rule(topic_name, subscription_name, rule_name, filter=sql_filter)

rule_desc = await mgmt_service.get_rule(topic_name, subscription_name, rule_name)

Expand Down Expand Up @@ -209,9 +203,6 @@ async def test_async_mgmt_rule_list_and_delete(self, servicebus_namespace_connec
sql_filter_1 = SqlRuleFilter("Priority = 'low'")
sql_filter_2 = SqlRuleFilter("Priority = 'middle'")
sql_filter_3 = SqlRuleFilter("Priority = 'high'")
rule_1 = RuleDescription(name=rule_name_1, filter=sql_filter_1)
rule_2 = RuleDescription(name=rule_name_2, filter=sql_filter_2)
rule_3 = RuleDescription(name=rule_name_3, filter=sql_filter_3)

try:
await mgmt_service.create_topic(topic_name)
Expand All @@ -220,9 +211,9 @@ async def test_async_mgmt_rule_list_and_delete(self, servicebus_namespace_connec
rules = await async_pageable_to_list(mgmt_service.list_rules(topic_name, subscription_name))
assert len(rules) == 1 # by default there is a True filter

await mgmt_service.create_rule(topic_name, subscription_name, rule_1)
await mgmt_service.create_rule(topic_name, subscription_name, rule_2)
await mgmt_service.create_rule(topic_name, subscription_name, rule_3)
await mgmt_service.create_rule(topic_name, subscription_name, rule_name_1, filter=sql_filter_1)
await mgmt_service.create_rule(topic_name, subscription_name, rule_name_2, filter=sql_filter_2)
await mgmt_service.create_rule(topic_name, subscription_name, rule_name_3, filter=sql_filter_3)

rules = await async_pageable_to_list(mgmt_service.list_rules(topic_name, subscription_name))
assert len(rules) == 3 + 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import msrest
from azure.servicebus.aio.management import ServiceBusManagementClient
from azure.servicebus.management import SubscriptionDescription
from azure.servicebus.management import SubscriptionProperties
from utilities import get_logger
from azure.core.exceptions import HttpResponseError, ResourceExistsError

Expand Down Expand Up @@ -55,16 +55,14 @@ async def test_async_mgmt_subscription_create_with_subscription_description(self
await mgmt_service.create_topic(topic_name)
await mgmt_service.create_subscription(
topic_name,
SubscriptionDescription(
name=subscription_name,
auto_delete_on_idle=datetime.timedelta(minutes=10),
dead_lettering_on_message_expiration=True,
default_message_time_to_live=datetime.timedelta(minutes=11),
enable_batched_operations=True,
lock_duration=datetime.timedelta(seconds=13),
max_delivery_count=14,
requires_session=True
)
name=subscription_name,
auto_delete_on_idle=datetime.timedelta(minutes=10),
dead_lettering_on_message_expiration=True,
default_message_time_to_live=datetime.timedelta(minutes=11),
enable_batched_operations=True,
lock_duration=datetime.timedelta(seconds=13),
max_delivery_count=14,
requires_session=True
)
subscription = await mgmt_service.get_subscription(topic_name, subscription_name)
assert subscription.name == subscription_name
Expand Down Expand Up @@ -257,13 +255,12 @@ async def test_async_mgmt_subscription_list_runtime_info(self, servicebus_namesp

assert info.accessed_at is not None
assert info.updated_at is not None

assert info.message_count_details
assert info.message_count_details.active_message_count == 0
assert info.message_count_details.dead_letter_message_count == 0
assert info.message_count_details.transfer_dead_letter_message_count == 0
assert info.message_count_details.transfer_message_count == 0
assert info.message_count_details.scheduled_message_count == 0
assert info.created_at is not None
assert info.total_message_count == 0
assert info.active_message_count == 0
assert info.dead_letter_message_count == 0
assert info.transfer_dead_letter_message_count == 0
assert info.transfer_message_count == 0

await mgmt_service.delete_subscription(topic_name, subscription_name)
subs_infos = await async_pageable_to_list(mgmt_service.list_subscriptions_runtime_info(topic_name))
Expand All @@ -288,13 +285,11 @@ async def test_async_mgmt_subscription_get_runtime_info_basic(self, servicebus_n
assert sub_runtime_info.created_at is not None
assert sub_runtime_info.accessed_at is not None
assert sub_runtime_info.updated_at is not None

assert sub_runtime_info.message_count_details
assert sub_runtime_info.message_count_details.active_message_count == 0
assert sub_runtime_info.message_count_details.dead_letter_message_count == 0
assert sub_runtime_info.message_count_details.transfer_dead_letter_message_count == 0
assert sub_runtime_info.message_count_details.transfer_message_count == 0
assert sub_runtime_info.message_count_details.scheduled_message_count == 0
assert sub_runtime_info.total_message_count == 0
assert sub_runtime_info.active_message_count == 0
assert sub_runtime_info.dead_letter_message_count == 0
assert sub_runtime_info.transfer_dead_letter_message_count == 0
assert sub_runtime_info.transfer_message_count == 0

await mgmt_service.delete_subscription(topic_name, subscription_name)
await mgmt_service.delete_topic(topic_name)
Loading