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

{Redis} az redis update: Support --no-wait to avoid breaking change and default to True #30035

Merged
merged 7 commits into from
Oct 9, 2024
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
4 changes: 4 additions & 0 deletions src/azure-cli/azure/cli/command_modules/redis/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements
c.argument('name', arg_type=cache_name, id_part=None)
c.argument('mi_system_assigned', arg_type=system_identity_type)
c.argument('mi_user_assigned', arg_type=user_identity_type)

# hide --no-wait from customer usage, only use for functional tests to get LRO result
with self.argument_context('redis update') as c:
c.extra('no_wait', arg_type=get_three_state_flag(), help="Specify as false to wait for result of long running operation", deprecate_info=c.deprecate(hide=True))
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/redis/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def load_command_table(self, _):
g.command('list-keys', 'list_keys')
g.custom_command('regenerate-keys', 'cli_redis_regenerate_key')
g.show_command('show', 'get')
g.generic_update_command('update', setter_name='custom_update_setter', setter_type=redis_operations_custom, custom_func_name='cli_redis_update')
g.generic_update_command('update', setter_name='custom_update_setter', setter_type=redis_operations_custom, custom_func_name='cli_redis_update', supports_no_wait=True)
g.command('flush', 'begin_flush_cache', confirmation=True)

with self.command_group('redis patch-schedule', redis_patch, custom_command_type=redis_patch_schedules_custom) as g:
Expand Down
7 changes: 5 additions & 2 deletions src/azure-cli/azure/cli/command_modules/redis/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from knack.log import get_logger
from knack.util import CLIError
from azure.cli.command_modules.redis._client_factory import cf_redis
from azure.cli.core.util import sdk_no_wait

logger = get_logger(__name__)

Expand Down Expand Up @@ -80,9 +81,11 @@ def cli_redis_update(cmd, instance, sku=None, vm_size=None):
return update_params


def custom_update_setter(client, resource_group_name, name, parameters):
def custom_update_setter(client, resource_group_name, name, parameters, no_wait=True):
if no_wait is None:
no_wait = True
# Custom update setter is used to match behavior from when update was not a LRO
return client.begin_update(resource_group_name, name, parameters).result(0)
return sdk_no_wait(no_wait, client.begin_update, resource_group_name, name, parameters)


# pylint: disable=unused-argument
Expand Down

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.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import time
import datetime

location = 'WestUS'
location = 'WestEurope'
seclocation = 'EastUS'
premium_sku = 'Premium'
basic_sku = 'Basic'
Expand Down Expand Up @@ -201,26 +201,17 @@ def test_redis_cache_authentication(self, resource_group):
self.assertTrue(len(result) == 3)

# Enable access keys on cache and verify
self.cmd('az redis update -n {name} -g {rg} --set "disableAccessKeyAuthentication=false"')
if self.is_live:
time.sleep(30)
self.cmd('az redis update -n {name} -g {rg} --set "disableAccessKeyAuthentication=false" --no-wait false')
result = self.cmd('az redis show -n {name} -g {rg}').get_output_in_json()
self.assertFalse(result['disableAccessKeyAuthentication'])

# Commenting out due to issues with tearing down test for update (need to provide exact sleep time for lro to complete)
"""
# Disable aad on cache
self.cmd('az redis update -n {name} -g {rg} --set redisConfiguration.aadEnabled=false --no-wait False')
self.cmd('az redis update -n {name} -g {rg} --set redisConfiguration.aadEnabled=false --no-wait false')
result = self.cmd('az redis show -n {name} -g {rg}').get_output_in_json()

# Verify cache is aad disabled
if self.is_live:
while result['provisioningState'] == 'ConfiguringAAD':
result = self.cmd('az redis show -n {name} -g {rg}').get_output_in_json()
time.sleep(1)
self.assertTrue(result['provisioningState'] == 'Succeeded')
self.assertTrue(result['redisConfiguration']['aadEnabled'] == "False")
"""
assert result['provisioningState'] == 'Succeeded'
assert result['redisConfiguration']['aadEnabled'].lower() == "false"


@ResourceGroupPreparer(name_prefix='cli_test_redis')
Expand All @@ -242,7 +233,6 @@ def test_redis_cache_list_keys(self, resource_group):
result = self.cmd('az redis list-keys -n {name} -g {rg}').get_output_in_json()
self.assertTrue(result['primaryKey'] is not None)
self.assertTrue(result['secondaryKey'] is not None)
# TODO: self.cmd('az redis update -n {name} -g {rg} --set "tags.mytag=mytagval"')

@ResourceGroupPreparer(name_prefix='cli_test_redis')
def test_redis_cache_patch_schedule(self, resource_group):
Expand Down Expand Up @@ -408,7 +398,7 @@ def test_redis_cache_regenerate_key_update_tags(self, resource_group):

self.cmd('az redis regenerate-keys -n {name} -g {rg} --key-type Primary')
self.cmd('az redis regenerate-keys -n {name} -g {rg} --key-type Secondary')
# TODO: self.cmd('az redis update -n {name} -g {rg} --set "tags.mytag=mytagval"')
self.cmd('az redis update -n {name} -g {rg} --set "tags.mytag=mytagval" --no-wait false')
self.cmd('az redis delete -n {name} -g {rg} -y')

@ResourceGroupPreparer(name_prefix='cli_test_redis')
Expand All @@ -426,9 +416,7 @@ def test_redis_cache_managed_identity(self, resource_group):
self.check('length(identity.userAssignedIdentities)', 1)
])

# TODO: self.cmd('az redis update -n {name} -g {rg} --set "publicNetworkAccess=Disabled"')
if self.is_live:
time.sleep(5*60)
self.cmd('az redis update -n {name} -g {rg} --set "publicNetworkAccess=Disabled" --no-wait false')

self.cmd('az redis identity remove -n {name} -g {rg} --mi-system-assigned --mi-user-assigned "{userIdentity}"',checks=[
self.check('type', 'None')
Expand Down Expand Up @@ -561,10 +549,10 @@ def test_redis_cache_update(self, resource_group):
self.cmd('az redis create -n {name} -g {rg} -l {location} --sku {sku} --vm-size {size}')
if self.is_live:
time.sleep(5*60)
# TODO: self.cmd('az redis update -n {name} -g {rg} --set "publicNetworkAccess=Disabled"')
if self.is_live:
time.sleep(5*60)
self.cmd('az redis create -n {name} -g {rg} -l {location} --sku {sku} --vm-size {size}')
self.cmd('az redis update -n {name} -g {rg} --set "publicNetworkAccess=Disabled" --no-wait false')

result = self.cmd('az redis show -n {name} -g {rg}').get_output_in_json()
assert result['publicNetworkAccess'] == 'Disabled'

@ResourceGroupPreparer(name_prefix='cli_test_redis')
def test_redis_cache_flush(self, resource_group):
Expand Down Expand Up @@ -592,12 +580,9 @@ def test_redis_cache_update_channel(self, resource_group):
self.cmd('az redis create -n {name} -g {rg} -l {location} --sku {sku} --vm-size {size} --update-channel Preview')
if self.is_live:
time.sleep(5*60)
# Commenting out due to issues with tearing down test for update (need to provide exact sleep time for lro to complete)
'''
self.cmd('az redis update -n {name} -g {rg} --set "RedisVersion=6.0" "UpdateChannel=Preview"')
if self.is_live:
time.sleep(5*60)
'''

self.cmd('az redis update -n {name} -g {rg} --set "RedisVersion=6.0" "UpdateChannel=Preview" --no-wait false')

result = self.cmd('az redis show -n {name} -g {rg}').get_output_in_json()
assert result['updateChannel'] == 'Preview'