зеркало из https://github.com/Azure/azure-cli.git
Update flake8 setting and fix style violations
* Remove E126 escape * Remove E741 escape * Annotate the .flake8 file * Fixes style violation surfaced from escape removal
This commit is contained in:
Родитель
e86ef7d6c9
Коммит
63ee848d50
13
.flake8
13
.flake8
|
@ -2,10 +2,9 @@
|
|||
max-line-length = 120
|
||||
max-complexity = 10
|
||||
ignore =
|
||||
E126,
|
||||
E501,
|
||||
E722,
|
||||
E741,
|
||||
F401,
|
||||
F811,
|
||||
C901
|
||||
E501, # line too long, it is covered by pylint
|
||||
E722, # bare except, bad practice, to be removed in the future
|
||||
F401, # imported but unused, too many violations, to be removed in the future
|
||||
F811, # redefinition of unused, to be removed in the future
|
||||
C901 # code flow is too complex, too many violations, to be removed in the future
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ def _option_descriptions(operation):
|
|||
lines = lines.splitlines()
|
||||
index = 0
|
||||
while index < len(lines):
|
||||
l = lines[index]
|
||||
line = lines[index]
|
||||
regex = r'\s*(:param)\s+(.+?)\s*:(.*)'
|
||||
match = re.search(regex, l)
|
||||
match = re.search(regex, line)
|
||||
if not match:
|
||||
index += 1
|
||||
continue
|
||||
|
|
|
@ -13,8 +13,8 @@ from azure.cli.core._config import GLOBAL_CONFIG_DIR
|
|||
|
||||
|
||||
_CUSTOM_EXT_DIR = os.environ.get('AZURE_EXTENSION_DIR')
|
||||
EXTENSIONS_DIR = os.path.expanduser(_CUSTOM_EXT_DIR) if _CUSTOM_EXT_DIR \
|
||||
else os.path.join(GLOBAL_CONFIG_DIR, 'cliextensions')
|
||||
EXTENSIONS_DIR = os.path.expanduser(_CUSTOM_EXT_DIR) if _CUSTOM_EXT_DIR else os.path.join(GLOBAL_CONFIG_DIR,
|
||||
'cliextensions')
|
||||
EXTENSIONS_MOD_PREFIX = 'azext_'
|
||||
|
||||
WHL_METADATA_FILENAME = 'metadata.json'
|
||||
|
|
|
@ -25,13 +25,12 @@ class AcrCommandsTests(ScenarioTest):
|
|||
resource_group_location,
|
||||
'Classic',
|
||||
'Microsoft.ContainerRegistry'),
|
||||
checks=[
|
||||
JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', resource_group_location),
|
||||
JMESPathCheck('adminUserEnabled', False),
|
||||
JMESPathCheck('sku.name', 'Classic'),
|
||||
JMESPathCheck('sku.tier', 'Classic'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
checks=[JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', resource_group_location),
|
||||
JMESPathCheck('adminUserEnabled', False),
|
||||
JMESPathCheck('sku.name', 'Classic'),
|
||||
JMESPathCheck('sku.tier', 'Classic'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
self._core_registry_scenario(registry_name, resource_group, resource_group_location,
|
||||
storage_account_for_update)
|
||||
|
||||
|
@ -43,21 +42,19 @@ class AcrCommandsTests(ScenarioTest):
|
|||
storage_account_for_create):
|
||||
registry_name = self.create_random_name('clireg', 20)
|
||||
|
||||
self.cmd('acr create -n {} -g {} -l {} --sku {} '
|
||||
'--storage-account-name {} --deployment-name {}'.format(
|
||||
registry_name,
|
||||
resource_group,
|
||||
resource_group_location,
|
||||
'Classic',
|
||||
storage_account_for_create,
|
||||
'Microsoft.ContainerRegistry'),
|
||||
checks=[
|
||||
JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', resource_group_location),
|
||||
JMESPathCheck('adminUserEnabled', False),
|
||||
JMESPathCheck('sku.name', 'Classic'),
|
||||
JMESPathCheck('sku.tier', 'Classic'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
self.cmd('acr create -n {} -g {} -l {} --sku {} --storage-account-name {} --deployment-name {}'.format(
|
||||
registry_name,
|
||||
resource_group,
|
||||
resource_group_location,
|
||||
'Classic',
|
||||
storage_account_for_create,
|
||||
'Microsoft.ContainerRegistry'),
|
||||
checks=[JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', resource_group_location),
|
||||
JMESPathCheck('adminUserEnabled', False),
|
||||
JMESPathCheck('sku.name', 'Classic'),
|
||||
JMESPathCheck('sku.tier', 'Classic'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
|
||||
self._core_registry_scenario(registry_name, resource_group, resource_group_location,
|
||||
storage_account_for_update)
|
||||
|
@ -72,13 +69,12 @@ class AcrCommandsTests(ScenarioTest):
|
|||
resource_group_location,
|
||||
'Standard',
|
||||
'Microsoft.ContainerRegistry'),
|
||||
checks=[
|
||||
JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', resource_group_location),
|
||||
JMESPathCheck('adminUserEnabled', False),
|
||||
JMESPathCheck('sku.name', 'Standard'),
|
||||
JMESPathCheck('sku.tier', 'Standard'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
checks=[JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', resource_group_location),
|
||||
JMESPathCheck('adminUserEnabled', False),
|
||||
JMESPathCheck('sku.name', 'Standard'),
|
||||
JMESPathCheck('sku.tier', 'Standard'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
|
||||
self._core_registry_scenario(registry_name, resource_group, resource_group_location)
|
||||
|
||||
|
@ -93,58 +89,57 @@ class AcrCommandsTests(ScenarioTest):
|
|||
resource_group_location,
|
||||
'Standard',
|
||||
'Microsoft.ContainerRegistry'),
|
||||
checks=[
|
||||
JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', resource_group_location),
|
||||
JMESPathCheck('adminUserEnabled', False),
|
||||
JMESPathCheck('sku.name', 'Standard'),
|
||||
JMESPathCheck('sku.tier', 'Standard'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
checks=[
|
||||
JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', resource_group_location),
|
||||
JMESPathCheck('adminUserEnabled', False),
|
||||
JMESPathCheck('sku.name', 'Standard'),
|
||||
JMESPathCheck('sku.tier', 'Standard'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
|
||||
self.cmd('acr webhook create -n {} -r {} --uri {} --actions {}'.format(
|
||||
webhook_name,
|
||||
registry_name,
|
||||
'http://www.microsoft.com',
|
||||
'push'),
|
||||
checks=[
|
||||
JMESPathCheck('name', webhook_name),
|
||||
JMESPathCheck('location', resource_group_location),
|
||||
JMESPathCheck('status', 'enabled'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
checks=[JMESPathCheck('name', webhook_name),
|
||||
JMESPathCheck('location', resource_group_location),
|
||||
JMESPathCheck('status', 'enabled'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
|
||||
self.cmd('acr webhook list -r {}'.format(registry_name), checks=[
|
||||
JMESPathCheck('[0].name', webhook_name),
|
||||
JMESPathCheck('[0].status', 'enabled'),
|
||||
JMESPathCheck('[0].provisioningState', 'Succeeded')])
|
||||
self.cmd('acr webhook show -n {} -r {}'.format(webhook_name, registry_name), checks=[
|
||||
JMESPathCheck('name', webhook_name),
|
||||
JMESPathCheck('status', 'enabled'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
self.cmd('acr webhook list -r {}'.format(registry_name),
|
||||
checks=[JMESPathCheck('[0].name', webhook_name),
|
||||
JMESPathCheck('[0].status', 'enabled'),
|
||||
JMESPathCheck('[0].provisioningState', 'Succeeded')])
|
||||
self.cmd('acr webhook show -n {} -r {}'.format(webhook_name, registry_name),
|
||||
checks=[JMESPathCheck('name', webhook_name),
|
||||
JMESPathCheck('status', 'enabled'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
|
||||
# update webhook
|
||||
self.cmd('acr webhook update -n {} -r {} --headers {} --scope {}'.format(
|
||||
webhook_name, registry_name, 'key=value', 'hello-world'), checks=[
|
||||
JMESPathCheck('name', webhook_name),
|
||||
JMESPathCheck('status', 'enabled'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded'),
|
||||
JMESPathCheck('scope', 'hello-world')])
|
||||
webhook_name, registry_name, 'key=value', 'hello-world'),
|
||||
checks=[JMESPathCheck('name', webhook_name),
|
||||
JMESPathCheck('status', 'enabled'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded'),
|
||||
JMESPathCheck('scope', 'hello-world')])
|
||||
|
||||
# get webhook config
|
||||
self.cmd('acr webhook get-config -n {} -r {}'.format(webhook_name, registry_name), checks=[
|
||||
JMESPathCheck('serviceUri', 'http://www.microsoft.com'),
|
||||
JMESPathCheck('customHeaders', {'key': 'value'})])
|
||||
self.cmd('acr webhook get-config -n {} -r {}'.format(webhook_name, registry_name),
|
||||
checks=[JMESPathCheck('serviceUri', 'http://www.microsoft.com'),
|
||||
JMESPathCheck('customHeaders', {'key': 'value'})])
|
||||
# ping
|
||||
self.cmd('acr webhook ping -n {} -r {}'.format(webhook_name, registry_name), checks=[
|
||||
JMESPathCheckExists('id')])
|
||||
self.cmd('acr webhook ping -n {} -r {}'.format(webhook_name, registry_name),
|
||||
checks=[JMESPathCheckExists('id')])
|
||||
# list webhook events
|
||||
self.cmd('acr webhook list-events -n {} -r {}'.format(webhook_name, registry_name))
|
||||
|
||||
# get registry usage
|
||||
self.cmd('acr show-usage -n {} -g {}'.format(registry_name, resource_group), checks=[
|
||||
JMESPathCheck('value[?name==`Size`]|[0].currentValue', 0),
|
||||
JMESPathCheckGreaterThan('value[?name==`Size`]|[0].limit', 0),
|
||||
JMESPathCheck('value[?name==`Webhooks`]|[0].currentValue', 1),
|
||||
JMESPathCheckGreaterThan('value[?name==`Webhooks`]|[0].limit', 0)])
|
||||
self.cmd('acr show-usage -n {} -g {}'.format(registry_name, resource_group),
|
||||
checks=[JMESPathCheck('value[?name==`Size`]|[0].currentValue', 0),
|
||||
JMESPathCheckGreaterThan('value[?name==`Size`]|[0].limit', 0),
|
||||
JMESPathCheck('value[?name==`Webhooks`]|[0].currentValue', 1),
|
||||
JMESPathCheckGreaterThan('value[?name==`Webhooks`]|[0].limit', 0)])
|
||||
|
||||
# test webhook delete
|
||||
self.cmd('acr webhook delete -n {} -r {}'.format(webhook_name, registry_name))
|
||||
|
@ -164,36 +159,34 @@ class AcrCommandsTests(ScenarioTest):
|
|||
resource_group_location,
|
||||
'Premium',
|
||||
'Microsoft.ContainerRegistry'),
|
||||
checks=[
|
||||
JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', resource_group_location),
|
||||
JMESPathCheck('adminUserEnabled', False),
|
||||
JMESPathCheck('sku.name', 'Premium'),
|
||||
JMESPathCheck('sku.tier', 'Premium'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
checks=[JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', resource_group_location),
|
||||
JMESPathCheck('adminUserEnabled', False),
|
||||
JMESPathCheck('sku.name', 'Premium'),
|
||||
JMESPathCheck('sku.tier', 'Premium'),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
|
||||
self.cmd('acr replication create -n {} -r {} -l {}'.format(
|
||||
replication_name,
|
||||
registry_name,
|
||||
replication_location),
|
||||
checks=[
|
||||
JMESPathCheck('name', replication_name),
|
||||
JMESPathCheck('location', replication_location),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
checks=[
|
||||
JMESPathCheck('name', replication_name),
|
||||
JMESPathCheck('location', replication_location),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
|
||||
self.cmd('acr replication list -r {}'.format(registry_name), checks=[
|
||||
JMESPathCheck('[0].provisioningState', 'Succeeded'),
|
||||
JMESPathCheck('[1].provisioningState', 'Succeeded')])
|
||||
self.cmd('acr replication show -n {} -r {}'.format(replication_name, registry_name), checks=[
|
||||
JMESPathCheck('name', replication_name),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
self.cmd('acr replication list -r {}'.format(registry_name),
|
||||
checks=[JMESPathCheck('[0].provisioningState', 'Succeeded'),
|
||||
JMESPathCheck('[1].provisioningState', 'Succeeded')])
|
||||
self.cmd('acr replication show -n {} -r {}'.format(replication_name, registry_name),
|
||||
checks=[JMESPathCheck('name', replication_name),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
|
||||
# update replication
|
||||
self.cmd('acr replication update -n {} -r {} --tags {}'.format(
|
||||
replication_name, registry_name, 'key=value'), checks=[
|
||||
JMESPathCheck('name', replication_name),
|
||||
JMESPathCheck('provisioningState', 'Succeeded'),
|
||||
JMESPathCheck('tags', {'key': 'value'})])
|
||||
replication_name, registry_name, 'key=value'), checks=[JMESPathCheck('name', replication_name),
|
||||
JMESPathCheck('provisioningState', 'Succeeded'),
|
||||
JMESPathCheck('tags', {'key': 'value'})])
|
||||
|
||||
# test replication delete
|
||||
self.cmd('acr replication delete -n {} -r {}'.format(replication_name, registry_name))
|
||||
|
@ -202,31 +195,29 @@ class AcrCommandsTests(ScenarioTest):
|
|||
|
||||
def _core_registry_scenario(self, registry_name, resource_group, location,
|
||||
storage_account_for_update=None):
|
||||
self.cmd('acr check-name -n {}'.format(registry_name), checks=[
|
||||
JMESPathCheck('nameAvailable', False),
|
||||
JMESPathCheck('reason', 'AlreadyExists')])
|
||||
self.cmd('acr list -g {}'.format(resource_group), checks=[
|
||||
JMESPathCheck('[0].name', registry_name),
|
||||
JMESPathCheck('[0].location', location),
|
||||
JMESPathCheck('[0].adminUserEnabled', False)])
|
||||
self.cmd('acr show -n {} -g {}'.format(
|
||||
registry_name, resource_group), checks=[
|
||||
JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', location),
|
||||
JMESPathCheck('adminUserEnabled', False)])
|
||||
self.cmd('acr check-name -n {}'.format(registry_name),
|
||||
checks=[JMESPathCheck('nameAvailable', False),
|
||||
JMESPathCheck('reason', 'AlreadyExists')])
|
||||
self.cmd('acr list -g {}'.format(resource_group),
|
||||
checks=[JMESPathCheck('[0].name', registry_name),
|
||||
JMESPathCheck('[0].location', location),
|
||||
JMESPathCheck('[0].adminUserEnabled', False)])
|
||||
self.cmd('acr show -n {} -g {}'.format(registry_name, resource_group),
|
||||
checks=[JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', location),
|
||||
JMESPathCheck('adminUserEnabled', False)])
|
||||
|
||||
# enable admin user
|
||||
self.cmd('acr update -n {} -g {} --tags foo=bar cat --admin-enabled true'.format(
|
||||
registry_name, resource_group), checks=[
|
||||
JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', location),
|
||||
JMESPathCheck('tags', {'cat': '', 'foo': 'bar'}),
|
||||
JMESPathCheck('adminUserEnabled', True),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
self.cmd('acr update -n {} -g {} --tags foo=bar cat --admin-enabled true'.format(registry_name, resource_group),
|
||||
checks=[JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', location),
|
||||
JMESPathCheck('tags', {'cat': '', 'foo': 'bar'}),
|
||||
JMESPathCheck('adminUserEnabled', True),
|
||||
JMESPathCheck('provisioningState', 'Succeeded')])
|
||||
|
||||
# test credential module
|
||||
credential = self.cmd('acr credential show -n {} -g {}'.format(
|
||||
registry_name, resource_group)).get_output_in_json()
|
||||
credential = self.cmd(
|
||||
'acr credential show -n {} -g {}'.format(registry_name, resource_group)).get_output_in_json()
|
||||
username = credential['username']
|
||||
password = credential['passwords'][0]['value']
|
||||
password2 = credential['passwords'][1]['value']
|
||||
|
@ -258,9 +249,8 @@ class AcrCommandsTests(ScenarioTest):
|
|||
if storage_account_for_update is not None:
|
||||
self.cmd('acr update -n {} -g {} --storage-account-name {}'.format(
|
||||
registry_name, resource_group, storage_account_for_update),
|
||||
checks=[
|
||||
JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', location)])
|
||||
checks=[JMESPathCheck('name', registry_name),
|
||||
JMESPathCheck('location', location)])
|
||||
|
||||
# test acr delete
|
||||
self.cmd('acr delete -n {} -g {}'.format(registry_name, resource_group))
|
||||
|
|
|
@ -210,19 +210,16 @@ class AppServicePlanScenarioTest(ScenarioTest):
|
|||
plan = 'webapp-delete-plan2'
|
||||
self.cmd('appservice plan create -g {} -n {} -l westus'.format(resource_group, plan))
|
||||
|
||||
self.cmd('appservice plan update -g {} -n {} --sku S1'.format(resource_group, plan), checks=[
|
||||
JMESPathCheckV2('name', plan),
|
||||
JMESPathCheckV2('sku.tier', 'Standard'),
|
||||
JMESPathCheckV2('sku.name', 'S1')
|
||||
])
|
||||
self.cmd('appservice plan update -g {} -n {} --sku S1'.format(resource_group, plan),
|
||||
checks=[JMESPathCheckV2('name', plan),
|
||||
JMESPathCheckV2('sku.tier', 'Standard'),
|
||||
JMESPathCheckV2('sku.name', 'S1')])
|
||||
|
||||
self.cmd('webapp create -g {} -n {} --plan {}'.format(resource_group, webapp_name, plan))
|
||||
|
||||
self.cmd('webapp delete -g {} -n {}'.format(resource_group, webapp_name))
|
||||
# test empty service plan should be automatically deleted.
|
||||
self.cmd('appservice plan list -g {}'.format(resource_group), checks=[
|
||||
JMESPathCheckV2('length(@)', 0)
|
||||
])
|
||||
self.cmd('appservice plan list -g {}'.format(resource_group), checks=[JMESPathCheckV2('length(@)', 0)])
|
||||
|
||||
|
||||
class WebappConfigureTest(ScenarioTest):
|
||||
|
|
|
@ -52,8 +52,8 @@ class VstsContinuousDeliveryProvider(object):
|
|||
message = '{: >3.0f}% complete: {}'.format(percent_done, status)
|
||||
# Erase the previous message
|
||||
# (backspace to beginning, space over the text and backspace again)
|
||||
l = len(self._progress_last_message)
|
||||
print('\b' * l + ' ' * l + '\b' * l, end='', file=stderr)
|
||||
msg_len = len(self._progress_last_message)
|
||||
print('\b' * msg_len + ' ' * msg_len + '\b' * msg_len, end='', file=stderr)
|
||||
print(message, end='', file=stderr)
|
||||
self._progress_last_message = message
|
||||
stderr.flush()
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
# --------------------------------------------------------------------------------------------
|
||||
# pylint: disable=line-too-long,too-many-statements
|
||||
# pylint: disable=too-many-statements
|
||||
|
||||
from azure.cli.testsdk.vcr_test_base import \
|
||||
ResourceGroupVCRTestBase, JMESPathCheck, JMESPathPatternCheck, NoneCheck
|
||||
from azure.cli.testsdk.vcr_test_base import (ResourceGroupVCRTestBase, JMESPathCheck, JMESPathPatternCheck, NoneCheck)
|
||||
|
||||
|
||||
class IoTHubTest(ResourceGroupVCRTestBase):
|
||||
|
@ -25,15 +24,14 @@ class IoTHubTest(ResourceGroupVCRTestBase):
|
|||
|
||||
# Test 'az iot hub create'
|
||||
self.cmd('iot hub create -n {0} -g {1} --sku S1'.format(hub, rg),
|
||||
checks=[
|
||||
JMESPathCheck('resourceGroup', rg),
|
||||
JMESPathCheck('location', location),
|
||||
JMESPathCheck('name', hub),
|
||||
JMESPathCheck('sku.name', 'S1')
|
||||
])
|
||||
checks=[JMESPathCheck('resourceGroup', rg),
|
||||
JMESPathCheck('location', location),
|
||||
JMESPathCheck('name', hub),
|
||||
JMESPathCheck('sku.name', 'S1')])
|
||||
|
||||
# Test 'az iot hub show-connection-string'
|
||||
conn_str_pattern = r'^HostName={0}\.azure-devices\.net;SharedAccessKeyName=iothubowner;SharedAccessKey='.format(hub)
|
||||
conn_str_pattern = r'^HostName={0}\.azure-devices\.net;SharedAccessKeyName=iothubowner;SharedAccessKey='.format(
|
||||
hub)
|
||||
self.cmd('iot hub show-connection-string -n {0}'.format(hub), checks=[
|
||||
JMESPathPatternCheck('connectionString', conn_str_pattern)
|
||||
])
|
||||
|
@ -48,13 +46,11 @@ class IoTHubTest(ResourceGroupVCRTestBase):
|
|||
property_to_update = 'properties.operationsMonitoringProperties.events.DeviceTelemetry'
|
||||
updated_value = 'Error, Information'
|
||||
self.cmd('iot hub update -n {0} --set {1}="{2}"'.format(hub, property_to_update, updated_value),
|
||||
checks=[
|
||||
JMESPathCheck('resourceGroup', rg),
|
||||
JMESPathCheck('location', location),
|
||||
JMESPathCheck('name', hub),
|
||||
JMESPathCheck('sku.name', 'S1'),
|
||||
JMESPathCheck(property_to_update, updated_value)
|
||||
])
|
||||
checks=[JMESPathCheck('resourceGroup', rg),
|
||||
JMESPathCheck('location', location),
|
||||
JMESPathCheck('name', hub),
|
||||
JMESPathCheck('sku.name', 'S1'),
|
||||
JMESPathCheck(property_to_update, updated_value)])
|
||||
|
||||
# Test 'az iot hub show'
|
||||
self.cmd('iot hub show -n {0}'.format(hub), checks=[
|
||||
|
@ -149,28 +145,24 @@ class IoTHubTest(ResourceGroupVCRTestBase):
|
|||
# Test 'az iot device create'
|
||||
device_1 = self.device_id_1
|
||||
self.cmd('iot device create --hub-name {0} -d {1}'.format(hub, device_1),
|
||||
checks=[
|
||||
JMESPathCheck('deviceId', device_1),
|
||||
JMESPathCheck('status', 'enabled'),
|
||||
JMESPathCheck('statusReason', None),
|
||||
JMESPathCheck('connectionState', 'Disconnected')
|
||||
])
|
||||
checks=[JMESPathCheck('deviceId', device_1),
|
||||
JMESPathCheck('status', 'enabled'),
|
||||
JMESPathCheck('statusReason', None),
|
||||
JMESPathCheck('connectionState', 'Disconnected')])
|
||||
|
||||
device_2 = self.device_id_2
|
||||
primary_thumbprint = 'A361EA6A7119A8B0B7BBFFA2EAFDAD1F9D5BED8C'
|
||||
secondary_thumbprint = '14963E8F3BA5B3984110B3C1CA8E8B8988599087'
|
||||
self.cmd('iot device create --hub-name {0} -d {1} --x509 --primary-thumbprint {2} --secondary-thumbprint {3}'
|
||||
.format(hub, device_2, primary_thumbprint, secondary_thumbprint),
|
||||
checks=[
|
||||
JMESPathCheck('deviceId', device_2),
|
||||
JMESPathCheck('status', 'enabled'),
|
||||
JMESPathCheck('statusReason', None),
|
||||
JMESPathCheck('connectionState', 'Disconnected'),
|
||||
JMESPathCheck('authentication.symmetricKey.primaryKey', None),
|
||||
JMESPathCheck('authentication.symmetricKey.secondaryKey', None),
|
||||
JMESPathCheck('authentication.x509Thumbprint.primaryThumbprint', primary_thumbprint),
|
||||
JMESPathCheck('authentication.x509Thumbprint.secondaryThumbprint', secondary_thumbprint),
|
||||
])
|
||||
checks=[JMESPathCheck('deviceId', device_2),
|
||||
JMESPathCheck('status', 'enabled'),
|
||||
JMESPathCheck('statusReason', None),
|
||||
JMESPathCheck('connectionState', 'Disconnected'),
|
||||
JMESPathCheck('authentication.symmetricKey.primaryKey', None),
|
||||
JMESPathCheck('authentication.symmetricKey.secondaryKey', None),
|
||||
JMESPathCheck('authentication.x509Thumbprint.primaryThumbprint', primary_thumbprint),
|
||||
JMESPathCheck('authentication.x509Thumbprint.secondaryThumbprint', secondary_thumbprint)])
|
||||
|
||||
# Test 'az iot device show-connection-string'
|
||||
conn_str_pattern = r'^HostName={0}\.azure-devices\.net;DeviceId={1};SharedAccessKey='.format(hub, device_1)
|
||||
|
@ -209,15 +201,13 @@ class IoTHubTest(ResourceGroupVCRTestBase):
|
|||
JMESPathCheck('authentication.symmetricKey.primaryKey', None),
|
||||
JMESPathCheck('authentication.symmetricKey.secondaryKey', None),
|
||||
JMESPathCheck('authentication.x509Thumbprint.primaryThumbprint', primary_thumbprint),
|
||||
JMESPathCheck('authentication.x509Thumbprint.secondaryThumbprint', secondary_thumbprint),
|
||||
])
|
||||
JMESPathCheck('authentication.x509Thumbprint.secondaryThumbprint', secondary_thumbprint)])
|
||||
|
||||
# Test 'az iot device list'
|
||||
self.cmd('iot device list --hub-name {0}'.format(hub), checks=[
|
||||
JMESPathCheck('length([*])', 2),
|
||||
JMESPathPatternCheck('[0].deviceId', device_id_pattern),
|
||||
JMESPathPatternCheck('[1].deviceId', device_id_pattern)
|
||||
])
|
||||
self.cmd('iot device list --hub-name {0}'.format(hub),
|
||||
checks=[JMESPathCheck('length([*])', 2),
|
||||
JMESPathPatternCheck('[0].deviceId', device_id_pattern),
|
||||
JMESPathPatternCheck('[1].deviceId', device_id_pattern)])
|
||||
|
||||
# Test 'az iot device message send'
|
||||
self.cmd('iot device message send --hub-name {0} -d {1}'.format(hub, device_1), checks=NoneCheck())
|
||||
|
|
|
@ -1113,58 +1113,56 @@ class NetworkNicScenarioTest(ScenarioTest):
|
|||
# create with minimum parameters
|
||||
self.cmd('network nic create -g {} -n {} --subnet {} --vnet-name {}'.format(rg, nic, subnet, vnet), checks=[
|
||||
JMESPathCheckV2('NewNIC.ipConfigurations[0].privateIpAllocationMethod', 'Dynamic'),
|
||||
JMESPathCheckV2('NewNIC.provisioningState', 'Succeeded')
|
||||
])
|
||||
JMESPathCheckV2('NewNIC.provisioningState', 'Succeeded')])
|
||||
|
||||
# exercise optional parameters
|
||||
self.cmd('network nic create -g {} -n {} --subnet {} --ip-forwarding --private-ip-address {} --public-ip-address {} --internal-dns-name test --dns-servers 100.1.2.3 --lb-address-pools {} --lb-inbound-nat-rules {}'.format(rg, nic, subnet_id, private_ip, public_ip_name, address_pool_ids, rule_ids), checks=[
|
||||
JMESPathCheckV2('NewNIC.ipConfigurations[0].privateIpAllocationMethod', 'Static'),
|
||||
JMESPathCheckV2('NewNIC.ipConfigurations[0].privateIpAddress', private_ip),
|
||||
JMESPathCheckV2('NewNIC.enableIpForwarding', True),
|
||||
JMESPathCheckV2('NewNIC.provisioningState', 'Succeeded'),
|
||||
JMESPathCheckV2('NewNIC.dnsSettings.internalDnsNameLabel', 'test'),
|
||||
JMESPathCheckV2('length(NewNIC.dnsSettings.dnsServers)', 1)
|
||||
])
|
||||
self.cmd('network nic create -g {} -n {} --subnet {} --ip-forwarding --private-ip-address {} --public-ip-address {} --internal-dns-name test --dns-servers 100.1.2.3 --lb-address-pools {} --lb-inbound-nat-rules {}'.format(rg, nic, subnet_id, private_ip, public_ip_name, address_pool_ids, rule_ids),
|
||||
checks=[JMESPathCheckV2('NewNIC.ipConfigurations[0].privateIpAllocationMethod', 'Static'),
|
||||
JMESPathCheckV2('NewNIC.ipConfigurations[0].privateIpAddress', private_ip),
|
||||
JMESPathCheckV2('NewNIC.enableIpForwarding', True),
|
||||
JMESPathCheckV2('NewNIC.provisioningState', 'Succeeded'),
|
||||
JMESPathCheckV2('NewNIC.dnsSettings.internalDnsNameLabel', 'test'),
|
||||
JMESPathCheckV2('length(NewNIC.dnsSettings.dnsServers)', 1)])
|
||||
|
||||
# exercise creating with NSG
|
||||
self.cmd('network nic create -g {} -n {} --subnet {} --vnet-name {} --network-security-group {}'.format(rg, nic, subnet, vnet, nsg), checks=[
|
||||
JMESPathCheckV2('NewNIC.ipConfigurations[0].privateIpAllocationMethod', 'Dynamic'),
|
||||
JMESPathCheckV2('NewNIC.enableIpForwarding', False),
|
||||
JMESPathCheckV2("NewNIC.networkSecurityGroup.contains(id, '{}')".format(nsg), True),
|
||||
JMESPathCheckV2('NewNIC.provisioningState', 'Succeeded')
|
||||
])
|
||||
self.cmd('network nic create -g {} -n {} --subnet {} --vnet-name {} --network-security-group {}'.format(rg, nic, subnet, vnet, nsg),
|
||||
checks=[JMESPathCheckV2('NewNIC.ipConfigurations[0].privateIpAllocationMethod', 'Dynamic'),
|
||||
JMESPathCheckV2('NewNIC.enableIpForwarding', False),
|
||||
JMESPathCheckV2("NewNIC.networkSecurityGroup.contains(id, '{}')".format(nsg), True),
|
||||
JMESPathCheckV2('NewNIC.provisioningState', 'Succeeded')])
|
||||
|
||||
# exercise creating with NSG and Public IP
|
||||
self.cmd('network nic create -g {} -n {} --subnet {} --vnet-name {} --network-security-group {} --public-ip-address {}'.format(rg, nic, subnet, vnet, nsg_id, public_ip_id), checks=[
|
||||
JMESPathCheckV2('NewNIC.ipConfigurations[0].privateIpAllocationMethod', 'Dynamic'),
|
||||
JMESPathCheckV2('NewNIC.enableIpForwarding', False),
|
||||
JMESPathCheckV2("NewNIC.networkSecurityGroup.contains(id, '{}')".format(nsg), True),
|
||||
JMESPathCheckV2('NewNIC.provisioningState', 'Succeeded')
|
||||
])
|
||||
self.cmd('network nic list', checks=[
|
||||
JMESPathCheckV2('type(@)', 'array'),
|
||||
JMESPathCheckV2("length([?contains(id, 'networkInterfaces')]) == length(@)", True)
|
||||
])
|
||||
self.cmd('network nic list --resource-group {}'.format(rg), checks=[
|
||||
JMESPathCheckV2('type(@)', 'array'),
|
||||
JMESPathCheckV2("length([?type == '{}']) == length(@)".format(rt), True),
|
||||
JMESPathCheckV2("length([?resourceGroup == '{}']) == length(@)".format(rg), True)
|
||||
])
|
||||
self.cmd('network nic show --resource-group {} --name {}'.format(rg, nic), checks=[
|
||||
JMESPathCheckV2('type(@)', 'object'),
|
||||
JMESPathCheckV2('type', rt),
|
||||
JMESPathCheckV2('resourceGroup', rg),
|
||||
JMESPathCheckV2('name', nic)
|
||||
])
|
||||
self.cmd('network nic update -g {} -n {} --internal-dns-name noodle --ip-forwarding true --dns-servers "" --network-security-group {}'.format(rg, nic, alt_nsg), checks=[
|
||||
JMESPathCheckV2('enableIpForwarding', True),
|
||||
JMESPathCheckV2('dnsSettings.internalDnsNameLabel', 'noodle'),
|
||||
JMESPathCheckV2('length(dnsSettings.dnsServers)', 0),
|
||||
JMESPathCheckV2("networkSecurityGroup.contains(id, '{}')".format(alt_nsg), True)
|
||||
])
|
||||
JMESPathCheckV2('NewNIC.provisioningState', 'Succeeded')])
|
||||
|
||||
self.cmd('network nic list',
|
||||
checks=[JMESPathCheckV2('type(@)', 'array'),
|
||||
JMESPathCheckV2("length([?contains(id, 'networkInterfaces')]) == length(@)", True)])
|
||||
|
||||
self.cmd('network nic list --resource-group {}'.format(rg),
|
||||
checks=[JMESPathCheckV2('type(@)', 'array'),
|
||||
JMESPathCheckV2("length([?type == '{}']) == length(@)".format(rt), True),
|
||||
JMESPathCheckV2("length([?resourceGroup == '{}']) == length(@)".format(rg), True)])
|
||||
|
||||
self.cmd('network nic show --resource-group {} --name {}'.format(rg, nic),
|
||||
checks=[JMESPathCheckV2('type(@)', 'object'),
|
||||
JMESPathCheckV2('type', rt),
|
||||
JMESPathCheckV2('resourceGroup', rg),
|
||||
JMESPathCheckV2('name', nic)])
|
||||
|
||||
self.cmd('network nic update -g {} -n {} --internal-dns-name noodle --ip-forwarding true --dns-servers "" --network-security-group {}'.format(rg, nic, alt_nsg),
|
||||
checks=[JMESPathCheckV2('enableIpForwarding', True),
|
||||
JMESPathCheckV2('dnsSettings.internalDnsNameLabel', 'noodle'),
|
||||
JMESPathCheckV2('length(dnsSettings.dnsServers)', 0),
|
||||
JMESPathCheckV2("networkSecurityGroup.contains(id, '{}')".format(alt_nsg), True)])
|
||||
|
||||
# test generic update
|
||||
self.cmd('network nic update -g {} -n {} --set dnsSettings.internalDnsNameLabel=doodle --set enableIpForwarding=false'.format(rg, nic), checks=[
|
||||
JMESPathCheckV2('enableIpForwarding', False),
|
||||
JMESPathCheckV2('dnsSettings.internalDnsNameLabel', 'doodle')
|
||||
])
|
||||
self.cmd('network nic update -g {} -n {} --set dnsSettings.internalDnsNameLabel=doodle --set enableIpForwarding=false'.format(rg, nic),
|
||||
checks=[JMESPathCheckV2('enableIpForwarding', False),
|
||||
JMESPathCheckV2('dnsSettings.internalDnsNameLabel', 'doodle')])
|
||||
|
||||
self.cmd('network nic delete --resource-group {} --name {}'.format(rg, nic))
|
||||
self.cmd('network nic list -g {}'.format(rg), checks=NoneCheck())
|
||||
|
|
|
@ -285,9 +285,9 @@ def _flatten(text):
|
|||
|
||||
# tokens: sequence of non-whitespace separated by '' where a newline was
|
||||
tokens = []
|
||||
for l in (x for x in lines if len(x) > 0):
|
||||
l = l.replace('\t', ' ')
|
||||
tokens += _tokenize_line(l, quote_strings=True, infer_name=False)
|
||||
for line in (x for x in lines if len(x) > 0):
|
||||
line = line.replace('\t', ' ')
|
||||
tokens += _tokenize_line(line, quote_strings=True, infer_name=False)
|
||||
tokens.append(SENTINEL)
|
||||
|
||||
# find (...) and turn it into a single line ("capture" it)
|
||||
|
|
|
@ -19,7 +19,6 @@ from azure.cli.testsdk.vcr_test_base import (VCRTestBase, JMESPathCheck, NoneChe
|
|||
|
||||
|
||||
class ResourceGroupScenarioTest(ScenarioTest):
|
||||
|
||||
@ResourceGroupPreparer(name_prefix='cli_test_rg_scenario')
|
||||
def test_resource_group(self, resource_group):
|
||||
s = self
|
||||
|
@ -287,7 +286,6 @@ class ProviderOperationTest(VCRTestBase):
|
|||
|
||||
|
||||
class DeploymentTest(ScenarioTest):
|
||||
|
||||
@ResourceGroupPreparer(name_prefix='cli_test_deployment_lite')
|
||||
def test_group_deployment_lite(self, resource_group):
|
||||
# ensures that a template that is missing "parameters" or "resources" still deploys
|
||||
|
@ -309,18 +307,22 @@ class DeploymentTest(ScenarioTest):
|
|||
object_file = os.path.join(curr_dir, 'test-object.json').replace('\\', '\\\\')
|
||||
deployment_name = 'azure-cli-deployment'
|
||||
|
||||
subnet_id = self.cmd('network vnet create -g {} -n vnet1 --subnet-name subnet1'.format(resource_group)).get_output_in_json()['newVNet']['subnets'][0]['id']
|
||||
subnet_id = self.cmd(
|
||||
'network vnet create -g {} -n vnet1 --subnet-name subnet1'.format(resource_group)).get_output_in_json()[
|
||||
'newVNet']['subnets'][0]['id']
|
||||
|
||||
self.cmd('group deployment validate -g {} --template-file {} --parameters @"{}" --parameters subnetId="{}" --parameters backendAddressPools=@"{}"'.format(
|
||||
resource_group, template_file, parameters_file, subnet_id, object_file), checks=[
|
||||
JCheck('properties.provisioningState', 'Succeeded')
|
||||
])
|
||||
self.cmd(
|
||||
'group deployment validate -g {} --template-file {} --parameters @"{}" --parameters subnetId="{}" --parameters backendAddressPools=@"{}"'.format(
|
||||
resource_group, template_file, parameters_file, subnet_id, object_file), checks=[
|
||||
JCheck('properties.provisioningState', 'Succeeded')
|
||||
])
|
||||
|
||||
self.cmd('group deployment create -g {} -n {} --template-file {} --parameters @"{}" --parameters subnetId="{}" --parameters backendAddressPools=@"{}"'.format(
|
||||
resource_group, deployment_name, template_file, parameters_file, subnet_id, object_file), checks=[
|
||||
JCheck('properties.provisioningState', 'Succeeded'),
|
||||
JCheck('resourceGroup', resource_group),
|
||||
])
|
||||
self.cmd(
|
||||
'group deployment create -g {} -n {} --template-file {} --parameters @"{}" --parameters subnetId="{}" --parameters backendAddressPools=@"{}"'.format(
|
||||
resource_group, deployment_name, template_file, parameters_file, subnet_id, object_file), checks=[
|
||||
JCheck('properties.provisioningState', 'Succeeded'),
|
||||
JCheck('resourceGroup', resource_group),
|
||||
])
|
||||
self.cmd('network lb show -g {} -n test-lb'.format(resource_group), checks=[
|
||||
JCheck('tags', {'key': 'super=value'})
|
||||
])
|
||||
|
@ -349,11 +351,14 @@ class DeploymentLiveTest(LiveScenarioTest):
|
|||
object_file = os.path.join(curr_dir, 'test-object.json').replace('\\', '\\\\')
|
||||
deployment_name = 'azure-cli-deployment2'
|
||||
|
||||
subnet_id = self.cmd('network vnet create -g {} -n vnet1 --subnet-name subnet1'.format(resource_group)).get_output_in_json()['newVNet']['subnets'][0]['id']
|
||||
subnet_id = self.cmd(
|
||||
'network vnet create -g {} -n vnet1 --subnet-name subnet1'.format(resource_group)).get_output_in_json()[
|
||||
'newVNet']['subnets'][0]['id']
|
||||
|
||||
with force_progress_logging() as test_io:
|
||||
self.cmd('group deployment create --verbose -g {} -n {} --template-file {} --parameters @"{}" --parameters subnetId="{}" --parameters backendAddressPools=@"{}"'.format(
|
||||
resource_group, deployment_name, template_file, parameters_file, subnet_id, object_file))
|
||||
self.cmd(
|
||||
'group deployment create --verbose -g {} -n {} --template-file {} --parameters @"{}" --parameters subnetId="{}" --parameters backendAddressPools=@"{}"'.format(
|
||||
resource_group, deployment_name, template_file, parameters_file, subnet_id, object_file))
|
||||
|
||||
# very the progress
|
||||
lines = test_io.getvalue().splitlines()
|
||||
|
@ -389,13 +394,10 @@ class DeploymentnoWaitTest(ResourceGroupVCRTestBase):
|
|||
checks=NoneCheck())
|
||||
|
||||
self.cmd('group deployment show -g {} -n {}'.format(self.resource_group, deployment_name),
|
||||
checks=[
|
||||
JMESPathCheck('properties.provisioningState', 'Succeeded')
|
||||
])
|
||||
checks=[JMESPathCheck('properties.provisioningState', 'Succeeded')])
|
||||
|
||||
|
||||
class DeploymentThruUriTest(ScenarioTest):
|
||||
|
||||
@ResourceGroupPreparer(name_prefix='cli_test_deployment_uri')
|
||||
def test_group_deployment_thru_uri(self, resource_group):
|
||||
self.resource_group = resource_group
|
||||
|
@ -413,7 +415,8 @@ class DeploymentThruUriTest(ScenarioTest):
|
|||
|
||||
deployment_name = result['name']
|
||||
result = self.cmd(
|
||||
'group deployment show -g {} -n {}'.format(self.resource_group, deployment_name), checks=JCheck('name', deployment_name))
|
||||
'group deployment show -g {} -n {}'.format(self.resource_group, deployment_name),
|
||||
checks=JCheck('name', deployment_name))
|
||||
|
||||
self.cmd('group deployment delete -g {} -n {}'.format(self.resource_group, deployment_name))
|
||||
self.cmd('group deployment list -g {}'.format(self.resource_group), checks=NoneCheck())
|
||||
|
@ -470,14 +473,15 @@ class PolicyScenarioTest(ScenarioTest):
|
|||
mode = 'Indexed'
|
||||
|
||||
# create a policy
|
||||
self.cmd('policy definition create -n {} --rules {} --params {} --display-name {} --description {} --mode {}'.format(
|
||||
policy_name, rules_file, params_def_file, policy_display_name, policy_description, mode),
|
||||
self.cmd(
|
||||
'policy definition create -n {} --rules {} --params {} --display-name {} --description {} --mode {}'.format(
|
||||
policy_name, rules_file, params_def_file, policy_display_name, policy_description, mode),
|
||||
checks=[
|
||||
JCheck('name', policy_name),
|
||||
JCheck('displayName', policy_display_name),
|
||||
JCheck('description', policy_description),
|
||||
JCheck('mode', mode)
|
||||
]
|
||||
JCheck('name', policy_name),
|
||||
JCheck('displayName', policy_display_name),
|
||||
JCheck('description', policy_description),
|
||||
JCheck('mode', mode)
|
||||
]
|
||||
)
|
||||
|
||||
# update it
|
||||
|
@ -496,13 +500,11 @@ class PolicyScenarioTest(ScenarioTest):
|
|||
policy_assignment_name = self.create_random_name('azurecli-test-policy-assignment', 40)
|
||||
policy_assignment_display_name = self.create_random_name('test_assignment', 20)
|
||||
self.cmd('policy assignment create --policy {} -n {} --display-name {} -g {} --params {}'.format(
|
||||
policy_name, policy_assignment_name, policy_assignment_display_name, resource_group, params_file),
|
||||
checks=[
|
||||
JCheck('name', policy_assignment_name),
|
||||
policy_name, policy_assignment_name, policy_assignment_display_name, resource_group, params_file),
|
||||
checks=[JCheck('name', policy_assignment_name),
|
||||
JCheck('displayName', policy_assignment_display_name),
|
||||
JCheck('sku.name', 'A0'),
|
||||
JCheck('sku.tier', 'Free'),
|
||||
])
|
||||
JCheck('sku.tier', 'Free')])
|
||||
|
||||
# create a policy assignment with not scopes and standard sku
|
||||
get_cmd = 'group show -n {}'
|
||||
|
@ -511,26 +513,26 @@ class PolicyScenarioTest(ScenarioTest):
|
|||
subnet_name = self.create_random_name('azurecli-test-policy-subnet', 40)
|
||||
vnetcreatecmd = 'network vnet create -g {} -n {} --subnet-name {}'
|
||||
self.cmd(vnetcreatecmd.format(resource_group, vnet_name, subnet_name))
|
||||
notscope = '/subscriptions/{}/resourceGroups/{}/providers/Microsoft.Network/virtualNetworks'.format(rg['id'].split("/")[2], resource_group)
|
||||
self.cmd('policy assignment create --policy {} -n {} --display-name {} -g {} --not-scopes {} --params {} --sku {}'.format(
|
||||
policy_name, policy_assignment_name, policy_assignment_display_name, resource_group, notscope, params_file, 'standard'),
|
||||
checks=[
|
||||
JCheck('name', policy_assignment_name),
|
||||
notscope = '/subscriptions/{}/resourceGroups/{}/providers/Microsoft.Network/virtualNetworks'.format(
|
||||
rg['id'].split("/")[2], resource_group)
|
||||
self.cmd(
|
||||
'policy assignment create --policy {} -n {} --display-name {} -g {} --not-scopes {} --params {} --sku {}'.format(
|
||||
policy_name, policy_assignment_name, policy_assignment_display_name, resource_group, notscope,
|
||||
params_file, 'standard'),
|
||||
checks=[JCheck('name', policy_assignment_name),
|
||||
JCheck('displayName', policy_assignment_display_name),
|
||||
JCheck('sku.name', 'A1'),
|
||||
JCheck('sku.tier', 'Standard'),
|
||||
JCheck('notScopes[0]', notscope)
|
||||
])
|
||||
JCheck('notScopes[0]', notscope)])
|
||||
|
||||
# create a policy assignment using a built in policy definition name
|
||||
policy_assignment_name2 = self.create_random_name('azurecli-test-policy-assignment2', 40)
|
||||
built_in_policy = self.cmd('policy definition list --query "[?policyType==\'BuiltIn\']|[0]"').get_output_in_json()
|
||||
built_in_policy = self.cmd(
|
||||
'policy definition list --query "[?policyType==\'BuiltIn\']|[0]"').get_output_in_json()
|
||||
self.cmd('policy assignment create --policy {} -n {} --display-name {} -g {}'.format(
|
||||
built_in_policy['name'], policy_assignment_name2, policy_assignment_display_name, resource_group),
|
||||
checks=[
|
||||
JCheck('name', policy_assignment_name2),
|
||||
JCheck('displayName', policy_assignment_display_name)
|
||||
])
|
||||
built_in_policy['name'], policy_assignment_name2, policy_assignment_display_name, resource_group),
|
||||
checks=[JCheck('name', policy_assignment_name2),
|
||||
JCheck('displayName', policy_assignment_display_name)])
|
||||
self.cmd('policy assignment delete -n {} -g {}'.format(policy_assignment_name2, resource_group))
|
||||
|
||||
# listing at subscription level won't find the assignment made at a resource group
|
||||
|
@ -577,36 +579,32 @@ class PolicyScenarioTest(ScenarioTest):
|
|||
with open(os.path.join(curr_dir, 'sample_policy_set.json'), 'w') as outfile:
|
||||
json.dump(policyset, outfile)
|
||||
self.cmd('policy set-definition create -n {} --definitions @"{}" --display-name {} --description {}'.format(
|
||||
policyset_name, policyset_file, policyset_display_name, policyset_description),
|
||||
checks=[
|
||||
JCheck('name', policyset_name),
|
||||
policyset_name, policyset_file, policyset_display_name, policyset_description),
|
||||
checks=[JCheck('name', policyset_name),
|
||||
JCheck('displayName', policyset_display_name),
|
||||
JCheck('description', policyset_description)
|
||||
])
|
||||
JCheck('description', policyset_description)])
|
||||
|
||||
# update it
|
||||
new_policyset_description = policy_description + '_new'
|
||||
self.cmd('policy set-definition update -n {} --description {}'.format(policyset_name, new_policyset_description),
|
||||
checks=JCheck('description', new_policyset_description))
|
||||
self.cmd(
|
||||
'policy set-definition update -n {} --description {}'.format(policyset_name, new_policyset_description),
|
||||
checks=JCheck('description', new_policyset_description))
|
||||
|
||||
# list and show it
|
||||
self.cmd('policy set-definition list', checks=JMESPathCheck("length([?name=='{}'])".format(policyset_name), 1))
|
||||
self.cmd('policy set-definition show -n {}'.format(policyset_name), checks=[
|
||||
JCheck('name', policyset_name),
|
||||
JCheck('displayName', policyset_display_name)
|
||||
])
|
||||
self.cmd('policy set-definition show -n {}'.format(policyset_name),
|
||||
checks=[JCheck('name', policyset_name),
|
||||
JCheck('displayName', policyset_display_name)])
|
||||
|
||||
# create a policy assignment on a resource group
|
||||
policy_assignment_name = self.create_random_name('azurecli-test-policy-assignment', 40)
|
||||
policy_assignment_display_name = self.create_random_name('test_assignment', 20)
|
||||
self.cmd('policy assignment create -d {} -n {} --display-name {} -g {}'.format(
|
||||
policyset_name, policy_assignment_name, policy_assignment_display_name, resource_group),
|
||||
checks=[
|
||||
JCheck('name', policy_assignment_name),
|
||||
policyset_name, policy_assignment_name, policy_assignment_display_name, resource_group),
|
||||
checks=[JCheck('name', policy_assignment_name),
|
||||
JCheck('displayName', policy_assignment_display_name),
|
||||
JCheck('sku.name', 'A0'),
|
||||
JCheck('sku.tier', 'Free'),
|
||||
])
|
||||
JCheck('sku.tier', 'Free')])
|
||||
|
||||
# delete the assignment
|
||||
self.cmd('policy assignment delete -n {} -g {}'.format(policy_assignment_name, resource_group))
|
||||
|
@ -638,17 +636,19 @@ class ManagedAppDefinitionScenarioTest(ScenarioTest):
|
|||
|
||||
# create a managedapp definition
|
||||
create_cmd = 'managedapp definition create -n {} --package-file-uri {} --display-name {} --description {} -l {} -a {} --lock-level {} -g {}'
|
||||
appdef = self.cmd(create_cmd.format(appdef_name, packageUri, appdef_display_name, appdef_description, location, auth, lock, resource_group), checks=[
|
||||
JCheck('name', appdef_name),
|
||||
JCheck('displayName', appdef_display_name),
|
||||
JCheck('description', appdef_description),
|
||||
JCheck('authorizations[0].principalId', '5e91139a-c94b-462e-a6ff-1ee95e8aac07'),
|
||||
JCheck('authorizations[0].roleDefinitionId', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635'),
|
||||
JCheck('artifacts[0].name', 'ApplianceResourceTemplate'),
|
||||
JCheck('artifacts[0].type', 'Template'),
|
||||
JCheck('artifacts[1].name', 'CreateUiDefinition'),
|
||||
JCheck('artifacts[1].type', 'Custom')
|
||||
]).get_output_in_json()
|
||||
appdef = self.cmd(
|
||||
create_cmd.format(appdef_name, packageUri, appdef_display_name, appdef_description, location, auth, lock,
|
||||
resource_group), checks=[
|
||||
JCheck('name', appdef_name),
|
||||
JCheck('displayName', appdef_display_name),
|
||||
JCheck('description', appdef_description),
|
||||
JCheck('authorizations[0].principalId', '5e91139a-c94b-462e-a6ff-1ee95e8aac07'),
|
||||
JCheck('authorizations[0].roleDefinitionId', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635'),
|
||||
JCheck('artifacts[0].name', 'ApplianceResourceTemplate'),
|
||||
JCheck('artifacts[0].type', 'Template'),
|
||||
JCheck('artifacts[1].name', 'CreateUiDefinition'),
|
||||
JCheck('artifacts[1].type', 'Custom')
|
||||
]).get_output_in_json()
|
||||
|
||||
# list and show it
|
||||
list_cmd = 'managedapp definition list -g {}'
|
||||
|
@ -687,17 +687,19 @@ class ManagedAppDefinitionScenarioTest(ScenarioTest):
|
|||
|
||||
# create a managedapp definition with inline params for create-ui-definition and main-template
|
||||
create_cmd = 'managedapp definition create -n {} --create-ui-definition @"{}" --main-template @"{}" --display-name {} --description {} -l {} -a {} --lock-level {} -g {}'
|
||||
appdef = self.cmd(create_cmd.format(appdef_name, createUiDef_file, mainTemplate_file, appdef_display_name, appdef_description, location, auth, lock, resource_group), checks=[
|
||||
JCheck('name', appdef_name),
|
||||
JCheck('displayName', appdef_display_name),
|
||||
JCheck('description', appdef_description),
|
||||
JCheck('authorizations[0].principalId', '5e91139a-c94b-462e-a6ff-1ee95e8aac07'),
|
||||
JCheck('authorizations[0].roleDefinitionId', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635'),
|
||||
JCheck('artifacts[0].name', 'ApplicationResourceTemplate'),
|
||||
JCheck('artifacts[0].type', 'Template'),
|
||||
JCheck('artifacts[1].name', 'CreateUiDefinition'),
|
||||
JCheck('artifacts[1].type', 'Custom')
|
||||
]).get_output_in_json()
|
||||
appdef = self.cmd(
|
||||
create_cmd.format(appdef_name, createUiDef_file, mainTemplate_file, appdef_display_name, appdef_description,
|
||||
location, auth, lock, resource_group), checks=[
|
||||
JCheck('name', appdef_name),
|
||||
JCheck('displayName', appdef_display_name),
|
||||
JCheck('description', appdef_description),
|
||||
JCheck('authorizations[0].principalId', '5e91139a-c94b-462e-a6ff-1ee95e8aac07'),
|
||||
JCheck('authorizations[0].roleDefinitionId', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635'),
|
||||
JCheck('artifacts[0].name', 'ApplicationResourceTemplate'),
|
||||
JCheck('artifacts[0].type', 'Template'),
|
||||
JCheck('artifacts[1].name', 'CreateUiDefinition'),
|
||||
JCheck('artifacts[1].type', 'Custom')
|
||||
]).get_output_in_json()
|
||||
|
||||
# list and show it
|
||||
list_cmd = 'managedapp definition list -g {}'
|
||||
|
@ -737,7 +739,8 @@ class ManagedAppScenarioTest(ScenarioTest):
|
|||
# create a managedapp definition
|
||||
create_cmd = 'managedapp definition create -n {} --package-file-uri {} --display-name {} --description {} -l {} -a {} --lock-level {} -g {}'
|
||||
managedappdef = self.cmd(create_cmd.format(appdef_name, packageUri, appdef_display_name,
|
||||
appdef_description, location, auth, lock, resource_group)).get_output_in_json()
|
||||
appdef_description, location, auth, lock,
|
||||
resource_group)).get_output_in_json()
|
||||
|
||||
# create a managedapp
|
||||
managedapp_name = 'mymanagedapp'
|
||||
|
@ -746,7 +749,8 @@ class ManagedAppScenarioTest(ScenarioTest):
|
|||
newrg = self.create_random_name('climanagedapp', 25)
|
||||
managedrg = '/subscriptions/{}/resourceGroups/{}'.format(managedappdef['id'].split("/")[2], newrg)
|
||||
create_cmd = 'managedapp create -n {} -g {} -l {} --kind {} -m {} -d {}'
|
||||
app = self.cmd(create_cmd.format(managedapp_name, resource_group, managedapp_loc, managedapp_kind, managedrg, managedappdef['id']), checks=[
|
||||
app = self.cmd(create_cmd.format(managedapp_name, resource_group, managedapp_loc, managedapp_kind, managedrg,
|
||||
managedappdef['id']), checks=[
|
||||
JCheck('name', managedapp_name),
|
||||
JCheck('type', 'Microsoft.Solutions/applications'),
|
||||
JCheck('kind', 'servicecatalog'),
|
||||
|
@ -773,7 +777,6 @@ class ManagedAppScenarioTest(ScenarioTest):
|
|||
|
||||
|
||||
class CrossRGDeploymentScenarioTest(ScenarioTest):
|
||||
|
||||
@ResourceGroupPreparer(name_prefix='cli_test_cross_rg_alt', parameter_name='resource_group_cross')
|
||||
@ResourceGroupPreparer(name_prefix='cli_test_cross_rg_deploy')
|
||||
def test_group_deployment_crossrg(self, resource_group, resource_group_cross):
|
||||
|
@ -783,10 +786,11 @@ class CrossRGDeploymentScenarioTest(ScenarioTest):
|
|||
storage_account_1 = create_random_name(prefix='crossrg')
|
||||
storage_account_2 = create_random_name(prefix='crossrg')
|
||||
|
||||
self.cmd('group deployment validate -g {} --template-file {} --parameters CrossRg={} StorageAccountName1={} StorageAccountName2={}'.format(
|
||||
resource_group, template_file, resource_group_cross, storage_account_1, storage_account_2), checks=[
|
||||
JCheck('properties.provisioningState', 'Succeeded')
|
||||
])
|
||||
self.cmd(
|
||||
'group deployment validate -g {} --template-file {} --parameters CrossRg={} StorageAccountName1={} StorageAccountName2={}'.format(
|
||||
resource_group, template_file, resource_group_cross, storage_account_1, storage_account_2), checks=[
|
||||
JCheck('properties.provisioningState', 'Succeeded')
|
||||
])
|
||||
self.cmd('group deployment create -g {} -n {} --template-file {} --parameters CrossRg={}'.format(
|
||||
resource_group, deployment_name, template_file, resource_group_cross), checks=[
|
||||
JCheck('properties.provisioningState', 'Succeeded'),
|
||||
|
|
|
@ -64,7 +64,6 @@ class SqlServerPreparer(AbstractPreparer, SingleValueReplacer):
|
|||
|
||||
|
||||
class SqlServerMgmtScenarioTest(ScenarioTest):
|
||||
|
||||
@ResourceGroupPreparer(parameter_name='resource_group_1')
|
||||
@ResourceGroupPreparer(parameter_name='resource_group_2')
|
||||
def test_sql_server_mgmt(self, resource_group_1, resource_group_2, resource_group_location):
|
||||
|
@ -146,7 +145,6 @@ class SqlServerMgmtScenarioTest(ScenarioTest):
|
|||
|
||||
|
||||
class SqlServerFirewallMgmtScenarioTest(ScenarioTest):
|
||||
|
||||
@ResourceGroupPreparer()
|
||||
@SqlServerPreparer()
|
||||
def test_sql_firewall_mgmt(self, resource_group, resource_group_location, server):
|
||||
|
@ -337,7 +335,7 @@ class SqlServerDbOperationMgmtScenarioTest(ScenarioTest):
|
|||
JMESPathCheck('[0].resourceGroup', resource_group),
|
||||
JMESPathCheck('[0].databaseName', database_name)
|
||||
])
|
||||
.get_output_in_json())
|
||||
.get_output_in_json())
|
||||
|
||||
# Cancel operation
|
||||
self.cmd('sql db op cancel -g {} -s {} -d {} -n {}'
|
||||
|
@ -385,7 +383,6 @@ class SqlServerDbCopyScenarioTest(ScenarioTest):
|
|||
def test_sql_db_copy(self, resource_group_1, resource_group_2,
|
||||
resource_group_location,
|
||||
server1, server2):
|
||||
|
||||
database_name = "cliautomationdb01"
|
||||
database_copy_name = "cliautomationdb02"
|
||||
service_objective = 'S1'
|
||||
|
@ -812,7 +809,6 @@ class SqlServerDwMgmtScenarioTest(ScenarioTest):
|
|||
|
||||
|
||||
class SqlServerDbReplicaMgmtScenarioTest(ScenarioTest):
|
||||
|
||||
# create 2 servers in the same resource group, and 1 server in a different resource group
|
||||
@ResourceGroupPreparer(parameter_name="resource_group_1",
|
||||
parameter_name_for_location="resource_group_location_1")
|
||||
|
@ -1208,21 +1204,17 @@ class SqlServerCapabilityScenarioTest(ScenarioTest):
|
|||
checks=[
|
||||
# Standard edition exists, other editions don't
|
||||
JMESPathCheckExists("[?name == 'Standard']"),
|
||||
JMESPathCheck("length([?name != 'Standard'])", 0),
|
||||
])
|
||||
JMESPathCheck("length([?name != 'Standard'])", 0)])
|
||||
|
||||
# Search for db service objective - note that it's case insensitive
|
||||
self.cmd('sql db list-editions -l {} --edition standard --service-objective s0'
|
||||
.format(location), checks=[
|
||||
# Standard edition exists, other editions don't
|
||||
JMESPathCheckExists("[?name == 'Standard']"),
|
||||
JMESPathCheck("length([?name != 'Standard'])", 0),
|
||||
# S0 service objective exists, others don't exist
|
||||
JMESPathCheckExists("[].supportedServiceLevelObjectives[] | [?name == 'S0']"),
|
||||
JMESPathCheck(
|
||||
"length([].supportedServiceLevelObjectives[] | [?name != 'S0'])",
|
||||
0),
|
||||
])
|
||||
# Checked items:
|
||||
# * Standard edition exists, other editions don't
|
||||
# * S0 service objective exists, others don't exist
|
||||
self.cmd('sql db list-editions -l {} --edition standard --service-objective s0'.format(location),
|
||||
checks=[JMESPathCheckExists("[?name == 'Standard']"),
|
||||
JMESPathCheck("length([?name != 'Standard'])", 0),
|
||||
JMESPathCheckExists("[].supportedServiceLevelObjectives[] | [?name == 'S0']"),
|
||||
JMESPathCheck("length([].supportedServiceLevelObjectives[] | [?name != 'S0'])", 0)])
|
||||
|
||||
pool_max_size_length_jmespath = 'length([].supportedElasticPoolDtus[].supportedMaxSizes[])'
|
||||
pool_db_max_dtu_length_jmespath = 'length([].supportedElasticPoolDtus[].supportedPerDatabaseMaxDtus[])'
|
||||
|
@ -1232,77 +1224,60 @@ class SqlServerCapabilityScenarioTest(ScenarioTest):
|
|||
|
||||
# Get all elastic pool capabilities
|
||||
self.cmd('sql elastic-pool list-editions -l {}'.format(location),
|
||||
checks=[
|
||||
# At least standard and premium edition exist
|
||||
JMESPathCheckExists("[?name == 'Standard']"),
|
||||
JMESPathCheckExists("[?name == 'Premium']"),
|
||||
# Optional details are omitted
|
||||
JMESPathCheck(pool_max_size_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_min_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_size_length_jmespath, 0)
|
||||
])
|
||||
checks=[JMESPathCheckExists("[?name == 'Standard']"), # At least standard and premium edition exist
|
||||
JMESPathCheckExists("[?name == 'Premium']"),
|
||||
JMESPathCheck(pool_max_size_length_jmespath, 0), # Optional details are omitted
|
||||
JMESPathCheck(pool_db_max_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_min_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_size_length_jmespath, 0)])
|
||||
|
||||
# Search for elastic pool edition - note that it's case insensitive
|
||||
self.cmd('sql elastic-pool list-editions -l {} --edition standard'.format(location),
|
||||
checks=[
|
||||
# Standard edition exists, other editions don't
|
||||
JMESPathCheckExists("[?name == 'Standard']"),
|
||||
JMESPathCheck("length([?name != 'Standard'])", 0)
|
||||
])
|
||||
checks=[JMESPathCheckExists("[?name == 'Standard']"), # Standard edition exists, other editions don't
|
||||
JMESPathCheck("length([?name != 'Standard'])", 0)])
|
||||
|
||||
# Search for dtu limit
|
||||
self.cmd('sql elastic-pool list-editions -l {} --dtu 100'.format(location),
|
||||
checks=[
|
||||
# All results have 100 dtu
|
||||
JMESPathCheckGreaterThan('length([].supportedElasticPoolDtus[?limit == `100`][])', 0),
|
||||
JMESPathCheck('length([].supportedElasticPoolDtus[?limit != `100`][])', 0)
|
||||
])
|
||||
JMESPathCheck('length([].supportedElasticPoolDtus[?limit != `100`][])', 0)])
|
||||
|
||||
# Get all db capabilities with pool max size
|
||||
self.cmd('sql elastic-pool list-editions -l {} --show-details max-size'.format(location),
|
||||
checks=[
|
||||
JMESPathCheckGreaterThan(pool_max_size_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_min_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_size_length_jmespath, 0)
|
||||
])
|
||||
checks=[JMESPathCheckGreaterThan(pool_max_size_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_min_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_size_length_jmespath, 0)])
|
||||
|
||||
# Get all db capabilities with per db max size
|
||||
self.cmd('sql elastic-pool list-editions -l {} --show-details db-max-size'.format(location),
|
||||
checks=[
|
||||
JMESPathCheck(pool_max_size_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_min_dtu_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_max_size_length_jmespath, 0)
|
||||
])
|
||||
checks=[JMESPathCheck(pool_max_size_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_min_dtu_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_max_size_length_jmespath, 0)])
|
||||
|
||||
# Get all db capabilities with per db max dtu
|
||||
self.cmd('sql elastic-pool list-editions -l {} --edition standard --show-details db-max-dtu'.format(location),
|
||||
checks=[
|
||||
JMESPathCheck(pool_max_size_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_max_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_min_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_size_length_jmespath, 0)
|
||||
])
|
||||
checks=[JMESPathCheck(pool_max_size_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_max_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_min_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_size_length_jmespath, 0)])
|
||||
|
||||
# Get all db capabilities with per db min dtu (which is nested under per db max dtu)
|
||||
self.cmd('sql elastic-pool list-editions -l {} --edition standard --show-details db-min-dtu'.format(location),
|
||||
checks=[
|
||||
JMESPathCheck(pool_max_size_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_max_dtu_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_min_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_size_length_jmespath, 0)
|
||||
])
|
||||
checks=[JMESPathCheck(pool_max_size_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_max_dtu_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_min_dtu_length_jmespath, 0),
|
||||
JMESPathCheck(pool_db_max_size_length_jmespath, 0)])
|
||||
|
||||
# Get all db capabilities with everything
|
||||
self.cmd('sql elastic-pool list-editions -l {} --edition standard --show-details db-min-dtu db-max-dtu db-max-size max-size'.format(location),
|
||||
checks=[
|
||||
JMESPathCheckGreaterThan(pool_max_size_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_max_dtu_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_min_dtu_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_max_size_length_jmespath, 0)
|
||||
])
|
||||
self.cmd('sql elastic-pool list-editions -l {} --edition standard --show-details db-min-dtu db-max-dtu '
|
||||
'db-max-size max-size'.format(location),
|
||||
checks=[JMESPathCheckGreaterThan(pool_max_size_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_max_dtu_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_min_dtu_length_jmespath, 0),
|
||||
JMESPathCheckGreaterThan(pool_db_max_size_length_jmespath, 0)])
|
||||
|
||||
|
||||
class SqlServerImportExportMgmtScenarioTest(ScenarioTest):
|
||||
|
@ -1330,39 +1305,35 @@ class SqlServerImportExportMgmtScenarioTest(ScenarioTest):
|
|||
'--start-ip-address {} --end-ip-address {}'
|
||||
.format(firewall_rule_1, resource_group, server,
|
||||
start_ip_address_1, end_ip_address_1),
|
||||
checks=[
|
||||
JMESPathCheck('name', firewall_rule_1),
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('startIpAddress', start_ip_address_1),
|
||||
JMESPathCheck('endIpAddress', end_ip_address_1)])
|
||||
checks=[JMESPathCheck('name', firewall_rule_1),
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('startIpAddress', start_ip_address_1),
|
||||
JMESPathCheck('endIpAddress', end_ip_address_1)])
|
||||
|
||||
# create dbs
|
||||
self.cmd('sql db create -g {} --server {} --name {}'
|
||||
.format(resource_group, server, db_name),
|
||||
checks=[
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('name', db_name),
|
||||
JMESPathCheck('location', location_long_name),
|
||||
JMESPathCheck('elasticPoolName', None),
|
||||
JMESPathCheck('status', 'Online')])
|
||||
checks=[JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('name', db_name),
|
||||
JMESPathCheck('location', location_long_name),
|
||||
JMESPathCheck('elasticPoolName', None),
|
||||
JMESPathCheck('status', 'Online')])
|
||||
|
||||
self.cmd('sql db create -g {} --server {} --name {}'
|
||||
.format(resource_group, server, db_name2),
|
||||
checks=[
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('name', db_name2),
|
||||
JMESPathCheck('location', location_long_name),
|
||||
JMESPathCheck('elasticPoolName', None),
|
||||
JMESPathCheck('status', 'Online')])
|
||||
checks=[JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('name', db_name2),
|
||||
JMESPathCheck('location', location_long_name),
|
||||
JMESPathCheck('elasticPoolName', None),
|
||||
JMESPathCheck('status', 'Online')])
|
||||
|
||||
self.cmd('sql db create -g {} --server {} --name {}'
|
||||
.format(resource_group, server, db_name3),
|
||||
checks=[
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('name', db_name3),
|
||||
JMESPathCheck('location', location_long_name),
|
||||
JMESPathCheck('elasticPoolName', None),
|
||||
JMESPathCheck('status', 'Online')])
|
||||
checks=[JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('name', db_name3),
|
||||
JMESPathCheck('location', location_long_name),
|
||||
JMESPathCheck('elasticPoolName', None),
|
||||
JMESPathCheck('status', 'Online')])
|
||||
|
||||
# get storage account endpoint
|
||||
storage_endpoint = self.cmd('storage account show -g {} -n {}'
|
||||
|
@ -1385,69 +1356,59 @@ class SqlServerImportExportMgmtScenarioTest(ScenarioTest):
|
|||
# create storage account blob container
|
||||
self.cmd('storage container create -n {} --account-name {} --account-key {} '
|
||||
.format(container, storage_account, storageKey),
|
||||
checks=[
|
||||
JMESPathCheck('created', True)])
|
||||
checks=[JMESPathCheck('created', True)])
|
||||
|
||||
# export database to blob container using both keys
|
||||
self.cmd('sql db export -s {} -n {} -g {} -p {} -u {}'
|
||||
' --storage-key {} --storage-key-type StorageAccessKey'
|
||||
' --storage-uri {}'
|
||||
.format(server, db_name, resource_group, admin_password, admin_login, storageKey,
|
||||
bacpacUri),
|
||||
checks=[
|
||||
JMESPathCheck('blobUri', bacpacUri),
|
||||
JMESPathCheck('databaseName', db_name),
|
||||
JMESPathCheck('requestType', 'Export'),
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('serverName', server),
|
||||
JMESPathCheck('status', 'Completed')])
|
||||
.format(server, db_name, resource_group, admin_password, admin_login, storageKey, bacpacUri),
|
||||
checks=[JMESPathCheck('blobUri', bacpacUri),
|
||||
JMESPathCheck('databaseName', db_name),
|
||||
JMESPathCheck('requestType', 'Export'),
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('serverName', server),
|
||||
JMESPathCheck('status', 'Completed')])
|
||||
|
||||
self.cmd('sql db export -s {} -n {} -g {} -p {} -u {}'
|
||||
' --storage-key {} --storage-key-type SharedAccessKey'
|
||||
' --storage-uri {}'
|
||||
.format(server, db_name, resource_group, admin_password, admin_login, sasKey,
|
||||
bacpacUri2),
|
||||
checks=[
|
||||
JMESPathCheck('blobUri', bacpacUri2),
|
||||
JMESPathCheck('databaseName', db_name),
|
||||
JMESPathCheck('requestType', 'Export'),
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('serverName', server),
|
||||
JMESPathCheck('status', 'Completed')])
|
||||
.format(server, db_name, resource_group, admin_password, admin_login, sasKey, bacpacUri2),
|
||||
checks=[JMESPathCheck('blobUri', bacpacUri2),
|
||||
JMESPathCheck('databaseName', db_name),
|
||||
JMESPathCheck('requestType', 'Export'),
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('serverName', server),
|
||||
JMESPathCheck('status', 'Completed')])
|
||||
|
||||
# import bacpac to second database using Storage Key
|
||||
self.cmd('sql db import -s {} -n {} -g {} -p {} -u {}'
|
||||
' --storage-key {} --storage-key-type StorageAccessKey'
|
||||
' --storage-uri {}'
|
||||
.format(server, db_name2, resource_group, admin_password, admin_login, storageKey,
|
||||
bacpacUri),
|
||||
checks=[
|
||||
JMESPathCheck('blobUri', bacpacUri),
|
||||
JMESPathCheck('databaseName', db_name2),
|
||||
JMESPathCheck('name', 'import'),
|
||||
JMESPathCheck('requestType', 'Import'),
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('serverName', server),
|
||||
JMESPathCheck('status', 'Completed')])
|
||||
.format(server, db_name2, resource_group, admin_password, admin_login, storageKey, bacpacUri),
|
||||
checks=[JMESPathCheck('blobUri', bacpacUri),
|
||||
JMESPathCheck('databaseName', db_name2),
|
||||
JMESPathCheck('name', 'import'),
|
||||
JMESPathCheck('requestType', 'Import'),
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('serverName', server),
|
||||
JMESPathCheck('status', 'Completed')])
|
||||
|
||||
# import bacpac to third database using SAS key
|
||||
self.cmd('sql db import -s {} -n {} -g {} -p {} -u {}'
|
||||
' --storage-key {} --storage-key-type SharedAccessKey'
|
||||
' --storage-uri {}'
|
||||
.format(server, db_name3, resource_group, admin_password, admin_login, sasKey,
|
||||
bacpacUri2),
|
||||
checks=[
|
||||
JMESPathCheck('blobUri', bacpacUri2),
|
||||
JMESPathCheck('databaseName', db_name3),
|
||||
JMESPathCheck('name', 'import'),
|
||||
JMESPathCheck('requestType', 'Import'),
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('serverName', server),
|
||||
JMESPathCheck('status', 'Completed')])
|
||||
.format(server, db_name3, resource_group, admin_password, admin_login, sasKey, bacpacUri2),
|
||||
checks=[JMESPathCheck('blobUri', bacpacUri2),
|
||||
JMESPathCheck('databaseName', db_name3),
|
||||
JMESPathCheck('name', 'import'),
|
||||
JMESPathCheck('requestType', 'Import'),
|
||||
JMESPathCheck('resourceGroup', resource_group),
|
||||
JMESPathCheck('serverName', server),
|
||||
JMESPathCheck('status', 'Completed')])
|
||||
|
||||
|
||||
class SqlServerConnectionStringScenarioTest(ScenarioTest):
|
||||
|
||||
def test_sql_db_conn_str(self):
|
||||
# ADO.NET, username/password
|
||||
conn_str = self.cmd('sql db show-connection-string -s myserver -n mydb -c ado.net').get_output_in_json()
|
||||
|
@ -1679,7 +1640,6 @@ class SqlTransparentDataEncryptionScenarioTest(ScenarioTest):
|
|||
|
||||
|
||||
class SqlServerVnetMgmtScenarioTest(ScenarioTest):
|
||||
|
||||
@ResourceGroupPreparer(location='eastus2euap')
|
||||
@SqlServerPreparer(location='eastus2euap')
|
||||
def test_sql_vnet_mgmt(self, resource_group, resource_group_location, server):
|
||||
|
@ -1747,20 +1707,19 @@ class SqlServerVnetMgmtScenarioTest(ScenarioTest):
|
|||
# test sql server vnet-rule update rule 2 with vnet 1 and ignore-missing-vnet-service-endpoint flag
|
||||
self.cmd('sql server vnet-rule update --name {} -g {} --server {} --subnet {} -i'
|
||||
.format(vnet_rule_2, rg, server, vnet_id_1),
|
||||
checks=[
|
||||
JMESPathCheck('name', vnet_rule_2),
|
||||
JMESPathCheck('resourceGroup', rg),
|
||||
JMESPathCheck('virtualNetworkSubnetId', vnet_id_1),
|
||||
JMESPathCheck('ignoreMissingVnetServiceEndpoint', True)])
|
||||
checks=[JMESPathCheck('name', vnet_rule_2),
|
||||
JMESPathCheck('resourceGroup', rg),
|
||||
JMESPathCheck('virtualNetworkSubnetId', vnet_id_1),
|
||||
JMESPathCheck('ignoreMissingVnetServiceEndpoint', True)])
|
||||
|
||||
# test sql server vnet-rule list
|
||||
self.cmd('sql server vnet-rule list -g {} --server {}'
|
||||
.format(rg, server), checks=[JMESPathCheck('length(@)', 2)])
|
||||
self.cmd('sql server vnet-rule list -g {} --server {}'.format(rg, server),
|
||||
checks=[JMESPathCheck('length(@)', 2)])
|
||||
|
||||
# test sql server vnet-rule delete rule 1
|
||||
self.cmd('sql server vnet-rule delete --name {} -g {} --server {}'
|
||||
.format(vnet_rule_1, rg, server), checks=NoneCheck())
|
||||
self.cmd('sql server vnet-rule delete --name {} -g {} --server {}'.format(vnet_rule_1, rg, server),
|
||||
checks=NoneCheck())
|
||||
|
||||
# test sql server vnet-rule delete rule 2
|
||||
self.cmd('sql server vnet-rule delete --name {} -g {} --server {}'
|
||||
.format(vnet_rule_2, rg, server), checks=NoneCheck())
|
||||
self.cmd('sql server vnet-rule delete --name {} -g {} --server {}'.format(vnet_rule_2, rg, server),
|
||||
checks=NoneCheck())
|
||||
|
|
|
@ -674,31 +674,28 @@ class VMAvailSetScenarioTest(ScenarioTest):
|
|||
@ResourceGroupPreparer()
|
||||
def test_vm_availset(self, resource_group):
|
||||
name = 'availset-test'
|
||||
self.cmd('vm availability-set create -g {} -n {}'.format(resource_group, name), checks=[
|
||||
JMESPathCheckV2('name', name),
|
||||
JMESPathCheckV2('platformFaultDomainCount', 2),
|
||||
JMESPathCheckV2('platformUpdateDomainCount', 5), # server defaults to 5
|
||||
JMESPathCheckV2('sku.name', 'Aligned')
|
||||
])
|
||||
self.cmd('vm availability-set create -g {} -n {}'.format(resource_group, name),
|
||||
checks=[JMESPathCheckV2('name', name),
|
||||
JMESPathCheckV2('platformFaultDomainCount', 2),
|
||||
JMESPathCheckV2('platformUpdateDomainCount', 5), # server defaults to 5
|
||||
JMESPathCheckV2('sku.name', 'Aligned')])
|
||||
|
||||
# create with explict UD count
|
||||
self.cmd('vm availability-set create -g {} -n avset2 --platform-fault-domain-count 2 --platform-update-domain-count 2'.format(resource_group), checks=[
|
||||
JMESPathCheckV2('platformFaultDomainCount', 2),
|
||||
JMESPathCheckV2('platformUpdateDomainCount', 2),
|
||||
JMESPathCheckV2('sku.name', 'Aligned')
|
||||
])
|
||||
self.cmd('vm availability-set create -g {} -n avset2 --platform-fault-domain-count 2 --platform-update-domain-count 2'.format(resource_group),
|
||||
checks=[JMESPathCheckV2('platformFaultDomainCount', 2),
|
||||
JMESPathCheckV2('platformUpdateDomainCount', 2),
|
||||
JMESPathCheckV2('sku.name', 'Aligned')])
|
||||
self.cmd('vm availability-set delete -g {} -n avset2'.format(resource_group))
|
||||
|
||||
self.cmd('vm availability-set update -g {} -n {} --set tags.test=success'.format(resource_group, name),
|
||||
checks=JMESPathCheckV2('tags.test', 'success'))
|
||||
self.cmd('vm availability-set list -g {}'.format(resource_group), checks=[
|
||||
JMESPathCheckV2('length(@)', 1),
|
||||
JMESPathCheckV2('[0].name', name),
|
||||
])
|
||||
self.cmd('vm availability-set list-sizes -g {} -n {}'.format(
|
||||
resource_group, name), checks=JMESPathCheckV2('type(@)', 'array'))
|
||||
self.cmd('vm availability-set show -g {} -n {}'.format(
|
||||
resource_group, name), checks=[JMESPathCheckV2('name', name)])
|
||||
JMESPathCheckV2('[0].name', name)])
|
||||
self.cmd('vm availability-set list-sizes -g {} -n {}'.format(resource_group, name),
|
||||
checks=JMESPathCheckV2('type(@)', 'array'))
|
||||
self.cmd('vm availability-set show -g {} -n {}'.format(resource_group, name),
|
||||
checks=[JMESPathCheckV2('name', name)])
|
||||
self.cmd('vm availability-set delete -g {} -n {}'.format(resource_group, name))
|
||||
self.cmd('vm availability-set list -g {}'.format(resource_group), checks=[JMESPathCheckV2('length(@)', 0)])
|
||||
|
||||
|
@ -708,19 +705,17 @@ class VMAvailSetLiveScenarioTest(LiveScenarioTest):
|
|||
@ResourceGroupPreparer()
|
||||
def test_vm_availset_convert(self, resource_group):
|
||||
name = 'availset-test'
|
||||
self.cmd('vm availability-set create -g {} -n {} --unmanaged --platform-fault-domain-count 3 -l westus2 '.format(resource_group, name), checks=[
|
||||
JMESPathCheckV2('name', name),
|
||||
JMESPathCheckV2('platformFaultDomainCount', 3),
|
||||
JMESPathCheckV2('platformUpdateDomainCount', 5), # server defaults to 5
|
||||
JMESPathCheckV2('sku.name', 'Classic')
|
||||
])
|
||||
self.cmd('vm availability-set create -g {} -n {} --unmanaged --platform-fault-domain-count 3 -l westus2 '.format(resource_group, name),
|
||||
checks=[JMESPathCheckV2('name', name),
|
||||
JMESPathCheckV2('platformFaultDomainCount', 3),
|
||||
JMESPathCheckV2('platformUpdateDomainCount', 5), # server defaults to 5
|
||||
JMESPathCheckV2('sku.name', 'Classic')])
|
||||
|
||||
# the conversion should auto adjust the FD from 3 to 2 as 'westus2' only offers 2
|
||||
self.cmd('vm availability-set convert -g {} -n {}'.format(resource_group, name), checks=[
|
||||
JMESPathCheckV2('name', name),
|
||||
JMESPathCheckV2('platformFaultDomainCount', 2),
|
||||
JMESPathCheckV2('sku.name', 'Aligned')
|
||||
])
|
||||
self.cmd('vm availability-set convert -g {} -n {}'.format(resource_group, name),
|
||||
checks=[JMESPathCheckV2('name', name),
|
||||
JMESPathCheckV2('platformFaultDomainCount', 2),
|
||||
JMESPathCheckV2('sku.name', 'Aligned')])
|
||||
|
||||
|
||||
class ComputeListSkusScenarioTest(LiveScenarioTest):
|
||||
|
|
Загрузка…
Ссылка в новой задаче