Fixing the vm_life_cycle expunge test

* expunge.interval determines the ExpungeTask interval to cleanup the
VM and post expunge.delay seconds we delete the VM entry. So let's just
wait long enough
This commit is contained in:
Prasanna Santhanam 2012-07-12 17:33:05 +05:30
parent ecfdb3af5c
commit 0119e6d04e

View File

@ -107,7 +107,7 @@ class Services:
"name": "testISO", "name": "testISO",
"url": "http://nfs1.lab.vmops.com/isos_32bit/dsl-4.4.10.iso", "url": "http://nfs1.lab.vmops.com/isos_32bit/dsl-4.4.10.iso",
# Source URL where ISO is located # Source URL where ISO is located
"ostypeid": '1a568aed-db2d-41ca-b644-416b0bdc067e', "ostypeid": '93ffa3ea-ef02-4e56-9940-f04158353555',
"mode": 'HTTP_DOWNLOAD', # Downloading existing ISO "mode": 'HTTP_DOWNLOAD', # Downloading existing ISO
}, },
"template": { "template": {
@ -121,7 +121,7 @@ class Services:
"sleep": 60, "sleep": 60,
"timeout": 10, "timeout": 10,
#Migrate VM to hostid #Migrate VM to hostid
"ostypeid": '1a568aed-db2d-41ca-b644-416b0bdc067e', "ostypeid": '93ffa3ea-ef02-4e56-9940-f04158353555',
# CentOS 5.3 (64-bit) # CentOS 5.3 (64-bit)
"mode":'advanced', "mode":'advanced',
} }
@ -168,6 +168,7 @@ class TestDeployVM(cloudstackTestCase):
self.account self.account
] ]
def test_deploy_vm(self): def test_deploy_vm(self):
"""Test Deploy Virtual Machine """Test Deploy Virtual Machine
""" """
@ -315,6 +316,7 @@ class TestVMLifeCycle(cloudstackTestCase):
cleanup_resources(self.apiclient, self.cleanup) cleanup_resources(self.apiclient, self.cleanup)
return return
def test_01_stop_vm(self): def test_01_stop_vm(self):
"""Test Stop Virtual Machine """Test Stop Virtual Machine
""" """
@ -350,6 +352,7 @@ class TestVMLifeCycle(cloudstackTestCase):
) )
return return
def test_02_start_vm(self): def test_02_start_vm(self):
"""Test Start Virtual Machine """Test Start Virtual Machine
""" """
@ -387,6 +390,7 @@ class TestVMLifeCycle(cloudstackTestCase):
) )
return return
def test_03_reboot_vm(self): def test_03_reboot_vm(self):
"""Test Reboot Virtual Machine """Test Reboot Virtual Machine
""" """
@ -422,6 +426,7 @@ class TestVMLifeCycle(cloudstackTestCase):
) )
return return
def test_04_change_offering_small(self): def test_04_change_offering_small(self):
"""Change Offering to a small capacity """Change Offering to a small capacity
""" """
@ -539,6 +544,7 @@ class TestVMLifeCycle(cloudstackTestCase):
) )
return return
def test_05_change_offering_medium(self): def test_05_change_offering_medium(self):
"""Change Offering to a medium capacity """Change Offering to a medium capacity
""" """
@ -660,6 +666,7 @@ class TestVMLifeCycle(cloudstackTestCase):
) )
return return
def test_06_destroy_vm(self): def test_06_destroy_vm(self):
"""Test destroy Virtual Machine """Test destroy Virtual Machine
""" """
@ -695,6 +702,7 @@ class TestVMLifeCycle(cloudstackTestCase):
) )
return return
def test_07_restore_vm(self): def test_07_restore_vm(self):
"""Test recover Virtual Machine """Test recover Virtual Machine
""" """
@ -734,6 +742,7 @@ class TestVMLifeCycle(cloudstackTestCase):
return return
def test_08_migrate_vm(self): def test_08_migrate_vm(self):
"""Test migrate VM """Test migrate VM
""" """
@ -824,11 +833,26 @@ class TestVMLifeCycle(cloudstackTestCase):
response = config[0] response = config[0]
# Wait for some time more than expunge.delay # Wait for some time more than expunge.delay
time.sleep(int(response.value) * 2) time.sleep(int(response.value) * 2)
list_vm_response = list_virtual_machines( #VM should be destroyed unless expunge thread hasn't run
self.apiclient, #Wait for two cycles of the expunge thread
id=self.small_virtual_machine.id config = list_configurations(
) self.apiclient,
name='expunge.interval'
)
expunge_cycle = int(config[0].value)*2
while expunge_cycle > 0:
list_vm_response = list_virtual_machines(
self.apiclient,
id=self.small_virtual_machine.id
)
if list_vm_response:
time.sleep(expunge_cycle)
expunge_cycle = 0
continue
else:
break
self.assertEqual( self.assertEqual(
list_vm_response, list_vm_response,
None, None,
@ -836,6 +860,7 @@ class TestVMLifeCycle(cloudstackTestCase):
) )
return return
def test_10_attachAndDetach_iso(self): def test_10_attachAndDetach_iso(self):
"""Test for detach ISO to virtual machine""" """Test for detach ISO to virtual machine"""
@ -1077,6 +1102,7 @@ class TestVMPasswordEnabled(cloudstackTestCase):
cleanup_resources(self.apiclient, self.cleanup) cleanup_resources(self.apiclient, self.cleanup)
return return
def test_11_get_vm_password(self): def test_11_get_vm_password(self):
"""Test get VM password for password enabled template""" """Test get VM password for password enabled template"""