cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [18/24] git commit: updated refs/heads/4.4 to e33d4a5
Date Mon, 28 Jul 2014 15:44:45 GMT
CLOUDSTACK-5342: Fix for failure in adding network to VM

(cherry picked from commit 24ef79aef82b69015c6e552258c4829d5a15a9d8)


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/79eae73a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/79eae73a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/79eae73a

Branch: refs/heads/4.4
Commit: 79eae73add39a795c4e1202483ebce4609b6dc31
Parents: 51442f3
Author: Gaurav Aradhye <gaurav.aradhye@clogeny.com>
Authored: Tue May 27 14:44:59 2014 +0530
Committer: Daan Hoogland <daan@onecht.net>
Committed: Mon Jul 28 17:43:27 2014 +0200

----------------------------------------------------------------------
 .../component/test_add_remove_network.py        | 55 ++++++++++++++++----
 tools/marvin/marvin/lib/base.py                 |  4 ++
 2 files changed, 50 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79eae73a/test/integration/component/test_add_remove_network.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_add_remove_network.py b/test/integration/component/test_add_remove_network.py
index 2aadb5b..a4e8254 100644
--- a/test/integration/component/test_add_remove_network.py
+++ b/test/integration/component/test_add_remove_network.py
@@ -292,7 +292,14 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
         self.debug("virtual machine nics: %s" % vm_list[0].nic)
         nics = [x for x in vm_list[0].nic if x.networkid == network.id]
         self.debug("Filtered nics list: %s:" % nics)
-        self.addednics.append(nics[-1])
+
+        # Only the nics added to self.virtual_machine should be added to this list
+        # Nics added to his list are removed before execution of next test case because we
are using
+        # same virtual machine in all test cases, so it is important that the common
+        # virtual machine should contain only the default nic whenever new test case
+        # execution starts
+        if vm.id == self.virtual_machine.id:
+            self.addednics.append(nics[-1])
 
         self.assertTrue(len(nics) == 1, "nics list should contain the nic of added isolated
network,\
                         the number of nics for the network should be 1, instead they are
%s" %
@@ -392,12 +399,23 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
         if network is None:
             self.skipTest("Network should not be none. Case not handled for Network of type
%s" % value)
 
+        try:
+            virtual_machine = VirtualMachine.create(
+                self.api_client, self.services["virtual_machine"],
+                accountid=self.account.name, domainid=self.account.domainid,
+                serviceofferingid=self.service_offering.id,
+                mode=self.zone.networktype,
+                networkids=[self.defaultNetworkId])
+            self.cleanup.append(virtual_machine)
+        except Exception as e:
+            self.fail("Failed to deply virtual machine: %s" % e)
+
         # Adding network to vm for the first time
-        self.addNetworkToVm(network, self.virtual_machine)
+        self.addNetworkToVm(network, virtual_machine)
 
         # Trying to add same network to vm for the second time
         with self.assertRaises(Exception) as e:
-            self.addNetworkToVm(network, self.virtual_machine)
+            self.addNetworkToVm(network, virtual_machine)
             self.debug("Adding same network again failed with exception: %s" % e.exception)
 
         return
@@ -415,8 +433,19 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
         # Validate the following:
         # 1. Adding VPC to vm should fail
 
+        try:
+            virtual_machine = VirtualMachine.create(
+                self.api_client, self.services["virtual_machine"],
+                accountid=self.account.name, domainid=self.account.domainid,
+                serviceofferingid=self.service_offering.id,
+                mode=self.zone.networktype,
+                networkids=[self.defaultNetworkId])
+            self.cleanup.append(virtual_machine)
+        except Exception as e:
+            self.fail("Failed to deply virtual machine: %s" % e)
+
         network = self.isolated_network
-        self.addNetworkToVm(network, self.virtual_machine)
+        self.addNetworkToVm(network, virtual_machine)
 
         self.debug("Creating VPC offering")
         vpc_off = VpcOffering.create(self.api_client,self.services["vpc_offering"])
@@ -432,11 +461,10 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
 
         self.debug("Trying to add VPC to vm belonging to isolated network, this should fail")
         with self.assertRaises(Exception):
-            self.virtual_machine.add_nic(self.apiclient, vpc.id)
+            virtual_machine.add_nic(self.apiclient, vpc.id)
 
         self.debug("Disabling vpc offering: %s" % vpc_off.id)
         vpc_off.update(self.apiclient, state='Disabled')
-
         return
 
     @attr(tags = ["advanced"])
@@ -499,10 +527,20 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
         # 2. The newly added nic has the ip address same as
         #    that passed while adding the network
 
+        try:
+            virtual_machine = VirtualMachine.create(
+                self.api_client, self.services["virtual_machine"],
+                accountid=self.account.name, domainid=self.account.domainid,
+                serviceofferingid=self.service_offering.id,
+                mode=self.zone.networktype,
+                networkids=[self.defaultNetworkId])
+            self.cleanup.append(virtual_machine)
+        except Exception as e:
+            self.fail("Failed to deply virtual machine: %s" % e)
+
         ipaddress = self.shared_nw_endip
         self.debug("Adding network to vm with ip address %s: " % ipaddress)
-        self.addNetworkToVm(self.shared_network, self.virtual_machine,ipaddress = ipaddress)
-
+        self.addNetworkToVm(self.shared_network, virtual_machine,ipaddress = ipaddress)
         return
 
     @attr(tags = ["advanced"])
@@ -1077,7 +1115,6 @@ class TestUpdateVirtualMachineNIC(cloudstackTestCase):
                 serviceofferingid=self.service_offering.id,mode=self.zone.networktype)
         time.sleep(self.services["sleep"])
         self.debug("Deployed virtual machine: %s" % virtual_machine.id)
-     
         foreignNicId = virtual_machine.nic[0].id
 
         self.debug("Trying to set nic of new virtual machine as default nic of existing virtual
machine, This \

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/79eae73a/tools/marvin/marvin/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py
index c7b7083..2cd7009 100644
--- a/tools/marvin/marvin/lib/base.py
+++ b/tools/marvin/marvin/lib/base.py
@@ -475,6 +475,10 @@ class VirtualMachine:
         cmd = startVirtualMachine.startVirtualMachineCmd()
         cmd.id = self.id
         apiclient.startVirtualMachine(cmd)
+        response = self.getState(apiclient, VirtualMachine.RUNNING)
+        if response[0] == FAIL:
+            raise Exception(response[1])
+        return
 
     def stop(self, apiclient, forced=None):
         """Stop the instance"""


Mime
View raw message