You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by gi...@apache.org on 2014/01/14 06:50:01 UTC

git commit: updated refs/heads/master to 842b58d

Updated Branches:
  refs/heads/master a957d52a3 -> 842b58d6e


CLOUDTACK-5626: Made few changes to test_vpc_vm_life_cycle.py


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

Branch: refs/heads/master
Commit: 842b58d6ee6038a43f11caf3929fe4e7504409d4
Parents: a957d52
Author: Girish Shilamkar <gi...@clogeny.com>
Authored: Tue Jan 14 11:13:48 2014 +0530
Committer: Girish Shilamkar <gi...@clogeny.com>
Committed: Tue Jan 14 11:19:22 2014 +0530

----------------------------------------------------------------------
 .../component/test_vpc_vm_life_cycle.py         | 104 ++++++++++++-------
 1 file changed, 67 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/842b58d6/test/integration/component/test_vpc_vm_life_cycle.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_vm_life_cycle.py b/test/integration/component/test_vpc_vm_life_cycle.py
index 5ce94f2..01373ac 100644
--- a/test/integration/component/test_vpc_vm_life_cycle.py
+++ b/test/integration/component/test_vpc_vm_life_cycle.py
@@ -18,13 +18,31 @@
 """ Component tests VM life cycle in VPC network functionality
 """
 #Import Local Modules
-import marvin
 from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.cloudstackTestCase import cloudstackTestCase, unittest
+from marvin.integration.lib.utils import cleanup_resources, validateList
+from marvin.integration.lib.base import (VirtualMachine,
+                                         NATRule,
+                                         LoadBalancerRule,
+                                         StaticNATRule,
+                                         PublicIPAddress,
+                                         VPC,
+                                         VpcOffering,
+                                         Network,
+                                         NetworkOffering,
+                                         NetworkACL,
+                                         Router,
+                                         Account,
+                                         ServiceOffering,
+                                         Host)
+from marvin.integration.lib.common import (get_domain,
+                                           get_zone,
+                                           get_template,
+                                           get_free_vlan,
+                                           wait_for_cleanup,
+                                           list_virtual_machines,
+                                           list_hosts)
+
 from marvin.codes import PASS
 
 import time
@@ -644,6 +662,13 @@ class TestVMLifeCycleVPC(cloudstackTestCase):
                          True,
                          "List LB rules shall return a valid list"
                          )
+
+        #Recover the instances so that they don't get expunged before runing next test case in the suite
+        try:
+            self.vm_1.recover(self.apiclient)
+            self.vm_2.recover(self.apiclient)
+        except Exception as e:
+            self.fail("Failed to recover the virtual instances, %s" % e)
         return
 
     @attr(tags=["advanced", "intervlan"])
@@ -690,6 +715,11 @@ class TestVMLifeCycleVPC(cloudstackTestCase):
         #    works as expected.
         # 3. Make sure that we are able to access google.com from this user Vm
 
+        vm_list = VirtualMachine.list(self.apiclient, id=self.vm_1.id)
+        self.assertEqual(validateList(vm_list)[0], PASS, "vm list validation failed, vm list is %s" % vm_list)
+
+        vm_hostid = vm_list[0].hostid
+
         self.debug("Checking if the host is available for migration?")
         hosts = Host.list(
                           self.apiclient,
@@ -707,7 +737,7 @@ class TestVMLifeCycleVPC(cloudstackTestCase):
             "No host available for migration. Test requires atleast 2 hosts")
 
         # Remove the host of current VM from the hosts list
-        hosts[:] = [host for host in hosts if host.id != self.vm_1.hostid]
+        hosts[:] = [host for host in hosts if host.id != vm_hostid]
 
         host = hosts[0]
 
@@ -847,17 +877,17 @@ class TestVMLifeCycleVPC(cloudstackTestCase):
         # Check if the network rules still exists after Vm stop
         self.debug("Checking if NAT rules existed")
         with self.assertRaises(Exception):
-            nat_rules = NATRule.list(
-                                     self.apiclient,
-                                     id=self.nat_rule.id,
-                                     listall=True
-                                     )
+            NATRule.list(
+                         self.apiclient,
+                         id=self.nat_rule.id,
+                         listall=True
+                         )
 
-            lb_rules = LoadBalancerRule.list(
-                                         self.apiclient,
-                                         id=self.lb_rule.id,
-                                         listall=True
-                                         )
+            LoadBalancerRule.list(
+                                  self.apiclient,
+                                  id=self.lb_rule.id,
+                                  listall=True
+                                  )
         return
 
 class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
@@ -1651,17 +1681,17 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
         # Check if the network rules still exists after Vm expunged
         self.debug("Checking if NAT rules existed ")
         with self.assertRaises(Exception):
-            nat_rules = NATRule.list(
-                                     self.apiclient,
-                                     id=self.nat_rule.id,
-                                     listall=True
-                                     )
+            NATRule.list(
+                         self.apiclient,
+                         id=self.nat_rule.id,
+                         listall=True
+                         )
 
-            lb_rules = LoadBalancerRule.list(
-                                         self.apiclient,
-                                         id=self.lb_rule.id,
-                                         listall=True
-                                         )
+            LoadBalancerRule.list(
+                                  self.apiclient,
+                                  id=self.lb_rule.id,
+                                  listall=True
+                                  )
         return
 
 class TestVMLifeCycleBothIsolated(cloudstackTestCase):
@@ -2687,17 +2717,17 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase):
         # Check if the network rules still exists after Vm expunged
         self.debug("Checking if NAT rules existed ")
         with self.assertRaises(Exception):
-            nat_rules = NATRule.list(
-                                     self.apiclient,
-                                     id=self.nat_rule.id,
-                                     listall=True
-                                     )
+            NATRule.list(
+                         self.apiclient,
+                         id=self.nat_rule.id,
+                         listall=True
+                         )
 
-            lb_rules = LoadBalancerRule.list(
-                                         self.apiclient,
-                                         id=self.lb_rule.id,
-                                         listall=True
-                                         )
+            LoadBalancerRule.list(
+                                  self.apiclient,
+                                  id=self.lb_rule.id,
+                                  listall=True
+                                  )
         return
 
 class TestVMLifeCycleDiffHosts(cloudstackTestCase):