-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactoring a few smoke tests #11748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,13 +38,15 @@ | |
StoragePool) | ||
from marvin.lib.common import (get_domain, | ||
get_zone, | ||
get_template) | ||
get_template, | ||
list_disk_offering) | ||
from marvin.lib.decoratorGenerators import skipTestIf | ||
from marvin.codes import FAILED, PASS | ||
from nose.plugins.attrib import attr | ||
import logging | ||
from sp_util import (TestData, StorPoolHelper) | ||
import math | ||
import uuid | ||
|
||
class TestSnapshotCopy(cloudstackTestCase): | ||
|
||
|
@@ -111,6 +113,10 @@ def setUpClass(cls): | |
cls.helper = StorPoolHelper() | ||
|
||
compute_offering_service = cls.services["service_offerings"]["tiny"].copy() | ||
td = TestData() | ||
cls.testdata = td.testdata | ||
cls.helper = StorPoolHelper() | ||
cls.disk_offerings = cls.create_do_if_not_exists(cls.testdata[TestData.diskOfferingCustomAdditionalZone]) | ||
cls.service_offering = ServiceOffering.create( | ||
cls.apiclient, | ||
compute_offering_service) | ||
|
@@ -160,8 +166,7 @@ def test_01_take_snapshot_multi_zone(self): | |
snapshot = Snapshot.create(self.userapiclient, volume_id=self.volume.id, zoneids=[str(self.additional_zone.id)], usestoragereplication=True) | ||
self.snapshot_id = snapshot.id | ||
self.helper.verify_snapshot_copies(self.userapiclient, self.snapshot_id, [self.zone.id, self.additional_zone.id]) | ||
time.sleep(420) | ||
Snapshot.delete(snapshot, self.userapiclient) | ||
self._cleanup.append(snapshot) | ||
return | ||
|
||
@skipTestIf("testsNotSupported") | ||
|
@@ -174,8 +179,8 @@ def test_02_copy_snapshot_multi_pools(self): | |
self.snapshot_id = snapshot.id | ||
Snapshot.copy(self.userapiclient, self.snapshot_id, zone_ids=[str(self.additional_zone.id)], source_zone_id=self.zone.id, usestoragereplication=True) | ||
self.helper.verify_snapshot_copies(self.userapiclient, self.snapshot_id, [self.zone.id, self.additional_zone.id]) | ||
time.sleep(420) | ||
Snapshot.delete(snapshot, self.userapiclient) | ||
|
||
self._cleanup.append(snapshot) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should move to just below the |
||
return | ||
|
||
@skipTestIf("testsNotSupported") | ||
|
@@ -190,7 +195,7 @@ def test_03_take_snapshot_multi_pools_delete_single_zone(self): | |
time.sleep(420) | ||
Snapshot.delete(snapshot, self.userapiclient, self.zone.id) | ||
self.helper.verify_snapshot_copies(self.userapiclient, self.snapshot_id, [self.additional_zone.id]) | ||
self.cleanup.append(snapshot) | ||
self._cleanup.append(snapshot) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn’t the snapshot to be removed from the cleanup list here? |
||
return | ||
|
||
@skipTestIf("testsNotSupported") | ||
|
@@ -227,13 +232,12 @@ def test_05_take_snapshot_multi_zone_create_volume_additional_zone(self): | |
self.apiclient, | ||
service | ||
) | ||
self.cleanup.append(self.disk_offering) | ||
self._cleanup.append(self.disk_offering) | ||
disk_offering_id = self.disk_offering.id | ||
|
||
self.volume = Volume.create(self.userapiclient, {"diskname":"StorPoolDisk-1" }, snapshotid=self.snapshot_id, zoneid=self.zone.id, diskofferingid=disk_offering_id) | ||
self.cleanup.append(self.volume) | ||
time.sleep(420) | ||
Snapshot.delete(snapshot, self.userapiclient) | ||
self._cleanup.append(self.volume) | ||
self._cleanup.append(snapshot) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this added at this point? |
||
if self.zone.id != self.volume.zoneid: | ||
self.fail("Volume from snapshot not created in the additional zone") | ||
return | ||
|
@@ -249,7 +253,96 @@ def test_06_take_snapshot_multi_zone_create_template_additional_zone(self): | |
self.template = self.helper.create_snapshot_template(self.userapiclient, self.services, self.snapshot_id, self.additional_zone.id) | ||
if self.additional_zone.id != self.template.zoneid: | ||
self.fail("Template from snapshot not created in the additional zone") | ||
self._cleanup.append(snapshot) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should move up a couple of lines to be just below the matching create |
||
self._cleanup.append(self.template) | ||
return | ||
|
||
@skipTestIf("testsNotSupported") | ||
@attr(tags=["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="false") | ||
def test_07_take_snapshot_multi_zone_deply_vm_additional_zone(self): | ||
"""Test to take volume snapshot in multiple StorPool primary storages in diff zones and deploy a VM from snapshot in one of the additional zones | ||
""" | ||
snapshot = Snapshot.create(self.userapiclient, volume_id=self.volume.id, zoneids=[str(self.additional_zone.id)], usestoragereplication=True) | ||
self._cleanup.append(snapshot) | ||
self.snapshot_id = snapshot.id | ||
self.helper.verify_snapshot_copies(self.userapiclient, self.snapshot_id, [self.zone.id, self.additional_zone.id]) | ||
vm = self.deploy_vm_from_snapshot(snapshot, self.additional_zone.id) | ||
if self.additional_zone.id != vm.zoneid: | ||
self.fail("VM from snapshot not created in the additional zone") | ||
return | ||
|
||
|
||
@skipTestIf("testsNotSupported") | ||
@attr(tags=["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="false") | ||
def test_08_take_snapshot_multi_zone_create_volume_additional_zone_deploy_vm(self): | ||
"""Test to take volume snapshot in multiple StorPool primary storages in diff zones | ||
create a volume from the snapshot in the additional zone | ||
and deploy a VM from the volume in one of the additional zones | ||
""" | ||
snapshot = Snapshot.create(self.userapiclient, volume_id=self.volume.id, zoneids=[str(self.additional_zone.id)], usestoragereplication=True) | ||
self._cleanup.append(snapshot) | ||
self.snapshot_id = snapshot.id | ||
self.helper.verify_snapshot_copies(self.userapiclient, self.snapshot_id, [self.zone.id, self.additional_zone.id]) | ||
vm = self.create_volume_from_snapshot_deploy_vm(snapshotid=self.snapshot_id, zoneid=self.additional_zone.id) | ||
time.sleep(420) | ||
Snapshot.delete(snapshot, self.userapiclient) | ||
self.cleanup.append(self.template) | ||
if self.additional_zone.id != vm.zoneid: | ||
self.fail("VM from snapshot not created in the additional zone") | ||
return | ||
|
||
def create_volume_from_snapshot_deploy_vm(self, snapshotid, zoneid=None): | ||
volume = Volume.create_from_snapshot( | ||
self.apiclient, | ||
snapshot_id=snapshotid, | ||
services=self.services, | ||
disk_offering=self.disk_offerings.id, | ||
size=8, | ||
account=self.account.name, | ||
domainid=self.account.domainid, | ||
zoneid=zoneid, | ||
) | ||
virtual_machine = VirtualMachine.create(self.apiclient, | ||
{"name": "Test-%s" % uuid.uuid4()}, | ||
accountid=self.account.name, | ||
domainid=self.account.domainid, | ||
zoneid=zoneid, | ||
serviceofferingid=self.service_offering.id, | ||
volumeid=volume.id, | ||
mode="basic", | ||
) | ||
self._cleanup.append(virtual_machine) | ||
try: | ||
ssh_client = virtual_machine.get_ssh_client() | ||
except Exception as e: | ||
self.fail("SSH failed for virtual machine: %s - %s" % | ||
(virtual_machine.ipaddress, e)) | ||
return virtual_machine | ||
|
||
def deploy_vm_from_snapshot(self, snapshot, zoneid=None): | ||
virtual_machine = VirtualMachine.create(self.apiclient, | ||
{"name": "Test-%s" % uuid.uuid4()}, | ||
accountid=self.account.name, | ||
domainid=self.account.domainid, | ||
zoneid=zoneid, | ||
serviceofferingid=self.service_offering.id, | ||
snapshotid=snapshot.id, | ||
mode="basic", | ||
) | ||
self._cleanup.append(virtual_machine) | ||
try: | ||
ssh_client = virtual_machine.get_ssh_client() | ||
except Exception as e: | ||
self.fail("SSH failed for virtual machine: %s - %s" % | ||
(virtual_machine.ipaddress, e)) | ||
return virtual_machine | ||
|
||
@classmethod | ||
def create_do_if_not_exists(cls, data): | ||
disk_offerings = list_disk_offering( | ||
cls.apiclient, | ||
name=data["name"] | ||
) | ||
if disk_offerings is None: | ||
disk_offerings = DiskOffering.create(cls.apiclient, services=data, custom=True) | ||
else: | ||
disk_offerings = disk_offerings[0] | ||
return disk_offerings |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -82,33 +82,27 @@ def setUpClass(cls): | |||||
|
||||||
storage_pools_response = list_storage_pools(cls.apiclient, | ||||||
zoneid=cls.zone.id, | ||||||
scope="ZONE") | ||||||
scope="ZONE", | ||||||
status="Up") | ||||||
|
||||||
if storage_pools_response: | ||||||
cls.zone_wide_storage = storage_pools_response[0] | ||||||
|
||||||
cls.debug( | ||||||
"zone wide storage id is %s" % | ||||||
cls.zone_wide_storage.id) | ||||||
update1 = StoragePool.update(cls.apiclient, | ||||||
id=cls.zone_wide_storage.id, | ||||||
tags="test-vm" | ||||||
) | ||||||
cls.debug( | ||||||
"Storage %s pool tag%s" % | ||||||
(cls.zone_wide_storage.id, update1.tags)) | ||||||
cls.service_offering = ServiceOffering.create( | ||||||
cls.apiclient, | ||||||
cls.services["service_offerings"]["small"], | ||||||
tags="test-vm" | ||||||
tags=cls.zone_wide_storage.tags | ||||||
) | ||||||
cls._cleanup.append(cls.service_offering) | ||||||
|
||||||
do = { | ||||||
"name": "do-tags", | ||||||
"displaytext": "Disk offering with tags", | ||||||
"disksize":8, | ||||||
"tags": "test-vm" | ||||||
"tags": cls.zone_wide_storage.tags | ||||||
} | ||||||
cls.disk_offering = DiskOffering.create( | ||||||
cls.apiclient, | ||||||
|
@@ -286,6 +280,7 @@ def deploy_vm_from_snapshot(self, snapshot): | |||||
snapshotid=snapshot.id, | ||||||
mode="basic", | ||||||
) | ||||||
self._cleanup.append(virtual_machine) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
maybe? |
||||||
try: | ||||||
ssh_client = virtual_machine.get_ssh_client() | ||||||
except Exception as e: | ||||||
|
@@ -311,6 +306,7 @@ def create_volume_from_snapshot_deploy_vm(self, snapshotid): | |||||
volumeid=volume.id, | ||||||
mode="basic", | ||||||
) | ||||||
self._cleanup.append(virtual_machine) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
? |
||||||
try: | ||||||
ssh_client = virtual_machine.get_ssh_client() | ||||||
except Exception as e: | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.