cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gir...@apache.org
Subject git commit: updated refs/heads/master to 0cc826a
Date Tue, 27 May 2014 09:15:25 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master fa05cfbc7 -> 0cc826aa5


CLOUDSTACK-5342: Fix for failure in adding network to VM


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

Branch: refs/heads/master
Commit: 0cc826aa53286f66232d6287aa05341f0138cdd1
Parents: fa05cfb
Author: Gaurav Aradhye <gaurav.aradhye@clogeny.com>
Authored: Tue May 27 14:44:59 2014 +0530
Committer: Girish Shilamkar <girish@clogeny.com>
Committed: Tue May 27 14:44:59 2014 +0530

----------------------------------------------------------------------
 .../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/0cc826aa/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 c17293d..20aefe4 100644
--- a/test/integration/component/test_add_remove_network.py
+++ b/test/integration/component/test_add_remove_network.py
@@ -290,7 +290,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" %
@@ -386,12 +393,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
@@ -409,8 +427,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"])
@@ -426,11 +455,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"])
@@ -487,10 +515,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"])
@@ -1065,7 +1103,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/0cc826aa/tools/marvin/marvin/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py
index e0aad3c..a301e25 100755
--- a/tools/marvin/marvin/lib/base.py
+++ b/tools/marvin/marvin/lib/base.py
@@ -497,6 +497,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