Skip to content

Commit be8ce75

Browse files
{cosmosdb-preview} Fix SQL container throughput update to preserve existing throughput buckets (Azure#9033)
* test: Enhance CosmosDB throughput bucketing tests to verify bucket retention and removal * Changes to preserve throughput buckets on throughput change and record test * Bump version in setup.py and fix whitespaces * Fix formatting in error messages for container not found exceptions * Rerecorded failing tests
1 parent dbf3ea0 commit be8ce75

9 files changed

+5189
-4796
lines changed

src/cosmosdb-preview/HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
.. :changelog:
22
Release History
33
===============
4+
5+
1.6.1
6+
+++++
7+
* Fix SQL container throughput update to preserve existing throughput buckets when not explicitly specified.
8+
49
1.6.0
510
* Add support for Fleet/Fleetspace/FleetspaceAccount/FleetAnalytics CRUD actions.
611

src/cosmosdb-preview/azext_cosmosdb_preview/custom.py

Lines changed: 3379 additions & 3370 deletions
Large diffs are not rendered by default.

src/cosmosdb-preview/azext_cosmosdb_preview/tests/latest/recordings/test_cosmosdb_sql_container_adaptiveru.yaml

Lines changed: 267 additions & 219 deletions
Large diffs are not rendered by default.

src/cosmosdb-preview/azext_cosmosdb_preview/tests/latest/recordings/test_cosmosdb_sql_container_merge.yaml

Lines changed: 203 additions & 155 deletions
Large diffs are not rendered by default.

src/cosmosdb-preview/azext_cosmosdb_preview/tests/latest/recordings/test_cosmosdb_sql_throughput_bucketing.yaml

Lines changed: 617 additions & 116 deletions
Large diffs are not rendered by default.

src/cosmosdb-preview/azext_cosmosdb_preview/tests/latest/recordings/test_managed_cassandra_cluster_without_datacenters.yaml

Lines changed: 216 additions & 362 deletions
Large diffs are not rendered by default.

src/cosmosdb-preview/azext_cosmosdb_preview/tests/latest/recordings/test_managed_cassandra_verify_lists.yaml

Lines changed: 474 additions & 572 deletions
Large diffs are not rendered by default.

src/cosmosdb-preview/azext_cosmosdb_preview/tests/latest/test_cosmosdb_sql_throughput_bucketing_scenario.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ def test_cosmosdb_sql_throughput_bucketing(self, resource_group):
1515
col = self.create_random_name(prefix='cli', length=15)
1616
db_name = self.create_random_name(prefix='cli', length=15)
1717
throughput_buckets = '"[{\\"id\\": 1, \\"maxThroughputPercentage\\": 10 }, {\\"id\\": 2, \\"maxThroughputPercentage\\": 20 }]"'
18+
empty_throughput_buckets = '"[]"'
1819

1920
# This test needs to be run on the following account since it has the feature flag enabled
2021
self.kwargs.update({
2122
'rg': 'throughput-bucketing-rg',
2223
'acc': 'throughput-bucketing-rp-test',
2324
'db_name': db_name,
2425
'col': col,
25-
'throughput_buckets': throughput_buckets
26+
'throughput_buckets': throughput_buckets,
27+
'empty_throughput_buckets': empty_throughput_buckets
2628
})
2729

2830
# Create database
@@ -44,6 +46,30 @@ def test_cosmosdb_sql_throughput_bucketing(self, resource_group):
4446
assert actual_throughput_buckets[1]["id"] == 2
4547
assert actual_throughput_buckets[1]["maxThroughputPercentage"] == 20
4648

49+
# Test: Change throughput without specifying throughput buckets - buckets should be retained
50+
self.cmd('az cosmosdb sql container throughput update -g {rg} -a {acc} -d {db_name} -n {col} --throughput 4000')
51+
52+
throughput_resource_json = self.cmd('az cosmosdb sql container throughput show -g {rg} -a {acc} -d {db_name} -n {col}').get_output_in_json()
53+
retained_throughput_buckets = throughput_resource_json["resource"]["throughputBuckets"]
54+
55+
# Verify throughput buckets are retained after throughput change
56+
assert len(retained_throughput_buckets) == 2
57+
assert retained_throughput_buckets[0]["id"] == 1
58+
assert retained_throughput_buckets[0]["maxThroughputPercentage"] == 10
59+
assert retained_throughput_buckets[1]["id"] == 2
60+
assert retained_throughput_buckets[1]["maxThroughputPercentage"] == 20
61+
62+
# Verify throughput was actually updated
63+
assert throughput_resource_json["resource"]["throughput"] == 4000
64+
65+
# Test: Set throughput buckets to empty array - buckets should be removed
66+
self.cmd('az cosmosdb sql container throughput update -g {rg} -a {acc} -d {db_name} -n {col} --throughput 4000 --throughput-buckets {empty_throughput_buckets}')
67+
68+
throughput_resource_json = self.cmd('az cosmosdb sql container throughput show -g {rg} -a {acc} -d {db_name} -n {col}').get_output_in_json()
69+
70+
# Verify throughput buckets are removed when set to empty array
71+
assert len(throughput_resource_json["resource"]["throughputBuckets"]) == 0
72+
4773
# delete container
4874
self.cmd('az cosmosdb sql container delete -g {rg} -a {acc} -d {db_name} -n {col} -y')
4975

src/cosmosdb-preview/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# TODO: Confirm this is the right version number you want and it matches your
1818
# HISTORY.rst entry.
19-
VERSION = '1.6.0'
19+
VERSION = '1.6.1'
2020

2121
# The full list of classifiers is available at
2222
# https://pypi.python.org/pypi?%3Aaction=list_classifiers

0 commit comments

Comments
 (0)