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] add keyword override support to update_ methods in mgmt module #18210

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add test and recordings
  • Loading branch information
yunhaoling committed Apr 22, 2021
commit 7b0980065f2c3663c2a4f940d13fa6f87e503022

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

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 @@ -393,10 +393,42 @@ async def test_async_mgmt_queue_update_success(self, servicebus_namespace_connec
assert queue_description.default_message_time_to_live == datetime.timedelta(minutes=11, seconds=2)
assert queue_description.duplicate_detection_history_time_window == datetime.timedelta(minutes=12, seconds=3)

# updating all settings with keyword arguments.
await mgmt_service.update_queue(
queue_description,
auto_delete_on_idle=datetime.timedelta(minutes=15),
dead_lettering_on_message_expiration=False,
default_message_time_to_live=datetime.timedelta(minutes=16),
duplicate_detection_history_time_window=datetime.timedelta(minutes=17),
enable_batched_operations=False,
enable_express=False,
lock_duration=datetime.timedelta(seconds=18),
max_delivery_count=15,
max_size_in_megabytes=2048,
forward_to=None,
forward_dead_lettered_messages_to=None
)
queue_description = await mgmt_service.get_queue(queue_name)
assert queue_description.auto_delete_on_idle == datetime.timedelta(minutes=15)
assert queue_description.dead_lettering_on_message_expiration == False
assert queue_description.default_message_time_to_live == datetime.timedelta(minutes=16)
assert queue_description.duplicate_detection_history_time_window == datetime.timedelta(minutes=17)
assert queue_description.enable_batched_operations == False
assert queue_description.enable_express == False
#assert queue_description.enable_partitioning == True
assert queue_description.lock_duration == datetime.timedelta(seconds=18)
assert queue_description.max_delivery_count == 15
assert queue_description.max_size_in_megabytes == 2048
# Note: We endswith to avoid the fact that the servicebus_namespace_name is replacered locally but not in the properties bag, and still test this.
assert queue_description.forward_to == None
assert queue_description.forward_dead_lettered_messages_to == None
#assert queue_description.requires_duplicate_detection == True
#assert queue_description.requires_session == True

finally:
await mgmt_service.delete_queue(queue_name)
await mgmt_service.delete_topic(topic_name)
mgmt_service.close()
await mgmt_service.close()

@CachedResourceGroupPreparer(name_prefix='servicebustest')
@CachedServiceBusNamespacePreparer(name_prefix='servicebustest')
Expand Down Expand Up @@ -576,6 +608,39 @@ async def test_mgmt_queue_async_update_dict_success(self, servicebus_namespace_c
assert queue_description.forward_dead_lettered_messages_to.endswith(".servicebus.windows.net/{}".format(queue_name))
#assert queue_description.requires_duplicate_detection == True
#assert queue_description.requires_session == True

# updating all settings with keyword arguments.
await mgmt_service.update_queue(
dict(queue_description),
auto_delete_on_idle=datetime.timedelta(minutes=15),
dead_lettering_on_message_expiration=False,
default_message_time_to_live=datetime.timedelta(minutes=16),
duplicate_detection_history_time_window=datetime.timedelta(minutes=17),
enable_batched_operations=False,
enable_express=False,
lock_duration=datetime.timedelta(seconds=18),
max_delivery_count=15,
max_size_in_megabytes=2048,
forward_to=None,
forward_dead_lettered_messages_to=None
)
queue_description = await mgmt_service.get_queue(queue_name)
assert queue_description.auto_delete_on_idle == datetime.timedelta(minutes=15)
assert queue_description.dead_lettering_on_message_expiration == False
assert queue_description.default_message_time_to_live == datetime.timedelta(minutes=16)
assert queue_description.duplicate_detection_history_time_window == datetime.timedelta(minutes=17)
assert queue_description.enable_batched_operations == False
assert queue_description.enable_express == False
# assert queue_description.enable_partitioning == True
assert queue_description.lock_duration == datetime.timedelta(seconds=18)
assert queue_description.max_delivery_count == 15
assert queue_description.max_size_in_megabytes == 2048
# Note: We endswith to avoid the fact that the servicebus_namespace_name is replacered locally but not in the properties bag, and still test this.
assert queue_description.forward_to == None
assert queue_description.forward_dead_lettered_messages_to == None
# assert queue_description.requires_duplicate_detection == True
# assert queue_description.requires_session == True

finally:
await mgmt_service.delete_queue(queue_name)
yunhaoling marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ async def test_async_mgmt_rule_update_success(self, servicebus_namespace_connect
assert rule_desc.filter.correlation_id == 'testcid'
assert rule_desc.action.sql_expression == "SET Priority = 'low'"

await mgmt_service.update_rule(
topic_description.name,
subscription_description.name,
rule_desc,
filter=CorrelationRuleFilter(correlation_id='updatedcid'),
action=None
)

rule_desc = await mgmt_service.get_rule(topic_name, subscription_name, rule_name)
assert type(rule_desc.filter) == CorrelationRuleFilter
assert rule_desc.filter.correlation_id == 'updatedcid'
assert rule_desc.action == None

finally:
await mgmt_service.delete_rule(topic_name, subscription_name, rule_name)
await mgmt_service.delete_subscription(topic_name, subscription_name)
yunhaoling marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -280,6 +293,19 @@ async def test_mgmt_rule_async_update_dict_success(self, servicebus_namespace_co
assert rule_desc.filter.correlation_id == 'testcid'
assert rule_desc.action.sql_expression == "SET Priority = 'low'"

await mgmt_service.update_rule(
topic_description.name,
subscription_description.name,
dict(rule_desc),
filter=CorrelationRuleFilter(correlation_id='updatedcid'),
action=None
)

rule_desc = await mgmt_service.get_rule(topic_name, subscription_name, rule_name)
assert type(rule_desc.filter) == CorrelationRuleFilter
assert rule_desc.filter.correlation_id == 'updatedcid'
assert rule_desc.action == None

finally:
await mgmt_service.delete_rule(topic_name, subscription_name, rule_name)
await mgmt_service.delete_subscription(topic_name, subscription_name)
yunhaoling marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,34 @@ async def test_async_mgmt_subscription_update_success(self, servicebus_namespace
assert subscription_description.default_message_time_to_live == datetime.timedelta(minutes=11, seconds=2)
assert subscription_description.lock_duration == datetime.timedelta(minutes=3, seconds=3)

# updating all settings with keyword arguments.
await mgmt_service.update_subscription(
topic_description.name,
subscription_description,
auto_delete_on_idle=datetime.timedelta(minutes=15),
dead_lettering_on_message_expiration=False,
default_message_time_to_live=datetime.timedelta(minutes=16),
lock_duration=datetime.timedelta(seconds=17),
max_delivery_count=15,
forward_to=None,
forward_dead_lettered_messages_to=None
)

subscription_description = await mgmt_service.get_subscription(topic_description.name, subscription_name)

assert subscription_description.auto_delete_on_idle == datetime.timedelta(minutes=15)
assert subscription_description.dead_lettering_on_message_expiration == False
assert subscription_description.default_message_time_to_live == datetime.timedelta(minutes=16)
assert subscription_description.max_delivery_count == 15
assert subscription_description.lock_duration == datetime.timedelta(seconds=17)
assert subscription_description.forward_to == None
assert subscription_description.forward_dead_lettered_messages_to == None

finally:
await mgmt_service.delete_subscription(topic_name, subscription_name)
await mgmt_service.delete_topic(topic_name)
await mgmt_service.delete_queue(queue_name)
mgmt_service.close()
await mgmt_service.close()

@CachedResourceGroupPreparer(name_prefix='servicebustest')
@CachedServiceBusNamespacePreparer(name_prefix='servicebustest')
Expand Down Expand Up @@ -437,6 +460,28 @@ async def test_mgmt_subscription_async_update_dict_success(self, servicebus_name
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))

# updating all settings with keyword arguments.
await mgmt_service.update_subscription(
topic_description.name,
dict(subscription_description),
auto_delete_on_idle=datetime.timedelta(minutes=15),
dead_lettering_on_message_expiration=False,
default_message_time_to_live=datetime.timedelta(minutes=16),
lock_duration=datetime.timedelta(seconds=17),
max_delivery_count=15,
forward_to=None,
forward_dead_lettered_messages_to=None
)

subscription_description = await mgmt_service.get_subscription(topic_description.name, subscription_name)

assert subscription_description.auto_delete_on_idle == datetime.timedelta(minutes=15)
assert subscription_description.dead_lettering_on_message_expiration == False
assert subscription_description.default_message_time_to_live == datetime.timedelta(minutes=16)
assert subscription_description.max_delivery_count == 15
assert subscription_description.lock_duration == datetime.timedelta(seconds=17)
assert subscription_description.forward_to == None
assert subscription_description.forward_dead_lettered_messages_to == None
finally:
await mgmt_service.delete_subscription(topic_name, subscription_name)
await mgmt_service.delete_topic(topic_name)
yunhaoling marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,30 @@ async def test_async_mgmt_topic_update_success(self, servicebus_namespace_connec
assert topic_description.default_message_time_to_live == datetime.timedelta(minutes=11, seconds=2)
assert topic_description.duplicate_detection_history_time_window == datetime.timedelta(minutes=12, seconds=3)

# updating all settings with keyword arguments.
await mgmt_service.update_topic(
topic_description,
auto_delete_on_idle=datetime.timedelta(minutes=14),
default_message_time_to_live=datetime.timedelta(minutes=15),
duplicate_detection_history_time_window=datetime.timedelta(minutes=16),
enable_batched_operations=False,
enable_express=False,
max_size_in_megabytes=2048,
support_ordering=False
)
topic_description = await mgmt_service.get_topic(topic_name)

assert topic_description.auto_delete_on_idle == datetime.timedelta(minutes=14)
assert topic_description.default_message_time_to_live == datetime.timedelta(minutes=15)
assert topic_description.duplicate_detection_history_time_window == datetime.timedelta(minutes=16)
assert topic_description.enable_batched_operations == False
assert topic_description.enable_express == False
# assert topic_description.enable_partitioning == True
assert topic_description.max_size_in_megabytes == 2048
# assert topic_description.requires_duplicate_detection == True
# assert topic_description.requires_session == True
assert topic_description.support_ordering == False

finally:
await mgmt_service.delete_topic(topic_name)
yunhaoling marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -333,6 +357,30 @@ async def test_mgmt_topic_async_update_dict_success(self, servicebus_namespace_c
# assert topic_description.requires_duplicate_detection == True
# assert topic_description.requires_session == True
assert topic_description.support_ordering == True

# updating all settings with keyword arguments.
await mgmt_service.update_topic(
dict(topic_description),
auto_delete_on_idle=datetime.timedelta(minutes=14),
default_message_time_to_live=datetime.timedelta(minutes=15),
duplicate_detection_history_time_window=datetime.timedelta(minutes=16),
enable_batched_operations=False,
enable_express=False,
max_size_in_megabytes=2048,
support_ordering=False
)
topic_description = await mgmt_service.get_topic(topic_name)

assert topic_description.auto_delete_on_idle == datetime.timedelta(minutes=14)
assert topic_description.default_message_time_to_live == datetime.timedelta(minutes=15)
assert topic_description.duplicate_detection_history_time_window == datetime.timedelta(minutes=16)
assert topic_description.enable_batched_operations == False
assert topic_description.enable_express == False
# assert topic_description.enable_partitioning == True
assert topic_description.max_size_in_megabytes == 2048
# assert topic_description.requires_duplicate_detection == True
# assert topic_description.requires_session == True
assert topic_description.support_ordering == False
finally:
await mgmt_service.delete_topic(topic_name)
yunhaoling marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
Loading