Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions test/integration/smoke/test_list_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ def setUpClass(cls):
cls.services["disk_offering"])
cls._cleanup.append(cls.disk_offering)

# Get already existing volumes in the env for assertions
cls.volumes = Volume.list(cls.apiclient, zoneid=cls.zone.id) or []

# Create VM
cls.virtual_machine = VirtualMachine.create(
cls.apiclient,
Expand Down Expand Up @@ -260,7 +257,7 @@ def test_05_list_volumes_isrecursive(self):
"List Volume response is not a valid list"
)
self.assertEqual(
len(list_volume_response) - len(self.volumes),
len(list_volume_response),
4,
"ListVolumes response expected 4 Volumes, received %s" % len(list_volume_response)
)
Expand All @@ -276,7 +273,7 @@ def test_05_list_volumes_isrecursive(self):
"List Volume response is not a valid list"
)
self.assertEqual(
len(list_volume_response) - len(self.volumes),
len(list_volume_response),
3,
"ListVolumes response expected 3 Volumes, received %s" % len(list_volume_response)
)
Expand Down Expand Up @@ -319,7 +316,7 @@ def test_07_list_volumes_listall(self):
"List Volume response is not a valid list"
)
self.assertEqual(
len(list_volume_response) - len(self.volumes),
len(list_volume_response),
4,
"ListVolumes response expected 4 Volumes, received %s" % len(list_volume_response)
)
Expand All @@ -334,7 +331,7 @@ def test_07_list_volumes_listall(self):
"List Volume response is not a valid list"
)
self.assertEqual(
len(list_volume_response) - len(self.volumes),
len(list_volume_response),
3,
"ListVolumes response expected 3 Volumes, received %s" % len(list_volume_response)
)
Expand Down
23 changes: 22 additions & 1 deletion tools/marvin/marvin/cloudstackTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
Network,
NetworkACL,
NetworkOffering,
VirtualMachine
VirtualMachine,
Volume
)


Expand Down Expand Up @@ -98,12 +99,32 @@ def cleanup_resources(cls, api_client, resources):
"""
Delete resources (created during tests)
"""
volume_list = []
for obj in resources:
if isinstance(obj, VirtualMachine):
obj.delete(api_client, expunge=True)
if isinstance(obj, Volume):
obj.destroy(api_client, expunge=True)
volume_list.append(obj)
else:
obj.delete(api_client)

cls.wait_for_volumes_cleanup(api_client, volume_list)

def wait_for_volumes_cleanup(cls, api_client, volume_list):
"""Wait for volumes to be deleted"""
for volume in volume_list:
max_retries = 24 # Max wait time will be 5 * 12 = 120 seconds
while max_retries > 0:
volumes = Volume.list(
api_client,
id=volume.id
)
if volumes is None or len(volumes) == 0:
break
max_retries = max_retries - 1
time.sleep(5)

def check_wget_from_vm(self, vm, public_ip, network=None, testnegative=False, isVmAccessible=True):
import urllib.request, urllib.error
self.debug(f"Checking if we can wget from a VM={vm.name} http server on public_ip={public_ip.ipaddress.ipaddress}, expecting failure == {testnegative} and vm is acceccible == {isVmAccessible}")
Expand Down