Add Backup Restore Multibackend Tests
This patch adds two backup and restore tempest tests. These tests aim to restore to different volume backend types. To make it more organized, a new scenario/test_volume_backup_restore.py file is added. Finally, this patch bumps the tempest version to 31.0.0 to include https://review.opendev.org/c/openstack/tempest/+/843542. Change-Id: I6f5d5c6bf6c30045752064c666dd8892adbad643 Depends-On: https://review.opendev.org/c/openstack/tempest/+/842240
This commit is contained in:
parent
0e9461155e
commit
571ee4ff29
|
@ -0,0 +1,127 @@
|
|||
# Copyright 2022 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.common import utils
|
||||
from tempest.common import waiters
|
||||
from tempest import config
|
||||
from tempest.lib import decorators
|
||||
|
||||
from cinder_tempest_plugin.scenario import manager
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class TestVolumeBackupRestore(manager.ScenarioTest):
|
||||
"""Test cinder backup and restore
|
||||
|
||||
This testcase verifies content preservation after backup and restore
|
||||
operations by booting a server from a restored backup and check the
|
||||
connectivity to it.
|
||||
|
||||
The following is the scenario outline:
|
||||
1. Create volume from image.
|
||||
2. Create a backup for the volume.
|
||||
3. Restore the backup.
|
||||
4. Boot a server from the restored backup.
|
||||
5. Create a floating ip.
|
||||
6. Check server connectivity.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def skip_checks(cls):
|
||||
super(TestVolumeBackupRestore, cls).skip_checks()
|
||||
if not CONF.volume_feature_enabled.backup:
|
||||
raise cls.skipException('Backup is not enabled.')
|
||||
|
||||
if not CONF.volume_feature_enabled.multi_backend:
|
||||
raise cls.skipException("Cinder multi-backend feature disabled")
|
||||
|
||||
if len(set(CONF.volume.backend_names)) < 2:
|
||||
raise cls.skipException("Requires at least two different "
|
||||
"backend names")
|
||||
|
||||
def _get_volume_types(self):
|
||||
backend_names = CONF.volume.backend_names
|
||||
|
||||
backend_source = backend_names[0]
|
||||
backend_dest = backend_names[1]
|
||||
|
||||
return backend_source, backend_dest
|
||||
|
||||
def _volume_backup_restore(self, source_type, dest_type):
|
||||
img_uuid = CONF.compute.image_ref
|
||||
|
||||
# Create volume from image
|
||||
source_volume = self.create_volume(imageRef=img_uuid,
|
||||
volume_type=source_type)
|
||||
|
||||
self.assertEqual('true', source_volume['bootable'])
|
||||
|
||||
dest_volume = self.create_volume(imageRef=img_uuid,
|
||||
volume_type=dest_type)
|
||||
|
||||
# Create a backup
|
||||
backup = self.create_backup(volume_id=source_volume['id'])
|
||||
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||
source_volume['id'],
|
||||
'available')
|
||||
# Restore the backup
|
||||
restored_volume = self.restore_backup(backup['id'],
|
||||
volume_id=dest_volume['id'])
|
||||
self.assertEqual(dest_volume['id'], restored_volume['volume_id'])
|
||||
|
||||
# Create keypair and security group
|
||||
keypair = self.create_keypair()
|
||||
security_group = self.create_security_group()
|
||||
|
||||
# Boot a server from the restored backup
|
||||
bd_map_v2 = [{
|
||||
'uuid': restored_volume['volume_id'],
|
||||
'source_type': 'volume',
|
||||
'destination_type': 'volume',
|
||||
'boot_index': 0}]
|
||||
server = self.create_server(image_id='',
|
||||
block_device_mapping_v2=bd_map_v2,
|
||||
key_name=keypair['name'],
|
||||
security_groups=[
|
||||
{'name': security_group['name']}])
|
||||
|
||||
# Create a floating ip and associate it to server.
|
||||
fip = self.create_floating_ip(server)
|
||||
floating_ip = self.associate_floating_ip(fip, server)
|
||||
|
||||
# Check server connectivity
|
||||
self.check_vm_connectivity(floating_ip['floating_ip_address'],
|
||||
username=CONF.validation.image_ssh_user,
|
||||
private_key=keypair['private_key'],
|
||||
should_connect=True)
|
||||
|
||||
@decorators.attr(type='slow')
|
||||
@utils.services('compute', 'volume', 'image')
|
||||
@decorators.idempotent_id('74ebe237-fdd1-451c-adde-b53259075555')
|
||||
def test_volume_backup_restore_multibackend(self):
|
||||
"""Test backup restore with multibackend."""
|
||||
source_type, dest_type = self._get_volume_types()
|
||||
self._volume_backup_restore(source_type=source_type,
|
||||
dest_type=dest_type)
|
||||
|
||||
@decorators.attr(type='slow')
|
||||
@utils.services('compute', 'volume', 'image')
|
||||
@decorators.idempotent_id('ce959459-a063-431c-bb50-c4357742588f')
|
||||
def test_volume_backup_restore_multibackend_reverse(self):
|
||||
"""Test backup restore with reverse multibackend."""
|
||||
dest_type, source_type = self._get_volume_types()
|
||||
self._volume_backup_restore(source_type=source_type,
|
||||
dest_type=dest_type)
|
|
@ -5,4 +5,4 @@
|
|||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||
oslo.config>=5.1.0 # Apache-2.0
|
||||
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
|
||||
tempest>=27.0.0 # Apache-2.0
|
||||
tempest>=31.0.0 # Apache-2.0
|
||||
|
|
Loading…
Reference in New Issue