You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sw...@apache.org on 2013/10/08 12:56:46 UTC
git commit: updated refs/heads/master to f6c6f03
Updated Branches:
refs/heads/master 6e80bb001 -> f6c6f03fa
CLOUDSTACK-702: 1. Moved common code to setupClass method 2. Added a test to deply vm in new CIDR and verify dns service on alias IP
Conflicts:
test/integration/component/maint/test_multiple_ip_ranges.py
Signed-off-by: sanjeevneelarapu <sa...@citrix.com>
Signed-off-by: venkataswamybabu budumuru <ve...@citrix.com>
(cherry picked from commit 1efd544ee27fd0c7c9eac4649568647c0dcbc85b)
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f6c6f03f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f6c6f03f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f6c6f03f
Branch: refs/heads/master
Commit: f6c6f03fad5dafa2f28a7a8e8b9d8ab89bf22bf8
Parents: 6e80bb0
Author: sanjeevneelarapu <sa...@citrix.com>
Authored: Thu Oct 3 22:34:55 2013 +0530
Committer: venkataswamybabu budumuru <ve...@citrix.com>
Committed: Tue Oct 8 16:26:18 2013 +0530
----------------------------------------------------------------------
.../component/maint/test_multiple_ip_ranges.py | 263 +++++++++++--------
1 file changed, 156 insertions(+), 107 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f6c6f03f/test/integration/component/maint/test_multiple_ip_ranges.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_multiple_ip_ranges.py b/test/integration/component/maint/test_multiple_ip_ranges.py
index 782957c..68b5979 100644
--- a/test/integration/component/maint/test_multiple_ip_ranges.py
+++ b/test/integration/component/maint/test_multiple_ip_ranges.py
@@ -59,11 +59,11 @@ class Services:
"ostype": "CentOS 5.3 (64-bit)",
"templatefilter": 'self',
},
- "vlan_ip_range": {
- "startip": "",
- "endip": "",
- "netmask": "",
- "gateway": "",
+ "vlan_ip_range": {
+ "startip": "10.147.43.130",
+ "endip": "10.147.43.135",
+ "netmask": "255.255.255.192",
+ "gateway": "10.147.43.129",
"forvirtualnetwork": "false",
"vlan": "untagged",
},
@@ -73,14 +73,12 @@ class Services:
"password": "password",
"hypervisor": 'XenServer',
},
- "cidr": {
- "name": "cidr1 -Test",
- "gateway" :"10.147.43.1",
- "netmask" :"255.255.255.128",
- "startip" :"10.147.43.3",
- "endip" :"10.147.43.10",
+ "host": {
+ "publicport": 22,
+ "username": "root", # Host creds for SSH
+ "password": "password",
},
- "ostype": "CentOS 5.3 (64-bit)",
+ "ostype": "CentOS 5.3 (64-bit)",
"sleep": 60,
"timeout": 10,
}
@@ -88,11 +86,10 @@ class Services:
class TestMultipleIpRanges(cloudstackTestCase):
"""Test Multiple IP Ranges for guest network
"""
-
-
@classmethod
def setUpClass(cls):
cls.api_client = super(TestMultipleIpRanges, cls).getClsTestClient().getApiClient()
+ cls.dbclient = super(TestMultipleIpRanges, cls).getClsTestClient().getDbConnection()
cls.services = Services().services
# Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client, cls.services)
@@ -122,7 +119,49 @@ class TestMultipleIpRanges(cloudstackTestCase):
)
cls.services["templates"]["ostypeid"] = cls.template.ostypeid
cls.services["diskoffering"] = cls.disk_offering.id
+ cls.dc_id = cls.dbclient.execute(
+ "select id from data_center where uuid = '%s';" % str(cls.services["zoneid"])
+ )
+ cls.dc_id = cls.dc_id[0][0]
+ cls.ids = cls.dbclient.execute(
+ "select id from user_ip_address where allocated is null and data_center_id = '%s';" % str(cls.dc_id)
+ )
+ cls.id_list = []
+ for i in range(len(cls.ids)):
+ cls.id_list.append(cls.ids[i][0])
+ #Check if VR is already present in the setup
+ vr_list = Router.list(cls.api_client, listall='true')
+ cls.debug("vr list {}".format(vr_list))
+ if isinstance(vr_list, list) and len(vr_list) > 0:
+ cls.debug("VR is running in the setup")
+ cls.vr_state = True
+ else:
+ cls.debug("VR is not present in the setup")
+ cls.vr_state = False
+ cls.id_list = cls.id_list[:-2]
+ for id in cls.id_list:
+ cls.dbclient.execute(
+ "update user_ip_address set allocated=now() where id = '%s';" % str(id)
+ )
+ #Add IP range in the new CIDR
+ cls.services["vlan_ip_range"]["zoneid"] = cls.zone.id
+ cls.services["vlan_ip_range"]["podid"] = cls.pod.id
+ #create new vlan ip range
+ cls.new_vlan = PublicIpRange.create(cls.api_client, cls.services["vlan_ip_range"])
+ #Deploy vm in existing subnet if VR is not present
+ if cls.vr_state is False :
+ cls.vm_res = VirtualMachine.create(
+ cls.api_client,
+ cls.services["server_without_disk"],
+ templateid = cls.template.id,
+ accountid = cls.account.name,
+ domainid = cls.services["domainid"],
+ zoneid = cls.services["zoneid"],
+ serviceofferingid = cls.service_offering.id,
+ mode = cls.services["mode"],
+ )
cls._cleanup = [
+ cls.new_vlan,
cls.account,
]
return
@@ -130,6 +169,10 @@ class TestMultipleIpRanges(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
try:
+ for id in cls.id_list:
+ cls.dbclient.execute(
+ "update user_ip_address set allocated=default where id = '%s';" % str(id)
+ )
#Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
@@ -184,94 +227,15 @@ class TestMultipleIpRanges(cloudstackTestCase):
)
return
- def list_Routers(self):
- """Check if any VR is already present in the setup
- Will return True if yes else return False
- """
- list_zone = Zone.list(self.apiclient)
- network_type = list_zone[0].networktype
- sg_enabled = list_zone[0].securitygroupsenabled
- if network_type == "Basic":
- vr_list = Router.list(self.apiclient, listall='true')
- self.debug("vr list {}".format(vr_list))
- if isinstance(vr_list,list) and len(vr_list) > 0:
- self.debug("VR is running in the setup")
- return True
- else:
- self.debug("VR is not present in the setup")
- return False
- elif network_type == "Advanced" and sg_enabled == True:
- nw_list = Network.list(
- self.apiclient,
- supportedservices='SecurityGroup',
- )
- nw_id = nw_list[0].id
- vr_list = Router.list(
- self.apiclient,
- networkid = nw_id,
- listall = 'true',
- )
- if isinstance(vr_list, list) and len(vr_list) > 0:
- self.debug("VR is present in the setup")
- return True
- else :
- self.debug("VR is not present in the setup")
- return False
- else :
- self.debug("Network type is not shared")
- return None
-
+ @attr(tags=["sg"])
def test_01_deploy_vm_in_new_cidr(self):
"""Deploy guest vm after adding guest IP range in new CIDR
-
- 1.Add IP range in new CIDR
- 2.Deploy guest vm
+ 1.Deploy guest vm
+ 2.Verify vm gets the ip address from new cidr
"""
- dc_id = self.dbclient.execute(
- "select id from data_center where uuid = '%s';" % str(self.services["zoneid"])
- )
- dc_id = dc_id[0][0]
- id_list = self.dbclient.execute(
- "select id from user_ip_address where allocated is null and data_center_id = '%s';" % str(dc_id)
- )
- ip_list = []
- for i in range(len(id_list)):
- ip_list.append(id_list[i][0])
- #Check if VR is already present in the setup
- vr_state = self.list_Routers();
- if vr_state is True :
- for id in ip_list:
- self.dbclient.execute(
- "update user_ip_address set allocated=now() where id = '%s';" % str(id)
- )
- else :
- ip_list = ip_list[:-2]
- for id in ip_list:
- self.dbclient.execute(
- "update user_ip_address set allocated=now() where id = '%s';" % str(id)
- )
- #Add IP range in the new CIDR
- test_gateway = self.services["cidr"]["gateway"]
- test_startIp = self.services["cidr"]["startip"]
- test_endIp = self.services["cidr"]["endip"]
- test_netmask = self.services["cidr"]["netmask"]
- #Populating services with new IP range
- self.services["vlan_ip_range"]["startip"] = test_startIp
- self.services["vlan_ip_range"]["endip"] = test_endIp
- self.services["vlan_ip_range"]["gateway"] = test_gateway
- self.services["vlan_ip_range"]["netmask"] = test_netmask
- self.services["vlan_ip_range"]["zoneid"] = self.zone.id
- self.services["vlan_ip_range"]["podid"] = self.pod.id
- #create new vlan ip range
- new_vlan = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
- self.debug("Created new vlan range with startip:%s and endip:%s" %(test_startIp,test_endIp))
- self.cleanup.append(new_vlan)
- new_vlan_res = new_vlan.list(self.apiclient,id=new_vlan.vlan.id)
- #Compare list output with configured values
- self.verify_vlan_range(new_vlan_res,self.services["vlan_ip_range"])
- #Deploy vm in existing subnet if VR is not present
- if vr_state is False :
- vm_res = VirtualMachine.create(
+ #Deploy guest vm
+ try :
+ self.virtual_machine = VirtualMachine.create(
self.apiclient,
self.services["server_without_disk"],
templateid = self.template.id,
@@ -281,7 +245,47 @@ class TestMultipleIpRanges(cloudstackTestCase):
serviceofferingid = self.service_offering.id,
mode = self.services["mode"],
)
- self.cleanup.append(vm_res)
+ except Exception as e :
+ raise Exception("Warning: Exception during vm deployment: {}".format(e))
+ self.vm_response = VirtualMachine.list(
+ self.apiclient,
+ id = self.virtual_machine.id
+ )
+ self.assertEqual(
+ isinstance(self.vm_response, list),
+ True,
+ "Check VM list response returned a valid list"
+ )
+ self.ip_range = list(netaddr.iter_iprange(unicode(self.services["vlan_ip_range"]["startip"]), unicode(self.services["vlan_ip_range"]["endip"])))
+ self.nic_ip = netaddr.IPAddress(unicode(self.vm_response[0].nic[0].ipaddress))
+ self.debug("vm got {} as ip address".format(self.nic_ip))
+ self.assertIn(
+ self.nic_ip,
+ self.ip_range,
+ "VM did not get the ip address from the new ip range"
+ )
+ self.virtual_machine.delete(self.apiclient)
+ expunge_del = Configurations.list(
+ self.apiclient,
+ name = 'expunge.delay'
+ )
+ expunge_int = Configurations.list(
+ self.apiclient,
+ name = 'expunge.interval'
+ )
+ wait_time = int(expunge_del[0].value) + int(expunge_int[0].value) + int(30)
+
+ self.debug("Waiting for {} seconds for the vm to expunge".format(wait_time))
+ #wait for the vm to expunge
+ time.sleep(wait_time)
+ return
+
+ @attr(tags=["sg"])
+ def test_02_deploy_vm_in_new_cidr(self):
+ """Deploy guest vm in new CIDR and verify
+ 1.Deploy guest vm in new cidr
+ 2.Verify dns service listens on alias ip in VR
+ """
#Deploy guest vm
try :
self.virtual_machine = VirtualMachine.create(
@@ -296,12 +300,6 @@ class TestMultipleIpRanges(cloudstackTestCase):
)
except Exception as e :
raise Exception("Warning: Exception during vm deployment: {}".format(e))
- finally :
- #Mark ip_Adddresses allocated state to Null which were marked as allocated at the beginning of the test
- for id in ip_list :
- self.dbclient.execute(
- "update user_ip_address set allocated=default where id = '%s';" % str(id)
- )
self.vm_response = VirtualMachine.list(
self.apiclient,
id = self.virtual_machine.id
@@ -311,7 +309,7 @@ class TestMultipleIpRanges(cloudstackTestCase):
True,
"Check VM list response returned a valid list"
)
- self.ip_range = list(netaddr.iter_iprange(unicode(self.services["cidr"]["startip"]), unicode(self.services["cidr"]["endip"])))
+ self.ip_range = list(netaddr.iter_iprange(unicode(self.services["vlan_ip_range"]["startip"]), unicode(self.services["vlan_ip_range"]["endip"])))
self.nic_ip = netaddr.IPAddress(unicode(self.vm_response[0].nic[0].ipaddress))
self.debug("vm got {} as ip address".format(self.nic_ip))
self.assertIn(
@@ -319,6 +317,57 @@ class TestMultipleIpRanges(cloudstackTestCase):
self.ip_range,
"VM did not get the ip address from the new ip range"
)
+ ip_alias = self.dbclient.execute(
+ "select ip4_address from nic_ip_alias;"
+ )
+ alias_ip = str(ip_alias[0][0])
+ self.debug("alias ip : %s" % alias_ip)
+ list_router_response = list_routers(
+ self.apiclient,
+ zoneid=self.zone.id,
+ listall=True
+ )
+ self.assertEqual(
+ isinstance(list_router_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ router = list_router_response[0]
+ hosts = list_hosts(
+ self.apiclient,
+ zoneid=router.zoneid,
+ type='Routing',
+ state='Up',
+ id=router.hostid
+ )
+ self.assertEqual(
+ isinstance(hosts, list),
+ True,
+ "Check list host returns a valid list"
+ )
+ host = hosts[0]
+ self.debug("Router ID: %s, state: %s" % (router.id, router.state))
+ self.assertEqual(
+ router.state,
+ 'Running',
+ "Check list router response for router state"
+ )
+ proc = alias_ip+":53"
+ result = get_process_status(
+ host.ipaddress,
+ self.services['host']["publicport"],
+ self.services['host']["username"],
+ self.services['host']["password"],
+ router.linklocalip,
+ "netstat -atnp | grep %s" % proc
+ )
+ res = str(result)
+ self.debug("Dns process status on alias ip: %s" % res)
+ self.assertNotEqual(
+ res.find(proc)
+ -1,
+ "dnsmasq service is not running on alias ip"
+ )
self.virtual_machine.delete(self.apiclient)
expunge_del = Configurations.list(
self.apiclient,