From 42a861e5908b110bbb41145b09394bd86ef318e1 Mon Sep 17 00:00:00 2001 From: Gaurav Aradhye Date: Wed, 30 Jul 2014 03:36:27 -0700 Subject: [PATCH] CLOUDSTACK-7205: Adding expunge=True while deleting VM for test case execution speed improvement --- .../integration/component/test_brocade_vcs.py | 6 ++-- test/integration/component/test_eip_elb.py | 30 +------------------ .../component/test_escalations_networks.py | 2 +- .../component/test_multiple_ips_per_nic.py | 5 +--- test/integration/component/test_nuage_vsp.py | 4 +-- .../component/test_persistent_networks.py | 12 ++++---- .../component/test_project_resources.py | 5 +--- .../component/test_project_usage.py | 2 +- .../component/test_reset_ssh_keypair.py | 24 +++++++-------- .../component/test_security_groups.py | 17 +---------- test/integration/component/test_usage.py | 2 +- .../component/test_vm_passwdenabled.py | 2 +- 12 files changed, 30 insertions(+), 81 deletions(-) diff --git a/test/integration/component/test_brocade_vcs.py b/test/integration/component/test_brocade_vcs.py index 556de285c3b..a5eff53a6f3 100644 --- a/test/integration/component/test_brocade_vcs.py +++ b/test/integration/component/test_brocade_vcs.py @@ -317,13 +317,11 @@ class TestBrocadeVcs(cloudstackTestCase): ) # Deleting a single VM - VirtualMachine.delete(virtual_machine_1, self.apiclient) - VirtualMachine.expung(virtual_machine_1, self.apiclient) + VirtualMachine.delete(virtual_machine_1, self.apiclient, expunge=True) # Deleting a single VM - VirtualMachine.delete(virtual_machine_2, self.apiclient) - VirtualMachine.expung(virtual_machine_2, self.apiclient) + VirtualMachine.delete(virtual_machine_2, self.apiclient, expunge=True) # Delete Network diff --git a/test/integration/component/test_eip_elb.py b/test/integration/component/test_eip_elb.py index 0613c4d0535..c35ea9bd240 100644 --- a/test/integration/component/test_eip_elb.py +++ b/test/integration/component/test_eip_elb.py @@ -797,37 +797,9 @@ class TestEIP(cloudstackTestCase): )) self.debug("Destroying an instance: %s" % self.virtual_machine.name) - self.virtual_machine.delete(self.apiclient) + self.virtual_machine.delete(self.apiclient, expunge=True) self.debug("Destroy instance complete!") - config = list_configurations( - self.apiclient, - name='expunge.delay' - ) - self.assertEqual( - isinstance(config, list), - True, - "Check list configurations response" - ) - exp_delay = config[0] - self.debug("expunge.delay: %s" % exp_delay.value) - - config = list_configurations( - self.apiclient, - name='expunge.interval' - ) - self.assertEqual( - isinstance(config, list), - True, - "Check list configurations response" - ) - exp_interval = config[0] - self.debug("expunge.interval: %s" % exp_interval.value) - - # wait for exp_delay+exp_interval - cleans up VM - total_wait = int(exp_interval.value) + int(exp_delay.value) - time.sleep(total_wait) - vms = VirtualMachine.list( self.apiclient, id=self.virtual_machine.id diff --git a/test/integration/component/test_escalations_networks.py b/test/integration/component/test_escalations_networks.py index 6e12eefece1..66985e92027 100644 --- a/test/integration/component/test_escalations_networks.py +++ b/test/integration/component/test_escalations_networks.py @@ -1013,7 +1013,7 @@ class TestNetworks_1(cloudstackTestCase): ) instance_page2 = list_instances_page2[0] # Deleting a single VM - VirtualMachine.delete(vm_created, self.userapiclient) + VirtualMachine.delete(vm_created, self.userapiclient, expunge=True) # Listing the VM's in page 2 list_instance_response = VirtualMachine.list( self.userapiclient, diff --git a/test/integration/component/test_multiple_ips_per_nic.py b/test/integration/component/test_multiple_ips_per_nic.py index 570ddd2db65..24b85dfa8c0 100644 --- a/test/integration/component/test_multiple_ips_per_nic.py +++ b/test/integration/component/test_multiple_ips_per_nic.py @@ -965,10 +965,7 @@ class TestVmNetworkOperations(cloudstackTestCase): network.id, vmguestip=ipaddress_2.ipaddress) # Delete VM - virtual_machine.delete(self.apiclient) - - # Wait for VMs to expunge - wait_for_cleanup(self.api_client, ["expunge.delay", "expunge.interval"]) + virtual_machine.delete(self.apiclient, expunge=True) # Make sure the VM is expunged retriesCount = 20 diff --git a/test/integration/component/test_nuage_vsp.py b/test/integration/component/test_nuage_vsp.py index 143fe391a71..096b9d1b50d 100644 --- a/test/integration/component/test_nuage_vsp.py +++ b/test/integration/component/test_nuage_vsp.py @@ -301,10 +301,10 @@ class TestNuageVsp(cloudstackTestCase): "VM state should be running after deployment" ) - VirtualMachine.delete(virtual_machine_1, self.apiclient) + VirtualMachine.delete(virtual_machine_1, self.apiclient, expunge=True) # Deleting a single VM - VirtualMachine.delete(virtual_machine_2, self.apiclient) + VirtualMachine.delete(virtual_machine_2, self.apiclient, expunge=True) # Delete Network Network.delete(self.network, self.apiclient) diff --git a/test/integration/component/test_persistent_networks.py b/test/integration/component/test_persistent_networks.py index 016a39122bc..210063ee1c9 100644 --- a/test/integration/component/test_persistent_networks.py +++ b/test/integration/component/test_persistent_networks.py @@ -164,7 +164,7 @@ class TestPersistentNetworks(cloudstackTestCase): """verify if vm is expunged""" isVmExpunged = False try: - virtual_machine.delete(self.apiclient) + virtual_machine.delete(self.apiclient, expunge=True) except Exception as e: self.fail("Failed to delete VM: %s with error %s" % (virtual_machine.id, e)) @@ -232,7 +232,7 @@ class TestPersistentNetworks(cloudstackTestCase): virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"], networkids=[network.id],serviceofferingid=self.service_offering.id, accountid=self.account.name,domainid=self.domain.id) - virtual_machine.delete(self.apiclient) + virtual_machine.delete(self.apiclient, expunge=True) except Exception as e: self.fail("vm creation failed: %s" % e) @@ -378,7 +378,7 @@ class TestPersistentNetworks(cloudstackTestCase): self.fail("Exception while SSHing to VM %s with IP %s" % (virtual_machine.id, ipaddress.ipaddress.ipaddress)) # Delete VM - virtual_machine.delete(self.api_client) + virtual_machine.delete(self.api_client, expunge=True) # Verify VM is expunged self.verifyVmExpungement(virtual_machine) @@ -457,7 +457,7 @@ class TestPersistentNetworks(cloudstackTestCase): except Exception as e: self.fail("Exception while SSHing to VM %s with IP %s" % (virtual_machine.id, ipaddress.ipaddress.ipaddress)) - virtual_machine.delete(self.api_client) + virtual_machine.delete(self.api_client, expunge=True) # Verify VM is expunged self.verifyVmExpungement(virtual_machine) @@ -540,7 +540,7 @@ class TestPersistentNetworks(cloudstackTestCase): except Exception as e: self.fail("Exception while SSHing to VM %s with IP %s" % (virtual_machine.id, ipaddress.ipaddress.ipaddress)) - virtual_machine.delete(self.api_client) + virtual_machine.delete(self.api_client, expunge=True) # Verify VM is expunged self.verifyVmExpungement(virtual_machine) @@ -919,7 +919,7 @@ class TestPersistentNetworks(cloudstackTestCase): self.fail("Exception while SSHing to VM %s with IP %s" % (virtual_machine.id, ipaddress.ipaddress.ipaddress)) # Delete VM - virtual_machine.delete(self.api_client) + virtual_machine.delete(self.api_client, expunge=True) # Verify VM is expunged self.verifyVmExpungement(virtual_machine) diff --git a/test/integration/component/test_project_resources.py b/test/integration/component/test_project_resources.py index 4f61cb0cabb..e533ca30117 100644 --- a/test/integration/component/test_project_resources.py +++ b/test/integration/component/test_project_resources.py @@ -534,10 +534,7 @@ class TestNetwork(cloudstackTestCase): ) # Delete VM before network gets deleted in cleanup - virtual_machine.delete(self.apiclient) - - # Wait for expunge interval to cleanup VM - wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"]) + virtual_machine.delete(self.apiclient, expunge=True) return diff --git a/test/integration/component/test_project_usage.py b/test/integration/component/test_project_usage.py index e8ed1b193d9..512156dfe67 100644 --- a/test/integration/component/test_project_usage.py +++ b/test/integration/component/test_project_usage.py @@ -227,7 +227,7 @@ class TestVmUsage(cloudstackTestCase): try: # Destroy the VM self.debug("Destroying the VM: %s" % self.virtual_machine.id) - self.virtual_machine.delete(self.apiclient) + self.virtual_machine.delete(self.apiclient, expunge=True) except Exception as e: self.fail("Failed to delete VM: %s" % e) diff --git a/test/integration/component/test_reset_ssh_keypair.py b/test/integration/component/test_reset_ssh_keypair.py index d0ddb18aa1c..204690e052e 100644 --- a/test/integration/component/test_reset_ssh_keypair.py +++ b/test/integration/component/test_reset_ssh_keypair.py @@ -218,7 +218,7 @@ class TestResetSSHKeypair(cloudstackTestCase): ) cls._cleanup.append(cls.pw_ssh_enabled_template) # Delete the VM - No longer needed - cls.virtual_machine.delete(cls.api_client) + cls.virtual_machine.delete(cls.api_client, expunge=True) except Exception as e: cls.tearDownClass() raise unittest.SkipTest("Exception in setUpClass: %s" % e) @@ -359,7 +359,7 @@ class TestResetSSHKeypair(cloudstackTestCase): except Exception as e: self.fail("Failed to SSH into VM with new keypair: %s, %s" % (virtual_machine.name, e)) - virtual_machine.delete(self.apiclient) + virtual_machine.delete(self.apiclient, expunge=True) return @attr(tags=["simulator", "basic", "advanced"]) @@ -477,7 +477,7 @@ class TestResetSSHKeypair(cloudstackTestCase): except Exception as e: self.fail("Failed to SSH into VM with password: %s, %s" % (virtual_machine.name, e)) - virtual_machine.delete(self.apiclient) + virtual_machine.delete(self.apiclient, expunge=True) return @attr(tags=["simulator", "basic", "advanced"]) @@ -580,7 +580,7 @@ class TestResetSSHKeypair(cloudstackTestCase): except Exception as e: self.fail("Failed to SSH into VM with new keypair: %s, %s" % (virtual_machine.name, e)) - virtual_machine.delete(self.apiclient) + virtual_machine.delete(self.apiclient, expunge=True) return @attr(tags=["simulator", "basic", "advanced"]) @@ -691,7 +691,7 @@ class TestResetSSHKeypair(cloudstackTestCase): except Exception as e: self.fail("Failed to SSH into VM with new keypair: %s, %s" % (virtual_machine.name, e)) - virtual_machine.delete(self.apiclient) + virtual_machine.delete(self.apiclient, expunge=True) return @attr(tags=["simulator", "basic", "advanced"]) @@ -766,7 +766,7 @@ class TestResetSSHKeypair(cloudstackTestCase): domainid=self.account.domainid ) - virtual_machine.delete(self.apiclient) + virtual_machine.delete(self.apiclient, expunge=True) return @attr(tags=["simulator", "basic", "advanced"]) @@ -844,7 +844,7 @@ class TestResetSSHKeypair(cloudstackTestCase): domainid=self.account.domainid ) - virtual_machine.delete(self.apiclient) + virtual_machine.delete(self.apiclient, expunge=True) return @attr(tags=["simulator", "basic", "advanced"]) @@ -920,7 +920,7 @@ class TestResetSSHKeypair(cloudstackTestCase): ) self.debug("Reset SSH key pair failed due to invalid parameters") - virtual_machine.delete(self.apiclient) + virtual_machine.delete(self.apiclient, expunge=True) return class TestResetSSHKeyUserRights(cloudstackTestCase): @@ -1030,7 +1030,7 @@ class TestResetSSHKeyUserRights(cloudstackTestCase): cls.volume.id ) # Delete the VM - No longer needed - cls.virtual_machine.delete(cls.api_client) + cls.virtual_machine.delete(cls.api_client, expunge=True) cls._cleanup = [ cls.service_offering, @@ -1184,7 +1184,7 @@ class TestResetSSHKeyUserRights(cloudstackTestCase): self.fail("Failed to SSH into VM with new keypair: %s, %s" % (virtual_machine.name, e)) - virtual_machine.delete(self.apiclient) + virtual_machine.delete(self.apiclient, expunge=True) return @attr(tags=["simulator", "basic", "advanced"]) @@ -1323,7 +1323,7 @@ class TestResetSSHKeyUserRights(cloudstackTestCase): self.fail("Failed to SSH into VM with new keypair: %s, %s" % (virtual_machine.name, e)) - virtual_machine.delete(self.apiclient) + virtual_machine.delete(self.apiclient, expunge=True) return @attr(tags=["simulator", "basic", "advanced"]) @@ -1462,5 +1462,5 @@ class TestResetSSHKeyUserRights(cloudstackTestCase): except Exception as e: self.fail("Failed to SSH into VM with new keypair: %s, %s" % (virtual_machine.name, e)) - virtual_machine.delete(self.apiclient) + virtual_machine.delete(self.apiclient, expunge=True) return diff --git a/test/integration/component/test_security_groups.py b/test/integration/component/test_security_groups.py index 63436131fee..ba276935791 100644 --- a/test/integration/component/test_security_groups.py +++ b/test/integration/component/test_security_groups.py @@ -1207,23 +1207,8 @@ class TestDeleteSecurityGroup(cloudstackTestCase): self.debug("Deploying VM in account: %s" % self.account.name) # Destroy the VM - self.virtual_machine.delete(self.apiclient) + self.virtual_machine.delete(self.apiclient, expunge=True) - config = Configurations.list( - self.apiclient, - name='expunge.delay' - ) - self.assertEqual( - isinstance(config, list), - True, - "Check list configurations response" - ) - response = config[0] - self.debug("expunge.delay: %s" % response.value) - # Wait for some time more than expunge.delay - time.sleep(int(response.value) * 2) - - # Deleting Security group should raise exception try: self.debug("Deleting Security Group: %s" % security_group.id) security_group.delete(self.apiclient) diff --git a/test/integration/component/test_usage.py b/test/integration/component/test_usage.py index fe80da7ffd6..4cc5183b7e4 100644 --- a/test/integration/component/test_usage.py +++ b/test/integration/component/test_usage.py @@ -214,7 +214,7 @@ class TestVmUsage(cloudstackTestCase): try: # Destroy the VM self.debug("Destroying the VM: %s" % self.virtual_machine.id) - self.virtual_machine.delete(self.apiclient) + self.virtual_machine.delete(self.apiclient, expunge=True) except Exception as e: self.fail("Failed to destroy VM: %s" % e) diff --git a/test/integration/component/test_vm_passwdenabled.py b/test/integration/component/test_vm_passwdenabled.py index 2f68257f893..0a1082a0a0d 100644 --- a/test/integration/component/test_vm_passwdenabled.py +++ b/test/integration/component/test_vm_passwdenabled.py @@ -208,7 +208,7 @@ class TestVMPasswordEnabled(cloudstackTestCase): domainid=cls.account.domainid ) # Delete the VM - No longer needed - cls.virtual_machine.delete(cls.api_client) + cls.virtual_machine.delete(cls.api_client, expunge=True) cls.services["small"]["template"] = cls.pw_enabled_template.id cls.vm = VirtualMachine.create(