cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sangeet...@apache.org
Subject git commit: updated refs/heads/master to 76ef987
Date Wed, 12 Nov 2014 21:18:56 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 2042660a6 -> 76ef987e7


CLOUDSTACK-7876 - Fixed the script 'test_vpc_vm_life_cycle.py' - Destruction of VM before
it can be recovered needs to be prevented


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

Branch: refs/heads/master
Commit: 76ef987e7c5d2264281a941f56ee3c655c7aea66
Parents: 2042660
Author: Chandan Purushothama <Chandan.Purushothama@citrix.com>
Authored: Mon Nov 10 15:36:51 2014 -0800
Committer: Sangeetha Hariharan <sangeetha.hariharan@citrix.com>
Committed: Wed Nov 12 16:04:55 2014 -0800

----------------------------------------------------------------------
 .../component/test_vpc_vm_life_cycle.py         | 280 +++++++++++++++----
 1 file changed, 229 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/76ef987e/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 e8df680..84e27df 100644
--- a/test/integration/component/test_vpc_vm_life_cycle.py
+++ b/test/integration/component/test_vpc_vm_life_cycle.py
@@ -620,7 +620,7 @@ class TestVMLifeCycleVPC(cloudstackTestCase):
         self.validate_network_rules()
         return
 
-    @attr(tags=["advanced", "intervlan"])
+    @attr(tags=["advanced","multihost", "intervlan"])
     def test_05_destroy_instance_in_network(self):
         """ Test destroy an instance in VPC networks
         """
@@ -628,6 +628,11 @@ class TestVMLifeCycleVPC(cloudstackTestCase):
         # Validate the following
         # 1. Destory the virtual machines.
         # 2. Rules should be still configured on virtual router.
+        # 3. Recover the virtual machines.
+        # 4. Vm should be in stopped state. State both the instances
+        # 5. Make sure that all the PF,LB and Static NAT rules on this VM
+        #    works as expected.
+        # 6. Make sure that we are able to access google.com from this user Vm
 
         self.debug("Validating if the network rules work properly or not?")
         self.validate_network_rules()
@@ -636,10 +641,23 @@ class TestVMLifeCycleVPC(cloudstackTestCase):
                                                 self.account.name)
         try:
             self.vm_1.delete(self.apiclient, expunge=False)
-            self.vm_2.delete(self.apiclient, expunge=False)
+
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_1.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Destroyed',
+                    "VM state should be destroyed"
+                    )
+            
         except Exception as e:
             self.fail("Failed to stop the virtual instances, %s" % e)
-
+            
         # Check if the network rules still exists after Vm stop
         self.debug("Checking if NAT rules ")
         nat_rules = NATRule.list(
@@ -664,46 +682,108 @@ class TestVMLifeCycleVPC(cloudstackTestCase):
                          "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
+        self.debug("Recovering the expunged virtual machine vm1 in account: %s" %
+                                                self.account.name)
         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"])
-    def test_06_recover_instance_in_network(self):
-        """ Test recover an instance in VPC networks
-        """
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_1.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Stopped',
+                    "VM state should be stopped"
+                    )
 
-        self.debug("Deleted instacnes ..")
+        except Exception as e:
+            self.fail("Failed to recover the virtual instances, %s" % e)
+            
         try:
-            self.vm_1.delete(self.apiclient, expunge=False)
             self.vm_2.delete(self.apiclient, expunge=False)
+
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_2.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Destroyed',
+                    "VM state should be destroyed"
+                    )
+
         except Exception as e:
             self.fail("Failed to stop the virtual instances, %s" % e)
 
+        self.debug("Recovering the expunged virtual machine vm2 in account: %s" %
+                                                self.account.name)            
         try:
-            self.vm_1.recover(self.apiclient)
             self.vm_2.recover(self.apiclient)
+
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_2.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Stopped',
+                    "VM state should be stopped"
+                    )
         except Exception as e:
             self.fail("Failed to recover the virtual instances, %s" % e)
 
         self.debug("Starting the two instances..")
         try:
             self.vm_1.start(self.apiclient)
+
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_1.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Running',
+                    "VM state should be running"
+                    )
+
             self.vm_2.start(self.apiclient)
+
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_2.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Running',
+                    "VM state should be running"
+                    )
         except Exception as e:
             self.fail("Failed to start the instances, %s" % e)
 
         # Wait until vms are up
         time.sleep(120)
-
         self.debug("Validating if the network rules work properly or not?")
         self.validate_network_rules()
+
         return
 
+
     @attr(tags=["advanced", "intervlan"])
     def test_07_migrate_instance_in_network(self):
         """ Test migrate an instance in VPC networks
@@ -2412,7 +2492,7 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase):
         self.validate_network_rules()
         return
 
-    @attr(tags=["advanced", "intervlan"])
+    @attr(tags=["advanced","multihost", "intervlan"])
     def test_05_destroy_instance_in_network(self):
         """ Test destroy an instance in VPC networks
         """
@@ -2420,6 +2500,11 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase):
         # Validate the following
         # 1. Destory the virtual machines.
         # 2. Rules should be still configured on virtual router.
+        # 3. Recover the virtual machines.
+        # 4. Vm should be in stopped state. State both the instances
+        # 5. Make sure that all the PF,LB and Static NAT rules on this VM
+        #    works as expected.
+        # 6. Make sure that we are able to access google.com from this user Vm
 
         self.debug("Validating if the network rules work properly or not?")
         self.validate_network_rules()
@@ -2428,10 +2513,23 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase):
                                                 self.account.name)
         try:
             self.vm_1.delete(self.apiclient, expunge=False)
-            self.vm_2.delete(self.apiclient, expunge=False)
+
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_1.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Destroyed',
+                    "VM state should be destroyed"
+                    )
+            
         except Exception as e:
             self.fail("Failed to stop the virtual instances, %s" % e)
-
+            
         # Check if the network rules still exists after Vm stop
         self.debug("Checking if NAT rules ")
         nat_rules = NATRule.list(
@@ -2455,39 +2553,109 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase):
                          True,
                          "List LB rules shall return a valid list"
                          )
-        return
-
-    @attr(tags=["advanced", "intervlan"])
-    def test_06_recover_instance_in_network(self):
-        """ Test recover an instance in VPC networks
-        """
 
-        # Validate the following
-        # 1. Recover the virtual machines.
-        # 2. Vm should be in stopped state. State both the instances
-        # 3. Make sure that all the PF,LB and Static NAT rules on this VM
-        #    works as expected.
-        # 3. Make sure that we are able to access google.com from this user Vm
-
-        self.debug("Recovering the expunged virtual machines in account: %s" %
+        self.debug("Recovering the expunged virtual machine vm1 in account: %s" %
                                                 self.account.name)
         try:
             self.vm_1.recover(self.apiclient)
+
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_1.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Stopped',
+                    "VM state should be stopped"
+                    )
+
+        except Exception as e:
+            self.fail("Failed to recover the virtual instances, %s" % e)
+            
+        try:
+            self.vm_2.delete(self.apiclient, expunge=False)
+
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_2.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Destroyed',
+                    "VM state should be destroyed"
+                    )
+
+        except Exception as e:
+            self.fail("Failed to stop the virtual instances, %s" % e)
+
+        self.debug("Recovering the expunged virtual machine vm2 in account: %s" %
+                                                self.account.name)            
+        try:
             self.vm_2.recover(self.apiclient)
+
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_2.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Stopped',
+                    "VM state should be stopped"
+                    )
         except Exception as e:
             self.fail("Failed to recover the virtual instances, %s" % e)
 
         self.debug("Starting the two instances..")
         try:
             self.vm_1.start(self.apiclient)
+
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_1.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Running',
+                    "VM state should be running"
+                    )
+
             self.vm_2.start(self.apiclient)
+
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_2.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Running',
+                    "VM state should be running"
+                    )
         except Exception as e:
             self.fail("Failed to start the instances, %s" % e)
 
+        # Wait until vms are up
+        time.sleep(120)
         self.debug("Validating if the network rules work properly or not?")
         self.validate_network_rules()
+
         return
 
+
     @attr(tags=["advanced", "intervlan"])
     def test_07_migrate_instance_in_network(self):
         """ Test migrate an instance in VPC networks
@@ -3244,25 +3412,10 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase):
                     'Destroyed',
                     "VM state should be destroyed"
                     )
-
-            self.vm_2.delete(self.apiclient, expunge=False)
-
-            list_vm_response = list_virtual_machines(
-                                                 self.apiclient,
-                                                 id=self.vm_2.id
-                                                 )
-
-            vm_response = list_vm_response[0]
-
-            self.assertEqual(
-                    vm_response.state,
-                    'Destroyed',
-                    "VM state should be destroyed"
-                    )
-
+            
         except Exception as e:
             self.fail("Failed to stop the virtual instances, %s" % e)
-
+            
         # Check if the network rules still exists after Vm stop
         self.debug("Checking if NAT rules ")
         nat_rules = NATRule.list(
@@ -3287,7 +3440,7 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase):
                          "List LB rules shall return a valid list"
                          )
 
-        self.debug("Recovering the expunged virtual machines in account: %s" %
+        self.debug("Recovering the expunged virtual machine vm1 in account: %s" %
                                                 self.account.name)
         try:
             self.vm_1.recover(self.apiclient)
@@ -3305,6 +3458,31 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase):
                     "VM state should be stopped"
                     )
 
+        except Exception as e:
+            self.fail("Failed to recover the virtual instances, %s" % e)
+            
+        try:
+            self.vm_2.delete(self.apiclient, expunge=False)
+
+            list_vm_response = list_virtual_machines(
+                                                 self.apiclient,
+                                                 id=self.vm_2.id
+                                                 )
+
+            vm_response = list_vm_response[0]
+
+            self.assertEqual(
+                    vm_response.state,
+                    'Destroyed',
+                    "VM state should be destroyed"
+                    )
+
+        except Exception as e:
+            self.fail("Failed to stop the virtual instances, %s" % e)
+
+        self.debug("Recovering the expunged virtual machine vm2 in account: %s" %
+                                                self.account.name)            
+        try:
             self.vm_2.recover(self.apiclient)
 
             list_vm_response = list_virtual_machines(


Mime
View raw message