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 e62df62
Date Fri, 25 Jul 2014 13:45:54 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 97b9e8656 -> e62df62d9


Code rector - using library functions instead of repetative code


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

Branch: refs/heads/master
Commit: e62df62d924a96d99c2d7f5e5ee8b0af67e68428
Parents: 97b9e86
Author: Gaurav Aradhye <gaurav.aradhye@clogeny.com>
Authored: Fri Jul 25 01:51:12 2014 -0400
Committer: Girish Shilamkar <girish@clogeny.com>
Committed: Fri Jul 25 19:15:28 2014 +0530

----------------------------------------------------------------------
 test/integration/component/test_stopped_vm.py | 471 ++-------------------
 1 file changed, 35 insertions(+), 436 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e62df62d/test/integration/component/test_stopped_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_stopped_vm.py b/test/integration/component/test_stopped_vm.py
index 04dd859..5eec405 100644
--- a/test/integration/component/test_stopped_vm.py
+++ b/test/integration/component/test_stopped_vm.py
@@ -32,15 +32,13 @@ from marvin.lib.base import (Account,
                              Iso,
                              Cluster,
                              StoragePool,
-                             Configurations,
                              Template)
 from marvin.lib.common import (get_zone,
                                get_domain,
                                get_template,
                                get_builtin_template_info,
                                update_resource_limit)
-#Import System modules
-import time
+from marvin.codes import PASS
 
 
 class Services:
@@ -206,31 +204,8 @@ class TestDeployVM(cloudstackTestCase):
                                     mode=self.zone.networktype
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-
-                            vm_response.state,
-                            "Running",
-                            "VM should be in Running state after deployment"
-                        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.RUNNING)
+        self.assertEqual(response[0], PASS, response[1])
         return
 
     @attr(tags=["advanced", "eip", "advancedns", "basic", "sg", "selfservice"])
@@ -257,31 +232,8 @@ class TestDeployVM(cloudstackTestCase):
                                     mode=self.zone.networktype
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-
-                            vm_response.state,
-                            "Running",
-                            "VM should be in Running state after deployment"
-                        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.RUNNING)
+        self.assertEqual(response[0], PASS, response[1])
         return
 
     @attr(tags=["advanced", "eip", "advancedns", "basic", "sg", "selfservice"])
@@ -309,30 +261,8 @@ class TestDeployVM(cloudstackTestCase):
                                     diskofferingid=self.disk_offering.id,
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-            vm_response.state,
-            "Stopped",
-            "VM should be in Stopped state after deployment with startvm=false"
-        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.STOPPED)
+        self.assertEqual(response[0], PASS, response[1])
         routers = Router.list(
                               self.apiclient,
                               account=self.account.name,
@@ -345,35 +275,7 @@ class TestDeployVM(cloudstackTestCase):
                          "List routers should return empty response"
                          )
         self.debug("Destroying instance: %s" % self.virtual_machine.name)
-        self.virtual_machine.delete(self.apiclient)
-        self.debug("Instance is destroyed!")
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-        self.debug("Instance destroyed..waiting till expunge interval")
-
-        interval = Configurations.list(
-                                    self.apiclient,
-                                    name='expunge.interval'
-                                    )
-        delay = Configurations.list(
-                                    self.apiclient,
-                                    name='expunge.delay'
-                                    )
-        # Sleep to ensure that all resources are deleted
-        time.sleep((int(interval[0].value) + int(delay[0].value)))
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.assertEqual(
-                            list_vm_response,
-                            None,
-                            "Check list response returns a valid list"
-                        )
+        self.virtual_machine.delete(self.apiclient, expunge=True)
         return
 
     @attr(tags=["advanced", "eip", "advancedns", "basic", "sg", "selfservice"])
@@ -399,30 +301,8 @@ class TestDeployVM(cloudstackTestCase):
                                     diskofferingid=self.disk_offering.id,
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-            vm_response.state,
-            "Stopped",
-            "VM should be in Stopped state after deployment with startvm=false"
-        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.STOPPED)
+        self.assertEqual(response[0], PASS, response[1])
         self.debug("Creating a volume in account: %s" %
                                                     self.account.name)
         volume = Volume.create(
@@ -464,30 +344,8 @@ class TestDeployVM(cloudstackTestCase):
                                     startvm=False,
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-            vm_response.state,
-            "Stopped",
-            "VM should be in Stopped state after deployment with startvm=false"
-        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.STOPPED)
+        self.assertEqual(response[0], PASS, response[1])
         medium_service_off = ServiceOffering.create(
                                 self.apiclient,
                                 self.services["service_offering"]
@@ -540,30 +398,8 @@ class TestDeployVM(cloudstackTestCase):
                                     diskofferingid=self.disk_offering.id,
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-            vm_response.state,
-            "Stopped",
-            "VM should be in Stopped state after deployment with startvm=false"
-        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.STOPPED)
+        self.assertEqual(response[0], PASS, response[1])
         self.debug("Creating a volume in account: %s" %
                                                     self.account.name)
         volume = Volume.create(
@@ -623,30 +459,8 @@ class TestDeployVM(cloudstackTestCase):
                                     diskofferingid=self.disk_offering.id,
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-            vm_response.state,
-            "Stopped",
-            "VM should be in Stopped state after deployment with startvm=false"
-        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.STOPPED)
+        self.assertEqual(response[0], PASS, response[1])
         self.debug("Registering a ISO in account: %s" %
                                                     self.account.name)
         iso = Iso.create(
@@ -714,30 +528,8 @@ class TestDeployVM(cloudstackTestCase):
                                     startvm=False,
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine_1.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine_1.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-            vm_response.state,
-            "Stopped",
-            "VM should be in Stopped state after deployment with startvm=false"
-        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.STOPPED)
+        self.assertEqual(response[0], PASS, response[1])
 
         self.debug("Deploying instance in the account: %s" %
                                                 self.account.name)
@@ -880,29 +672,8 @@ class TestDeployVM(cloudstackTestCase):
                                     mode=self.zone.networktype
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-        self.assertEqual(
-                            vm_response.state,
-                            "Running",
-                            "VM should be in Running state after deployment"
-                        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.RUNNING)
+        self.assertEqual(response[0], PASS, response[1])
         try:
             self.virtual_machine.stop(self.apiclient)
         except Exception as e:
@@ -1041,31 +812,8 @@ class TestDeployHaEnabledVM(cloudstackTestCase):
                                     startvm=False
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-
-                            vm_response.state,
-                            "Stopped",
-                            "VM should be in Stopped state after deployment"
-                        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.STOPPED)
+        self.assertEqual(response[0], PASS, response[1])
         return
 
     @attr(tags=["advanced", "eip", "advancedns", "basic", "sg", "selfservice"])
@@ -1106,31 +854,8 @@ class TestDeployHaEnabledVM(cloudstackTestCase):
                                     startvm=True
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-
-                            vm_response.state,
-                            "Running",
-                            "VM should be in Running state after deployment"
-                        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.RUNNING)
+        self.assertEqual(response[0], PASS, response[1])
         return
 
     @attr(tags=["advanced", "eip", "advancedns", "basic", "sg", "selfservice"])
@@ -1155,31 +880,8 @@ class TestDeployHaEnabledVM(cloudstackTestCase):
                                     startvm=False
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-
-                            vm_response.state,
-                            "Stopped",
-                            "VM should be in Running state after deployment"
-                        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.STOPPED)
+        self.assertEqual(response[0], PASS, response[1])
         return
 
 
@@ -1272,31 +974,8 @@ class TestRouterStateAfterDeploy(cloudstackTestCase):
                                     startvm=False
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine_1.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine_1.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-
-                            vm_response.state,
-                            "Stopped",
-                            "VM should be in stopped state after deployment"
-                        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.STOPPED)
+        self.assertEqual(response[0], PASS, response[1])
         self.debug("Checking the router state after VM deployment")
         routers = Router.list(
                               self.apiclient,
@@ -1322,31 +1001,8 @@ class TestRouterStateAfterDeploy(cloudstackTestCase):
                                     startvm=True
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine_2.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine_2.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-
-                            vm_response.state,
-                            "Running",
-                            "VM should be in Running state after deployment"
-                        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.RUNNING)
+        self.assertEqual(response[0], PASS, response[1])
         self.debug("Checking the router state after VM deployment")
         routers = Router.list(
                               self.apiclient,
@@ -1368,21 +1024,7 @@ class TestRouterStateAfterDeploy(cloudstackTestCase):
                 )
         self.debug("Destroying the running VM:%s" %
                                         self.virtual_machine_2.name)
-        self.virtual_machine_2.delete(self.apiclient)
-        self.debug("Instance destroyed..waiting till expunge interval")
-
-        interval = Configurations.list(
-                                    self.apiclient,
-                                    name='expunge.interval'
-                                    )
-        delay = Configurations.list(
-                                    self.apiclient,
-                                    name='expunge.delay'
-                                    )
-        # Sleep to ensure that all resources are deleted
-        time.sleep((int(interval[0].value) + int(delay[0].value)) * 2)
-
-        self.debug("Checking the router state after VM deployment")
+        self.virtual_machine_2.delete(self.apiclient, expunge=True)
         routers = Router.list(
                               self.apiclient,
                               account=self.account.name,
@@ -1572,57 +1214,14 @@ class TestDeployVMFromTemplate(cloudstackTestCase):
                                     startvm=False,
                                 )
 
-        self.debug("Deployed instance in account: %s" %
-                                                    self.account.name)
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-
-                            vm_response.state,
-                            "Stopped",
-                            "VM should be in stopped state after deployment"
-                        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.STOPPED)
+        self.assertEqual(response[0], PASS, response[1])
         self.debug("Starting the instance: %s" % self.virtual_machine.name)
         self.virtual_machine.start(self.apiclient)
         self.debug("Started the instance: %s" % self.virtual_machine.name)
 
-        list_vm_response = VirtualMachine.list(
-                                                 self.apiclient,
-                                                 id=self.virtual_machine.id
-                                                 )
-
-        self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
-
-        self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        vm_response = list_vm_response[0]
-
-        self.assertEqual(
-                            vm_response.state,
-                            "Running",
-                            "VM should be in running state after deployment"
-                        )
+        response = self.virtual_machine.getState(self.apiclient, VirtualMachine.RUNNING)
+        self.assertEqual(response[0], PASS, response[1])
         return
 
 


Mime
View raw message