diff --git a/test/integration/component/test_resource_limits.py b/test/integration/component/test_resource_limits.py index 07fc5a5ce72..b543e7b0024 100644 --- a/test/integration/component/test_resource_limits.py +++ b/test/integration/component/test_resource_limits.py @@ -17,14 +17,29 @@ """ P1 tests for Resource limits """ #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 * -import datetime +from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.integration.lib.base import (VirtualMachine, + Snapshot, + Template, + PublicIPAddress, + Account, + Domain, + Volume, + Network, + DiskOffering, + NetworkOffering, + ServiceOffering, + Configurations) +from marvin.integration.lib.common import (list_volumes, + get_domain, + get_zone, + get_template, + update_resource_limit, + list_configurations, + wait_for_cleanup) +from marvin.integration.lib.utils import cleanup_resources +import time class Services: @@ -174,6 +189,8 @@ class TestResourceLimitsAccount(cloudstackTestCase): try: #Clean up, terminate the created instance, volumes and snapshots cleanup_resources(self.apiclient, self.cleanup) + # Wait for VMs to expunge + wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"]) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @@ -362,13 +379,13 @@ class TestResourceLimitsAccount(cloudstackTestCase): # Exception should be raised for second instance (account_1) with self.assertRaises(Exception): - public_ip_2 = PublicIPAddress.create( - self.apiclient, - virtual_machine_1.account, - virtual_machine_1.zoneid, - virtual_machine_1.domainid, - self.services["server"] - ) + PublicIPAddress.create( + self.apiclient, + virtual_machine_1.account, + virtual_machine_1.zoneid, + virtual_machine_1.domainid, + self.services["server"] + ) self.debug( "Associating public IP for account: %s" % @@ -537,7 +554,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.debug("Creating snapshot from volume: %s" % volumes[0].id) # Create a snapshot from the ROOTDISK (Account 2) snapshot_2 = Snapshot.create(self.apiclient, - volumes[0].id, + volume.id, account=self.account_2.name, domainid=self.account_2.domainid, ) @@ -555,7 +572,7 @@ class TestResourceLimitsAccount(cloudstackTestCase): self.debug("Creating snapshot from volume: %s" % volumes[0].id) # Create a second snapshot from the ROOTDISK (Account 2) snapshot_3 = Snapshot.create(self.apiclient, - volumes[0].id, + volume.id, account=self.account_2.name, domainid=self.account_2.domainid, ) @@ -940,6 +957,8 @@ class TestResourceLimitsDomain(cloudstackTestCase): try: #Clean up, terminate the created instance, volumes and snapshots cleanup_resources(self.apiclient, self.cleanup) + # Wait for VMs to expunge + wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"]) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @@ -1071,13 +1090,13 @@ class TestResourceLimitsDomain(cloudstackTestCase): # Exception should be raised for second Public IP with self.assertRaises(Exception): - public_ip_2 = PublicIPAddress.create( - self.apiclient, - virtual_machine_1.account, - virtual_machine_1.zoneid, - virtual_machine_1.domainid, - self.services["server"] - ) + PublicIPAddress.create( + self.apiclient, + virtual_machine_1.account, + virtual_machine_1.zoneid, + virtual_machine_1.domainid, + self.services["server"] + ) return @attr(speed="slow") @@ -1140,7 +1159,7 @@ class TestResourceLimitsDomain(cloudstackTestCase): self.debug("Creating snapshot from volume: %s" % volumes[0].id) # Create a snapshot from the ROOTDISK snapshot_1 = Snapshot.create(self.apiclient, - volumes[0].id, + volume.id, account=self.account.name, domainid=self.account.domainid, ) @@ -1158,7 +1177,7 @@ class TestResourceLimitsDomain(cloudstackTestCase): # Exception should be raised for second snapshot with self.assertRaises(Exception): Snapshot.create(self.apiclient, - volumes[0].id, + volume.id, account=self.account.name, domainid=self.account.domainid, )