зеркало из https://github.com/microsoft/azure-cli.git
Add NIC tests for AzureStack (#4100)
This commit is contained in:
Родитель
8fec686b25
Коммит
0932b8c53d
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,4 +1,4 @@
|
|||
# --------------------------------------------------------------------------------------------
|
||||
# --------------------------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
# --------------------------------------------------------------------------------------------
|
||||
|
@ -582,7 +582,7 @@ class NetworkLocalGatewayScenarioTest(ScenarioTest):
|
|||
|
||||
|
||||
class NetworkNicScenarioTest(ScenarioTest):
|
||||
|
||||
@api_version_constraint(ResourceType.MGMT_NETWORK, min_api='2017-06-01')
|
||||
@ResourceGroupPreparer(name_prefix='cli_test_nic_scenario')
|
||||
def test_network_nic(self, resource_group):
|
||||
rg = resource_group
|
||||
|
@ -669,6 +669,93 @@ class NetworkNicScenarioTest(ScenarioTest):
|
|||
self.cmd('network nic delete --resource-group {} --name {}'.format(rg, nic))
|
||||
self.cmd('network nic list -g {}'.format(rg), checks=NoneCheck())
|
||||
|
||||
@api_version_constraint(ResourceType.MGMT_NETWORK, max_api='2015-06-15')
|
||||
@ResourceGroupPreparer(name_prefix='cli_test_nic_stack_scenario', location='local', dev_setting_location='local')
|
||||
def test_network_nic_stack(self, resource_group):
|
||||
rg = resource_group
|
||||
nic = 'cli-test-nic'
|
||||
rt = 'Microsoft.Network/networkInterfaces'
|
||||
subnet = 'mysubnet'
|
||||
vnet = 'myvnet'
|
||||
nsg = 'mynsg'
|
||||
alt_nsg = 'myothernsg'
|
||||
lb = 'mylb'
|
||||
private_ip = '10.0.0.15'
|
||||
public_ip_name = 'publicip1'
|
||||
|
||||
subnet_id = self.cmd('network vnet create -g {} -n {} --subnet-name {}'.format(rg, vnet, subnet)).get_output_in_json()['newVNet']['subnets'][0]['id']
|
||||
self.cmd('network nsg create -g {} -n {}'.format(rg, nsg))
|
||||
nsg_id = self.cmd('network nsg show -g {} -n {}'.format(rg, nsg)).get_output_in_json()['id']
|
||||
self.cmd('network nsg create -g {} -n {}'.format(rg, alt_nsg))
|
||||
self.cmd('network public-ip create -g {} -n {}'.format(rg, public_ip_name))
|
||||
public_ip_id = self.cmd('network public-ip show -g {} -n {}'.format(rg, public_ip_name)).get_output_in_json()['id']
|
||||
self.cmd('network lb create -g {} -n {}'.format(rg, lb))
|
||||
self.cmd('network lb inbound-nat-rule create -g {} --lb-name {} -n rule1 --protocol tcp --frontend-port 100 --backend-port 100 --frontend-ip-name LoadBalancerFrontEnd'.format(rg, lb))
|
||||
self.cmd('network lb inbound-nat-rule create -g {} --lb-name {} -n rule2 --protocol tcp --frontend-port 200 --backend-port 200 --frontend-ip-name LoadBalancerFrontEnd'.format(rg, lb))
|
||||
rule_ids = ' '.join(self.cmd('network lb inbound-nat-rule list -g {} --lb-name {} --query "[].id"'.format(rg, lb)).get_output_in_json())
|
||||
self.cmd('network lb address-pool create -g {} --lb-name {} -n bap1'.format(rg, lb))
|
||||
self.cmd('network lb address-pool create -g {} --lb-name {} -n bap2'.format(rg, lb))
|
||||
address_pool_ids = ' '.join(self.cmd('network lb address-pool list -g {} --lb-name {} --query "[].id"'.format(rg, lb)).get_output_in_json())
|
||||
|
||||
# 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')
|
||||
])
|
||||
# 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)
|
||||
])
|
||||
# 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')
|
||||
])
|
||||
# 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)
|
||||
])
|
||||
|
||||
# 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 delete --resource-group {} --name {}'.format(rg, nic))
|
||||
self.cmd('network nic list -g {}'.format(rg), checks=NoneCheck())
|
||||
|
||||
|
||||
class NetworkNicSubresourceScenarioTest(ResourceGroupVCRTestBase):
|
||||
def __init__(self, test_method):
|
||||
|
|
Загрузка…
Ссылка в новой задаче