Skip to content

Commit cd8442a

Browse files
authored
test: improve purge expunged resources b/g task testcase (#9426)
* test: improve purge expunged resources b/g task testcase Failures were seen for during purging of expunged resources via bacground task during different test runs. This PR tries to make sure b/g task execution is not skipped after MS restrat in a multi-MS environment. It also updates expunged.resources.purge.interval to allow running task again in 60s. Signed-off-by: Abhishek Kumar <[email protected]> * new string formatting --------- Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 7f4a686 commit cd8442a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/integration/smoke/test_purge_expunged_vms.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def restartAllManagementServers(self):
273273
return False
274274
self.debug("Restarting all management server")
275275
for idx, server_ip in enumerate(server_ips):
276+
self.debug(f"Restarting management server #{idx} with IP {server_ip}")
276277
sshClient = SshClient(
277278
server_ip,
278279
22,
@@ -283,6 +284,9 @@ def restartAllManagementServers(self):
283284
sshClient.execute(command)
284285
command = "service cloudstack-management start"
285286
sshClient.execute(command)
287+
if idx == 0:
288+
# Wait before restarting other management servers to make the first as oldest running
289+
time.sleep(10)
286290

287291
# Waits for management to come up in 10 mins, when it's up it will continue
288292
timeout = time.time() + (10 * 60)
@@ -349,15 +353,18 @@ def test_05_purge_expunged_vm_service_offering(self):
349353
@skipTestIf("hypervisorIsSimulator")
350354
@attr(tags=["advanced"], required_hardware="true")
351355
def test_06_purge_expunged_vm_background_task(self):
352-
purge_task_delay = 60
356+
purge_task_delay = 120
353357
self.changeConfiguration('expunged.resources.purge.enabled', 'true')
354358
self.changeConfiguration('expunged.resources.purge.delay', purge_task_delay)
359+
self.changeConfiguration('expunged.resources.purge.interval', int(purge_task_delay/2))
355360
self.changeConfiguration('expunged.resources.purge.keep.past.days', 1)
356361
if len(self.staticConfigurations) > 0:
357362
self.restartAllManagementServers()
358-
wait = 2 * purge_task_delay
359-
logging.info("Waiting for 2x%d = %d seconds for background task to execute" % (purge_task_delay, wait))
363+
wait_multiple = 2
364+
wait = wait_multiple * purge_task_delay
365+
logging.info(f"Waiting for {wait_multiple}x{purge_task_delay} = {wait} seconds for background task to execute")
360366
time.sleep(wait)
367+
logging.debug("Validating expunged VMs")
361368
self.validatePurgedVmEntriesInDb(
362369
[self.vm_ids[self.timestamps[0]], self.vm_ids[self.timestamps[1]], self.vm_ids[self.timestamps[2]]],
363370
None

0 commit comments

Comments
 (0)