Fix smoke tests due to change in behavior of restore VM (#10583)

* Fix unit tests due to change in behavior of restore VM

* update numbering in comments

* revert delete operations

* fix placement of start vm after refactoring
This commit is contained in:
Pearl Dsilva 2025-04-26 10:11:27 +05:30 committed by GitHub
parent 55c8138a1a
commit 07f4fc2e51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 9 deletions

View File

@ -20,10 +20,6 @@ import json
import os
import tempfile
import time
import unittest
import urllib.error
import urllib.parse
import urllib.request
from datetime import datetime
@ -165,6 +161,7 @@ class TestEventsResource(cloudstackTestCase):
self.cleanup.remove(volume)
ts = str(time.time())
virtual_machine.update(self.apiclient, displayname=ts)
virtual_machine.start(self.apiclient)
virtual_machine.delete(self.apiclient)
self.cleanup.remove(virtual_machine)
account_network.update(self.apiclient, name=account_network.name + ts)

View File

@ -733,12 +733,17 @@ class TestNetworkPermissions(cloudstackTestCase):
self.exec_command("self.user_apiclient", command, expected=False)
self.exec_command("self.otheruser_apiclient", command, expected=True)
# 22. Destroy vm2, should succeed by vm owner
# 22. Start VM before destroying, to recreate ROOT volume that was deleted as part of restore operation
command = """self.virtual_machine.start({apiclient})"""
self.exec_command("self.user_apiclient", command, expected=False)
self.exec_command("self.otheruser_apiclient", command, expected=True)
# 23. Destroy vm2, should succeed by vm owner
command = """self.virtual_machine.delete({apiclient}, expunge=False)"""
self.exec_command("self.user_apiclient", command, expected=False)
self.exec_command("self.otheruser_apiclient", command, expected=True)
# 23. Recover vm2, should succeed by vm owner
# 24. Recover vm2, should succeed by vm owner
allow_expunge_recover_vm = Configurations.list(self.apiclient, name="allow.user.expunge.recover.vm")[0].value
self.logger.debug("Global configuration allow.user.expunge.recover.vm = %s", allow_expunge_recover_vm)
if allow_expunge_recover_vm == "true":
@ -746,12 +751,12 @@ class TestNetworkPermissions(cloudstackTestCase):
self.exec_command("self.user_apiclient", command, expected=False)
self.exec_command("self.otheruser_apiclient", command, expected=True)
# 24. Destroy vm2, should succeed by vm owner
# 25. Destroy vm2, should succeed by vm owner
command = """self.virtual_machine.delete({apiclient}, expunge=False)"""
self.exec_command("self.user_apiclient", command, expected=False)
self.exec_command("self.otheruser_apiclient", command, expected=True)
# 25. Expunge vm2, should succeed by vm owner
# 26. Expunge vm2, should succeed by vm owner
if allow_expunge_recover_vm == "true":
command = """self.virtual_machine.expunge({apiclient})"""
self.exec_command("self.user_apiclient", command, expected=False)
@ -759,7 +764,7 @@ class TestNetworkPermissions(cloudstackTestCase):
else:
self.virtual_machine.expunge(self.apiclient)
# 26. Reset network permissions, should succeed by network owner
# 27. Reset network permissions, should succeed by network owner
command = """self.reset_network_permission({apiclient}, self.user_network, expected=True)"""
self.exec_command("self.otheruser_apiclient", command, expected=False)
self.exec_command("self.user_apiclient", command, expected=True)