mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-2237: Automation - Adding new test cases for security group in advanced zone feature
This commit is contained in:
parent
cdf2a1161b
commit
4d9b95e13d
File diff suppressed because it is too large
Load Diff
159
tools/marvin/marvin/config/config.cfg
Normal file
159
tools/marvin/marvin/config/config.cfg
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
# Use the common configs added such as account, network_offerings, domain, project,
|
||||||
|
# or add your own data if required separately for any test case
|
||||||
|
{
|
||||||
|
"domain":
|
||||||
|
{
|
||||||
|
"name": "domain"
|
||||||
|
}
|
||||||
|
,
|
||||||
|
"project":
|
||||||
|
{
|
||||||
|
"name": "Project",
|
||||||
|
"displaytext": "Test project"
|
||||||
|
},
|
||||||
|
"account": {
|
||||||
|
"email": "test-account@test.com",
|
||||||
|
"firstname": "test",
|
||||||
|
"lastname": "test",
|
||||||
|
"username": "test-account",
|
||||||
|
"password": "password"
|
||||||
|
},
|
||||||
|
"service_offering": {
|
||||||
|
"name": "Tiny Instance",
|
||||||
|
"displaytext": "Tiny Instance",
|
||||||
|
"cpunumber": 1,
|
||||||
|
"cpuspeed": 100,
|
||||||
|
"memory": 128
|
||||||
|
},
|
||||||
|
"isolated_network_offering": {
|
||||||
|
"name": "Network offering-DA services",
|
||||||
|
"displaytext": "Network offering-DA services",
|
||||||
|
"guestiptype": "Isolated",
|
||||||
|
"supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
|
||||||
|
"traffictype": "GUEST",
|
||||||
|
"availability": "Optional'",
|
||||||
|
"serviceProviderList": {
|
||||||
|
"Dhcp": "VirtualRouter",
|
||||||
|
"Dns": "VirtualRouter",
|
||||||
|
"SourceNat": "VirtualRouter",
|
||||||
|
"PortForwarding": "VirtualRouter",
|
||||||
|
"Vpn": "VirtualRouter",
|
||||||
|
"Firewall": "VirtualRouter",
|
||||||
|
"Lb": "VirtualRouter",
|
||||||
|
"UserData": "VirtualRouter",
|
||||||
|
"StaticNat": "VirtualRouter"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"isolated_network": {
|
||||||
|
"name": "Isolated Network",
|
||||||
|
"displaytext": "Isolated Network"
|
||||||
|
},
|
||||||
|
"virtual_machine": {
|
||||||
|
"displayname": "Test VM",
|
||||||
|
"username": "root",
|
||||||
|
"password": "password",
|
||||||
|
"ssh_port": 22,
|
||||||
|
"privateport": 22,
|
||||||
|
"publicport": 22,
|
||||||
|
"protocol": "TCP"
|
||||||
|
},
|
||||||
|
"shared_network": {
|
||||||
|
"name": "MySharedNetwork - Test",
|
||||||
|
"displaytext": "MySharedNetwork",
|
||||||
|
"vlan" : "",
|
||||||
|
"gateway" :"",
|
||||||
|
"netmask" :"",
|
||||||
|
"startip" :"",
|
||||||
|
"endip" :"",
|
||||||
|
"acltype" : "Domain",
|
||||||
|
"scope":"all"
|
||||||
|
},
|
||||||
|
"shared_network_offering_sg": {
|
||||||
|
"name": "MySharedOffering-sg",
|
||||||
|
"displaytext": "MySharedOffering-sg",
|
||||||
|
"guestiptype": "Shared",
|
||||||
|
"supportedservices": "Dhcp,Dns,UserData,SecurityGroup",
|
||||||
|
"specifyVlan" : "False",
|
||||||
|
"specifyIpRanges" : "False",
|
||||||
|
"traffictype": "GUEST",
|
||||||
|
"serviceProviderList" : {
|
||||||
|
"Dhcp": "VirtualRouter",
|
||||||
|
"Dns": "VirtualRouter",
|
||||||
|
"UserData": "VirtualRouter",
|
||||||
|
"SecurityGroup": "SecurityGroupProvider"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"shared_network_sg": {
|
||||||
|
"name": "Shared-Network-SG-Test",
|
||||||
|
"displaytext": "Shared-Network_SG-Test",
|
||||||
|
"networkofferingid":"1",
|
||||||
|
"vlan" : "",
|
||||||
|
"gateway" :"",
|
||||||
|
"netmask" :"255.255.255.0",
|
||||||
|
"startip" :"",
|
||||||
|
"endip" :"",
|
||||||
|
"acltype" : "Domain",
|
||||||
|
"scope":"all"
|
||||||
|
},
|
||||||
|
"vpc_offering": {
|
||||||
|
"name": "VPC off",
|
||||||
|
"displaytext": "VPC off",
|
||||||
|
"supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,NetworkACL"
|
||||||
|
},
|
||||||
|
"vpc": {
|
||||||
|
"name": "TestVPC",
|
||||||
|
"displaytext": "TestVPC",
|
||||||
|
"cidr": "10.0.0.1/24"
|
||||||
|
},
|
||||||
|
"shared_network_offering": {
|
||||||
|
"name": "MySharedOffering",
|
||||||
|
"displaytext": "MySharedOffering",
|
||||||
|
"guestiptype": "Shared",
|
||||||
|
"supportedservices": "Dhcp,Dns,UserData",
|
||||||
|
"specifyVlan" : "False",
|
||||||
|
"specifyIpRanges" : "False",
|
||||||
|
"traffictype": "GUEST",
|
||||||
|
"serviceProviderList" : {
|
||||||
|
"Dhcp": "VirtualRouter",
|
||||||
|
"Dns": "VirtualRouter",
|
||||||
|
"UserData": "VirtualRouter"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security_group" : { "name": "custom_Sec_Grp" },
|
||||||
|
"ingress_rule": {
|
||||||
|
"protocol": "TCP",
|
||||||
|
"startport": "22",
|
||||||
|
"endport": "22",
|
||||||
|
"cidrlist": "0.0.0.0/0"
|
||||||
|
},
|
||||||
|
"ostype": "CentOS 5.3 (64-bit)",
|
||||||
|
"sleep": 90,
|
||||||
|
"timeout": 10,
|
||||||
|
"advanced_sg": {
|
||||||
|
"zone": {
|
||||||
|
"name": "",
|
||||||
|
"dns1": "8.8.8.8",
|
||||||
|
"internaldns1": "192.168.100.1",
|
||||||
|
"networktype": "Advanced",
|
||||||
|
"securitygroupenabled": "true"
|
||||||
|
},
|
||||||
|
"securitygroupenabled": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -330,7 +330,10 @@ class ConfigManager(object):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.filePath = "config/config.cfg"
|
# Joining path with current directory will avoid relative path issue
|
||||||
|
# It will take correct path irrespective of from where the test case is run
|
||||||
|
dirPath = os.path.dirname(__file__)
|
||||||
|
self.filePath = os.path.join(dirPath, 'config/config.cfg')
|
||||||
self.parsedDict = None
|
self.parsedDict = None
|
||||||
if self.__verifyFile(self.filePath) is not False:
|
if self.__verifyFile(self.filePath) is not False:
|
||||||
self.parsedDict = self.__parseConfig(self.filePath)
|
self.parsedDict = self.__parseConfig(self.filePath)
|
||||||
|
|||||||
@ -2262,6 +2262,8 @@ class Zone:
|
|||||||
cmd.internaldns2 = services["internaldns2"]
|
cmd.internaldns2 = services["internaldns2"]
|
||||||
if domainid:
|
if domainid:
|
||||||
cmd.domainid = domainid
|
cmd.domainid = domainid
|
||||||
|
if "securitygroupenabled" in services:
|
||||||
|
cmd.securitygroupenabled = services["securitygroupenabled"]
|
||||||
|
|
||||||
return Zone(apiclient.createZone(cmd).__dict__)
|
return Zone(apiclient.createZone(cmd).__dict__)
|
||||||
|
|
||||||
|
|||||||
@ -799,35 +799,45 @@ def get_free_vlan(apiclient, zoneid):
|
|||||||
assert len(list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
|
assert len(list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
|
||||||
|
|
||||||
physical_network = list_physical_networks_response[0]
|
physical_network = list_physical_networks_response[0]
|
||||||
vlans = xsplit(physical_network.vlan, ['-', ','])
|
|
||||||
|
|
||||||
assert len(vlans) > 0
|
|
||||||
assert int(vlans[0]) < int(vlans[-1]), "VLAN range %s was improperly split" % physical_network.vlan
|
|
||||||
|
|
||||||
usedVlanIds = []
|
|
||||||
networks = list_networks(apiclient, zoneid= zoneid, type='Shared')
|
networks = list_networks(apiclient, zoneid= zoneid, type='Shared')
|
||||||
|
usedVlanIds = []
|
||||||
|
|
||||||
if isinstance(networks, list) and len(networks) > 0:
|
if isinstance(networks, list) and len(networks) > 0:
|
||||||
usedVlanIds = [int(nw.vlan) for nw in networks]
|
usedVlanIds = [int(nw.vlan) for nw in networks if nw.vlan!="untagged"]
|
||||||
|
|
||||||
retriesCount = 20 #Assuming random function will give different integer each time
|
if hasattr(physical_network, "vlan") is False:
|
||||||
|
while True:
|
||||||
|
shared_ntwk_vlan = random.randrange(1,4095)
|
||||||
|
if shared_ntwk_vlan in usedVlanIds:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
vlans = xsplit(physical_network.vlan, ['-', ','])
|
||||||
|
|
||||||
shared_ntwk_vlan = None
|
assert len(vlans) > 0
|
||||||
|
assert int(vlans[0]) < int(vlans[-1]), "VLAN range %s was improperly split" % physical_network.vlan
|
||||||
|
|
||||||
while True:
|
retriesCount = 20 #Assuming random function will give different integer each time
|
||||||
|
|
||||||
if retriesCount == 0:
|
shared_ntwk_vlan = None
|
||||||
break
|
|
||||||
|
|
||||||
free_vlan = int(vlans[-1]) + random.randrange(1, 20)
|
while True:
|
||||||
|
|
||||||
if free_vlan > 4095:
|
if retriesCount == 0:
|
||||||
free_vlan = int(vlans[0]) - random.randrange(1, 20)
|
break
|
||||||
if free_vlan < 0 or (free_vlan in usedVlanIds):
|
|
||||||
retriesCount -= 1
|
free_vlan = int(vlans[-1]) + random.randrange(1, 20)
|
||||||
continue
|
|
||||||
else:
|
if free_vlan > 4095:
|
||||||
shared_ntwk_vlan = free_vlan
|
free_vlan = int(vlans[0]) - random.randrange(1, 20)
|
||||||
break
|
if free_vlan < 0 or (free_vlan in usedVlanIds):
|
||||||
|
retriesCount -= 1
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
shared_ntwk_vlan = free_vlan
|
||||||
|
break
|
||||||
|
|
||||||
return physical_network, shared_ntwk_vlan
|
return physical_network, shared_ntwk_vlan
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user