[Automation] fix CLOUDSTACK-2546 Failed to add second NIC to vm in KVM environment
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/47864209 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/47864209 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/47864209 Branch: refs/heads/rbd-snap-clone Commit: 4786420986b60955ca8f084f24b69f9d07153ab5 Parents: a69101d Author: Mice Xia <mice_...@tcloudcomputing.com> Authored: Thu May 23 09:54:46 2013 +0800 Committer: Mice Xia <mice_...@tcloudcomputing.com> Committed: Thu May 23 09:55:30 2013 +0800 ---------------------------------------------------------------------- test/integration/smoke/test_nic.py | 51 ++++++++++++++++++++++++++++--- 1 files changed, 46 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/47864209/test/integration/smoke/test_nic.py ---------------------------------------------------------------------- diff --git a/test/integration/smoke/test_nic.py b/test/integration/smoke/test_nic.py index bae6dfd..8e8d340 100644 --- a/test/integration/smoke/test_nic.py +++ b/test/integration/smoke/test_nic.py @@ -79,11 +79,35 @@ class Services: "PortForwarding": 'VirtualRouter', }, }, + "network_offering_shared": { + "name": 'Test Network offering shared', + "displaytext": 'Test Network offering Shared', + "guestiptype": 'Shared', + "supportedservices": 'Dhcp,Dns,UserData', + "traffictype": 'GUEST', + "specifyVlan" : "True", + "specifyIpRanges" : "True", + "serviceProviderList" : { + "Dhcp": 'VirtualRouter', + "Dns": 'VirtualRouter', + "UserData": 'VirtualRouter', + }, + }, "network": { "name": "Test Network", "displaytext": "Test Network", "acltype": "Account", }, + "network2": { + "name": "Test Network Shared", + "displaytext": "Test Network Shared", + "vlan" :1201, + "gateway" :"172.16.15.1", + "netmask" :"255.255.255.0", + "startip" :"172.16.15.21", + "endip" :"172.16.15.41", + "acltype": "Account", + }, # ISO settings for Attach/Detach ISO tests "iso": { "displaytext": "Test ISO", @@ -176,6 +200,14 @@ class TestDeployVM(cloudstackTestCase): self.network_offering.update(self.apiclient, state='Enabled') # Enable Network offering self.services["network"]["networkoffering"] = self.network_offering.id + self.network_offering_shared = NetworkOffering.create( + self.apiclient, + self.services["network_offering_shared"], + ) + self.cleanup.insert(0, self.network_offering_shared) + self.network_offering_shared.update(self.apiclient, state='Enabled') # Enable Network offering + self.services["network2"]["networkoffering"] = self.network_offering_shared.id + ################ ### Test Network self.test_network = Network.create( @@ -185,6 +217,14 @@ class TestDeployVM(cloudstackTestCase): self.account.domainid, ) self.cleanup.insert(0, self.test_network) + self.test_network2 = Network.create( + self.apiclient, + self.services["network2"], + self.account.name, + self.account.domainid, + zoneid=self.services["network"]["zoneid"] + ) + self.cleanup.insert(0, self.test_network2) except Exception as ex: self.debug("Exception during NIC test SETUP!: " + str(ex)) self.assertEqual(True, False, "Exception during NIC test SETUP!: " + str(ex)) @@ -201,10 +241,10 @@ class TestDeployVM(cloudstackTestCase): accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, - mode=self.services['mode'] + mode=self.services['mode'], + networkids=[self.test_network.id] ) self.cleanup.insert(0, self.virtual_machine) - list_vm_response = list_virtual_machines( self.apiclient, id=self.virtual_machine.id @@ -256,7 +296,7 @@ class TestDeployVM(cloudstackTestCase): existing_nic_id = vm_response.nic[0].id # 1. add a nic - add_response = self.virtual_machine.add_nic(self.apiclient, self.test_network.id) + add_response = self.virtual_machine.add_nic(self.apiclient, self.test_network2.id) time.sleep(5) # now go get the vm list? @@ -308,8 +348,9 @@ class TestDeployVM(cloudstackTestCase): sawException = True self.assertEqual(sawException, True, "Make sure we cannot delete the default NIC") - - self.virtual_machine.remove_nic(self.apiclient, existing_nic_id) + self.virtual_machine.update_default_nic(self.apiclient, existing_nic_id) + time.sleep(5) + self.virtual_machine.remove_nic(self.apiclient, new_nic_id) time.sleep(5) list_vm_response = list_virtual_machines(