-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Adding ability to scale for Redis Cache, adding tests #2821
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
23c7bef
adding ability to scale for redis cache
alfantp 0517121
adding tests for redis cache, adding change in history.rst
alfantp e9e91e7
fixing test failures
alfantp 3fea829
fixing build errors
alfantp 34d64e8
removing sku-capacity and sku-family and adding vm-size as variable. …
alfantp ff25e14
fixing build
alfantp 73dec9d
incorporating CR comments
alfantp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,13 +3,19 @@ | |
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from msrest.exceptions import ClientException | ||
| from azure.cli.core.util import CLIError | ||
|
|
||
| from azure.mgmt.redis.models import ( | ||
| ImportRDBParameters, | ||
| ExportRDBParameters, | ||
| RedisCreateOrUpdateParameters, | ||
| Sku, | ||
| ) | ||
|
|
||
| import azure.cli.core.azlogging as azlogging | ||
| logger = azlogging.get_az_logger(__name__) | ||
|
|
||
| def cli_redis_export(client, resource_group_name, name, prefix, container, file_format=None): | ||
| # pylint:disable=too-many-arguments | ||
| parameters = ExportRDBParameters(prefix, container, file_format) | ||
|
|
@@ -20,6 +26,8 @@ def cli_redis_import_method(client, resource_group_name, name, file_format, file | |
| return client.import_method(resource_group_name, name, files, parameters) | ||
|
|
||
| def cli_redis_update_settings(client, resource_group_name, name, redis_configuration): | ||
| logger.warning('This command is getting deprecated. Please use "redis update" command') | ||
|
|
||
| existing = client.get(resource_group_name, name) | ||
| existing.redis_configuration.update(redis_configuration) | ||
|
|
||
|
|
@@ -39,18 +47,46 @@ def cli_redis_update_settings(client, resource_group_name, name, redis_configura | |
| ) | ||
| return client.create_or_update(resource_group_name, name, parameters=update_params) | ||
|
|
||
| def cli_redis_create(client, resource_group_name, name, location, sku_name, # pylint:disable=too-many-arguments | ||
| sku_family, sku_capacity, tags=None, redis_configuration=None, | ||
| def cli_redis_update(instance, sku=None, vm_size=None): | ||
| if sku != None: | ||
| instance.sku.name = sku | ||
|
|
||
| if vm_size != None: | ||
| instance.sku.family = vm_size[0] | ||
| instance.sku.capacity = vm_size[1:] | ||
|
|
||
| update_params = RedisCreateOrUpdateParameters( | ||
| instance.location, | ||
| instance.sku, | ||
| instance.tags, | ||
| instance.redis_version, | ||
| instance.redis_configuration, | ||
| instance.enable_non_ssl_port, | ||
| instance.tenant_settings, | ||
| instance.shard_count, | ||
| instance.subnet_id, | ||
| instance.static_ip, | ||
| ) | ||
|
|
||
| return update_params | ||
|
|
||
| def wrong_vmsize_argument_exception_handler(ex): | ||
| # pylint:disable=line-too-long | ||
| if ("The value of the parameter 'properties.sku.family/properties.sku.capacity' is invalid" in format(ex)) or ("The value of the parameter 'properties.sku.family' is invalid" in format(ex)): | ||
| raise CLIError('Invalid VM size. Example for Valid values: For C family (C0, C1, C2, C3, C4, C5, C6), for P family (P1, P2, P3, P4)') | ||
| raise ex | ||
|
|
||
| def cli_redis_create(client, resource_group_name, name, location, sku, # pylint:disable=too-many-arguments | ||
| vm_size, tags=None, redis_configuration=None, | ||
| enable_non_ssl_port=None, tenant_settings=None, shard_count=None, | ||
| subnet_id=None, static_ip=None): | ||
| # pylint:disable=line-too-long | ||
| """Create new Redis Cache instance | ||
| :param resource_group_name: Name of resource group | ||
| :param name: Name of redis cache | ||
| :param location: Location | ||
| :param sku_name: What type of redis cache to deploy. Valid values: (Basic, Standard, Premium). | ||
| :param sku_family: Which family to use. Valid values: (C, P). | ||
| :param sku_capacity: What size of redis cache to deploy. Valid values for C family (0, 1, 2, 3, 4, 5, 6), for P family (1, 2, 3, 4) | ||
| :param sku: What type of redis cache to deploy. Valid values: (Basic, Standard, Premium). | ||
| :param vm_size: What size of redis cache to deploy. Valid values for C family (C0, C1, C2, C3, C4, C5, C6), for P family (P1, P2, P3, P4) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here, if you do like I suggest and parse the size, you will still need this so this is good. |
||
| :param redis_configuration: All Redis Settings. Few possible keys rdb-backup-enabled, rdb-storage-connection-string, rdb-backup-frequency, maxmemory-delta, maxmemory-policy, notify-keyspace-events, maxmemory-samples, slowlog-log-slower-than, slowlog-max-len, list-max-ziplist-entries, list-max-ziplist-value, hash-max-ziplist-entries, hash-max-ziplist-value, set-max-intset-entries, zset-max-ziplist-entries, zset-max-ziplist-value etc. | ||
| :param enable_non_ssl_port: If the value is true, then the non-ssl redis server port (6379) will be enabled. | ||
| :param tenant_settings: Json dictionary with tenant settings | ||
|
|
@@ -60,7 +96,7 @@ def cli_redis_create(client, resource_group_name, name, location, sku_name, # py | |
| """ | ||
| params = RedisCreateOrUpdateParameters( | ||
| location, | ||
| Sku(sku_name, sku_family, sku_capacity), | ||
| Sku(sku, vm_size[0], vm_size[1:]), | ||
| tags, | ||
| None, # Version is deprecated and ignored | ||
| redis_configuration, | ||
|
|
@@ -70,5 +106,7 @@ def cli_redis_create(client, resource_group_name, name, location, sku_name, # py | |
| subnet_id, | ||
| static_ip) | ||
|
|
||
| return client.create_or_update(resource_group_name, name, params) | ||
|
|
||
| try: | ||
| return client.create_or_update(resource_group_name, name, params) | ||
| except ClientException as err: | ||
| wrong_vmsize_argument_exception_handler(err) | ||
176 changes: 176 additions & 0 deletions
176
src/command_modules/azure-cli-redis/tests/recordings/test_create_redis_cache.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| interactions: | ||
| - request: | ||
| body: '{"location": "westus", "tags": {"use": "az-test"}}' | ||
| headers: | ||
| Accept: [application/json] | ||
| Accept-Encoding: ['gzip, deflate'] | ||
| CommandName: [group create] | ||
| Connection: [keep-alive] | ||
| Content-Length: ['50'] | ||
| Content-Type: [application/json; charset=utf-8] | ||
| User-Agent: [python/3.6.1 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 | ||
| msrest_azure/0.4.7 resourcemanagementclient/0.30.2 Azure-SDK-For-Python | ||
| AZURECLI/2.0.2+dev] | ||
| accept-language: [en-US] | ||
| method: PUT | ||
| uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001?api-version=2016-09-01 | ||
| response: | ||
| body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001","name":"clitest.rg000001","location":"westus","tags":{"use":"az-test"},"properties":{"provisioningState":"Succeeded"}}'} | ||
| headers: | ||
| cache-control: [no-cache] | ||
| content-length: ['326'] | ||
| content-type: [application/json; charset=utf-8] | ||
| date: ['Thu, 13 Apr 2017 17:18:10 GMT'] | ||
| expires: ['-1'] | ||
| pragma: [no-cache] | ||
| strict-transport-security: [max-age=31536000; includeSubDomains] | ||
| x-ms-ratelimit-remaining-subscription-writes: ['1199'] | ||
| status: {code: 201, message: Created} | ||
| - request: | ||
| body: '{"location": "WestUS", "properties": {"sku": {"name": "Basic", "family": | ||
| "C", "capacity": 0}}}' | ||
| headers: | ||
| Accept: [application/json] | ||
| Accept-Encoding: ['gzip, deflate'] | ||
| CommandName: [redis create] | ||
| Connection: [keep-alive] | ||
| Content-Length: ['94'] | ||
| Content-Type: [application/json; charset=utf-8] | ||
| User-Agent: [python/3.6.1 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 | ||
| msrest_azure/0.4.7 redismanagementclient/1.0.0 Azure-SDK-For-Python AZURECLI/2.0.2+dev] | ||
| accept-language: [en-US] | ||
| method: PUT | ||
| uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Cache/Redis/cli000002?api-version=2016-04-01 | ||
| response: | ||
| body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Cache/Redis/cli000002","location":"West | ||
| US","name":"cli000002","type":"Microsoft.Cache/Redis","tags":{},"properties":{"provisioningState":"Creating","redisVersion":"3.2","sku":{"name":"Basic","family":"C","capacity":0},"enableNonSslPort":false,"redisConfiguration":{"maxclients":"256","maxmemory-reserved":"2","maxfragmentationmemory-reserved":"12","maxmemory-delta":"2"},"accessKeys":{"primaryKey":"lr7S+XpwKd7wmVgX60N9Ajz6RNPTf+0VlsPNaWXKUYY=","secondaryKey":"lakNGov3L8Ki919D/yxR1ATPCEl6TlQON5iaeqO4Eaw="},"hostName":"cli000002.redis.cache.windows.net","port":6379,"sslPort":6380}}'} | ||
| headers: | ||
| cache-control: [no-cache] | ||
| content-length: ['798'] | ||
| content-type: [application/json; charset=utf-8] | ||
| date: ['Thu, 13 Apr 2017 17:18:13 GMT'] | ||
| expires: ['-1'] | ||
| location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Cache/redis/cli000002?api-version=2016-04-01'] | ||
| pragma: [no-cache] | ||
| server: [Microsoft-HTTPAPI/2.0] | ||
| strict-transport-security: [max-age=31536000; includeSubDomains] | ||
| x-ms-ratelimit-remaining-subscription-writes: ['1199'] | ||
| x-rp-server-mvid: [5a0a88c0-0183-48c7-85e3-df64396b7fab] | ||
| status: {code: 201, message: Created} | ||
| - request: | ||
| body: null | ||
| headers: | ||
| Accept: [application/json] | ||
| Accept-Encoding: ['gzip, deflate'] | ||
| CommandName: [redis show] | ||
| Connection: [keep-alive] | ||
| Content-Type: [application/json; charset=utf-8] | ||
| User-Agent: [python/3.6.1 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 | ||
| msrest_azure/0.4.7 redismanagementclient/1.0.0 Azure-SDK-For-Python AZURECLI/2.0.2+dev] | ||
| accept-language: [en-US] | ||
| method: GET | ||
| uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Cache/Redis/cli000002?api-version=2016-04-01 | ||
| response: | ||
| body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Cache/Redis/cli000002","location":"West | ||
| US","name":"cli000002","type":"Microsoft.Cache/Redis","tags":{},"properties":{"provisioningState":"Creating","redisVersion":"3.2","sku":{"name":"Basic","family":"C","capacity":0},"enableNonSslPort":false,"redisConfiguration":{"maxclients":"256","maxmemory-reserved":"2","maxfragmentationmemory-reserved":"12","maxmemory-delta":"2"},"accessKeys":null,"hostName":"cli000002.redis.cache.windows.net","port":6379,"sslPort":6380}}'} | ||
| headers: | ||
| cache-control: [no-cache] | ||
| content-length: ['679'] | ||
| content-type: [application/json; charset=utf-8] | ||
| date: ['Thu, 13 Apr 2017 17:18:14 GMT'] | ||
| expires: ['-1'] | ||
| pragma: [no-cache] | ||
| server: [Microsoft-HTTPAPI/2.0] | ||
| strict-transport-security: [max-age=31536000; includeSubDomains] | ||
| transfer-encoding: [chunked] | ||
| vary: [Accept-Encoding] | ||
| x-rp-server-mvid: [5a0a88c0-0183-48c7-85e3-df64396b7fab] | ||
| status: {code: 200, message: OK} | ||
| - request: | ||
| body: null | ||
| headers: | ||
| Accept: [application/json] | ||
| Accept-Encoding: ['gzip, deflate'] | ||
| CommandName: [redis list] | ||
| Connection: [keep-alive] | ||
| Content-Type: [application/json; charset=utf-8] | ||
| User-Agent: [python/3.6.1 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 | ||
| msrest_azure/0.4.7 redismanagementclient/1.0.0 Azure-SDK-For-Python AZURECLI/2.0.2+dev] | ||
| accept-language: [en-US] | ||
| method: GET | ||
| uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Cache/Redis/?api-version=2016-04-01 | ||
| response: | ||
| body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Cache/Redis/cli000002","location":"West | ||
| US","name":"cli000002","type":"Microsoft.Cache/Redis","tags":{},"properties":{"provisioningState":"Creating","redisVersion":"3.2","sku":{"name":"Basic","family":"C","capacity":0},"enableNonSslPort":false,"redisConfiguration":{"maxclients":"256","maxmemory-reserved":"2","maxfragmentationmemory-reserved":"12","maxmemory-delta":"2"},"accessKeys":null,"hostName":"cli000002.redis.cache.windows.net","port":6379,"sslPort":6380}}]}'} | ||
| headers: | ||
| cache-control: [no-cache] | ||
| content-length: ['691'] | ||
| content-type: [application/json; charset=utf-8] | ||
| date: ['Thu, 13 Apr 2017 17:18:15 GMT'] | ||
| expires: ['-1'] | ||
| pragma: [no-cache] | ||
| server: [Microsoft-HTTPAPI/2.0] | ||
| strict-transport-security: [max-age=31536000; includeSubDomains] | ||
| transfer-encoding: [chunked] | ||
| vary: [Accept-Encoding] | ||
| x-rp-server-mvid: [5a0a88c0-0183-48c7-85e3-df64396b7fab] | ||
| status: {code: 200, message: OK} | ||
| - request: | ||
| body: null | ||
| headers: | ||
| Accept: [application/json] | ||
| Accept-Encoding: ['gzip, deflate'] | ||
| CommandName: [redis list-keys] | ||
| Connection: [keep-alive] | ||
| Content-Length: ['0'] | ||
| Content-Type: [application/json; charset=utf-8] | ||
| User-Agent: [python/3.6.1 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 | ||
| msrest_azure/0.4.7 redismanagementclient/1.0.0 Azure-SDK-For-Python AZURECLI/2.0.2+dev] | ||
| accept-language: [en-US] | ||
| method: POST | ||
| uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Cache/Redis/cli000002/listKeys?api-version=2016-04-01 | ||
| response: | ||
| body: {string: '{"primaryKey":"lr7S+XpwKd7wmVgX60N9Ajz6RNPTf+0VlsPNaWXKUYY=","secondaryKey":"lakNGov3L8Ki919D/yxR1ATPCEl6TlQON5iaeqO4Eaw="}'} | ||
| headers: | ||
| cache-control: [no-cache] | ||
| content-length: ['123'] | ||
| content-type: [application/json; charset=utf-8] | ||
| date: ['Thu, 13 Apr 2017 17:18:17 GMT'] | ||
| expires: ['-1'] | ||
| pragma: [no-cache] | ||
| server: [Microsoft-HTTPAPI/2.0] | ||
| strict-transport-security: [max-age=31536000; includeSubDomains] | ||
| transfer-encoding: [chunked] | ||
| vary: [Accept-Encoding] | ||
| x-ms-ratelimit-remaining-subscription-writes: ['1199'] | ||
| x-rp-server-mvid: [5a0a88c0-0183-48c7-85e3-df64396b7fab] | ||
| status: {code: 200, message: OK} | ||
| - request: | ||
| body: null | ||
| headers: | ||
| Accept: [application/json] | ||
| Accept-Encoding: ['gzip, deflate'] | ||
| CommandName: [group delete] | ||
| Connection: [keep-alive] | ||
| Content-Length: ['0'] | ||
| Content-Type: [application/json; charset=utf-8] | ||
| User-Agent: [python/3.6.1 (Windows-10-10.0.14393-SP0) requests/2.9.1 msrest/0.4.7 | ||
| msrest_azure/0.4.7 resourcemanagementclient/0.30.2 Azure-SDK-For-Python | ||
| AZURECLI/2.0.2+dev] | ||
| accept-language: [en-US] | ||
| method: DELETE | ||
| uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001?api-version=2016-09-01 | ||
| response: | ||
| body: {string: ''} | ||
| headers: | ||
| cache-control: [no-cache] | ||
| content-length: ['0'] | ||
| date: ['Thu, 13 Apr 2017 17:18:18 GMT'] | ||
| expires: ['-1'] | ||
| location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTElURVNUOjJFUkc0NjQ5Qzc5M0FDODdGQzFGNkJENEQzRjRCNEQ4RENGODBEQ3w1Njg3QUMzOEYxM0I3RjBDLVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2016-09-01'] | ||
| pragma: [no-cache] | ||
| retry-after: ['15'] | ||
| strict-transport-security: [max-age=31536000; includeSubDomains] | ||
| x-ms-ratelimit-remaining-subscription-writes: ['1199'] | ||
| status: {code: 202, message: Accepted} | ||
| version: 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are using the **enum_choice_list, it will automatically list (and validate) the options, so you don't need this. If you run this command with -h you'll see the list essentially repeated twice.