Skip to content

Commit 404b579

Browse files
authored
test,xcp-ng: fix tests for VM PV driver issue (#6549)
Few of the smoke tests fail on XCP-ng8 with PV drivers not installed for the VM. This PR makes changes to use get_suitable_test_template instead of get_template to use the appropriate template for the VM deployed during the test. After volume migration VM becomes unusable for attach/detach volume action. A new template could be used in future. For workaround right now, tests are ordered in a way that migrate volume test run at the end. Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent b0e780a commit 404b579

File tree

3 files changed

+78
-73
lines changed

3 files changed

+78
-73
lines changed

test/integration/smoke/test_attach_multiple_volumes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
DiskOffering,
2929
)
3030
from marvin.lib.common import (get_domain,
31-
get_zone,
32-
get_template,
33-
find_storage_pool_type)
31+
get_zone,
32+
get_suitable_test_template,
33+
find_storage_pool_type)
3434
from marvin.codes import (
3535
PASS,
3636
FAILED,
@@ -69,13 +69,13 @@ def setUpClass(cls):
6969
)
7070
cls._cleanup.append(cls.disk_offering)
7171

72-
template = get_template(
73-
cls.apiclient,
74-
cls.zone.id,
75-
cls.services["ostype"]
76-
)
72+
template = get_suitable_test_template(
73+
cls.apiclient,
74+
cls.zone.id,
75+
cls.services["ostype"],
76+
cls.hypervisor)
7777
if template == FAILED:
78-
assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
78+
assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"]
7979

8080
cls.services["domainid"] = cls.domain.id
8181
cls.services["zoneid"] = cls.zone.id

test/integration/smoke/test_network_permissions.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
from marvin.lib.common import (get_domain,
4646
get_zone,
47-
get_template)
47+
get_suitable_test_template)
4848

4949
NETWORK_FILTER_ACCOUNT = 'account'
5050
NETWORK_FILTER_DOMAIN = 'domain'
@@ -66,7 +66,12 @@ def setUpClass(cls):
6666

6767
zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
6868
cls.zone = Zone(zone.__dict__)
69-
cls.template = get_template(cls.apiclient, cls.zone.id)
69+
cls.hypervisor = cls.testClient.getHypervisorInfo()
70+
cls.template = get_suitable_test_template(
71+
cls.apiclient,
72+
cls.zone.id,
73+
cls.services["ostype"],
74+
cls.hypervisor)
7075
cls._cleanup = []
7176

7277
cls.logger = logging.getLogger("TestNetworkPermissions")

test/integration/smoke/test_volumes.py

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -726,67 +726,6 @@ def test_08_resize_volume(self):
726726
time.sleep(30)
727727
return
728728

729-
@attr(tags=["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
730-
def test_12_resize_volume_with_only_size_parameter(self):
731-
"""Test resize a volume by providing only size parameter, disk offering id is not mandatory"""
732-
# Verify the size is the new size is what we wanted it to be.
733-
self.debug(
734-
"Attaching volume (ID: %s) to VM (ID: %s)" % (
735-
self.volume.id,
736-
self.virtual_machine.id
737-
))
738-
739-
self.virtual_machine.attach_volume(self.apiClient, self.volume)
740-
self.attached = True
741-
hosts = Host.list(self.apiClient, id=self.virtual_machine.hostid)
742-
self.assertTrue(isinstance(hosts, list))
743-
self.assertTrue(len(hosts) > 0)
744-
self.debug("Found %s host" % hosts[0].hypervisor)
745-
746-
if hosts[0].hypervisor == "XenServer":
747-
self.virtual_machine.stop(self.apiClient)
748-
elif hosts[0].hypervisor.lower() == "hyperv":
749-
self.skipTest("Resize Volume is unsupported on Hyper-V")
750-
751-
# resize the data disk
752-
self.debug("Resize Volume ID: %s" % self.volume.id)
753-
754-
cmd = resizeVolume.resizeVolumeCmd()
755-
cmd.id = self.volume.id
756-
cmd.size = 20
757-
758-
self.apiClient.resizeVolume(cmd)
759-
760-
count = 0
761-
success = False
762-
while count < 3:
763-
list_volume_response = Volume.list(
764-
self.apiClient,
765-
id=self.volume.id,
766-
type='DATADISK'
767-
)
768-
for vol in list_volume_response:
769-
if vol.id == self.volume.id and int(vol.size) == (20 * (1024 ** 3)) and vol.state == 'Ready':
770-
success = True
771-
if success:
772-
break
773-
else:
774-
time.sleep(10)
775-
count += 1
776-
777-
self.assertEqual(
778-
success,
779-
True,
780-
"Check if the data volume resized appropriately"
781-
)
782-
783-
# start the vm if it is on xenserver
784-
785-
if hosts[0].hypervisor == "XenServer":
786-
self.virtual_machine.start(self.apiClient)
787-
time.sleep(30)
788-
return
789-
790729
@attr(tags=["advanced", "advancedns", "smoke", "basic"], required_hardware="false")
791730
def test_09_delete_detached_volume(self):
792731
"""Delete a Volume unattached to an VM
@@ -943,6 +882,67 @@ def test_11_attach_volume_with_unstarted_vm(self):
943882

944883
return
945884

885+
@attr(tags=["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
886+
def test_12_resize_volume_with_only_size_parameter(self):
887+
"""Test resize a volume by providing only size parameter, disk offering id is not mandatory"""
888+
# Verify the size is the new size is what we wanted it to be.
889+
self.debug(
890+
"Attaching volume (ID: %s) to VM (ID: %s)" % (
891+
self.volume.id,
892+
self.virtual_machine.id
893+
))
894+
895+
self.virtual_machine.attach_volume(self.apiClient, self.volume)
896+
self.attached = True
897+
hosts = Host.list(self.apiClient, id=self.virtual_machine.hostid)
898+
self.assertTrue(isinstance(hosts, list))
899+
self.assertTrue(len(hosts) > 0)
900+
self.debug("Found %s host" % hosts[0].hypervisor)
901+
902+
if hosts[0].hypervisor == "XenServer":
903+
self.virtual_machine.stop(self.apiClient)
904+
elif hosts[0].hypervisor.lower() == "hyperv":
905+
self.skipTest("Resize Volume is unsupported on Hyper-V")
906+
907+
# resize the data disk
908+
self.debug("Resize Volume ID: %s" % self.volume.id)
909+
910+
cmd = resizeVolume.resizeVolumeCmd()
911+
cmd.id = self.volume.id
912+
cmd.size = 20
913+
914+
self.apiClient.resizeVolume(cmd)
915+
916+
count = 0
917+
success = False
918+
while count < 3:
919+
list_volume_response = Volume.list(
920+
self.apiClient,
921+
id=self.volume.id,
922+
type='DATADISK'
923+
)
924+
for vol in list_volume_response:
925+
if vol.id == self.volume.id and int(vol.size) == (20 * (1024 ** 3)) and vol.state == 'Ready':
926+
success = True
927+
if success:
928+
break
929+
else:
930+
time.sleep(10)
931+
count += 1
932+
933+
self.assertEqual(
934+
success,
935+
True,
936+
"Check if the data volume resized appropriately"
937+
)
938+
939+
# start the vm if it is on xenserver
940+
941+
if hosts[0].hypervisor == "XenServer":
942+
self.virtual_machine.start(self.apiClient)
943+
time.sleep(30)
944+
return
945+
946946
def wait_for_attributes_and_return_root_vol(self):
947947
def checkVolumeResponse():
948948
list_volume_response = Volume.list(
@@ -963,7 +963,7 @@ def checkVolumeResponse():
963963
return response
964964

965965
@attr(tags=["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
966-
def test_11_migrate_volume_and_change_offering(self):
966+
def test_13_migrate_volume_and_change_offering(self):
967967
"""
968968
Validates the following
969969
1. Creates a new Volume with a small disk offering

0 commit comments

Comments
 (0)