Add test for Ceph backup snapshot cleanup option

This adds a new test for the Ceph backup snapshot cleanup
option. It tests a special situation in which a requested
incremental backup should become a full backup instead.

Depends-On: https://review.opendev.org/c/openstack/cinder/+/810457
Depends-On: https://review.opendev.org/c/openstack/devstack/+/860812
Signed-off-by: Jan Hartkopf <jhartkopf@inovex.de>
Change-Id: I8e539f58cc7c8b2a1d2c3036520cad9092a48638
This commit is contained in:
Jan Hartkopf 2022-09-05 13:47:13 +02:00 committed by Christian Rohmann
parent 9f1f4b88e1
commit bfcc041253
3 changed files with 101 additions and 0 deletions

View File

@ -18,6 +18,7 @@
- nova-ceph-multistore:
voting: false
- cinder-tempest-plugin-cbak-ceph
- cinder-tempest-plugin-ceph-cleanup
- cinder-tempest-plugin-cbak-s3
# As per the Tempest "Stable Branch Support Policy", Tempest will only
# support the "Maintained" stable branches and not the "Extended Maintained"
@ -218,6 +219,21 @@
devstack_services:
c-bak: true
- job:
name: cinder-tempest-plugin-ceph-cleanup
parent: cinder-tempest-plugin-cbak-ceph
description: |
Integration test that runs the Ceph snapshot cleanup test.
vars:
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
volume-feature-enabled:
backup_keep_snapshots_option: True
devstack_localrc:
CINDER_BAK_CEPH_KEEP_SNAPSHOTS_COUNT: 1
tempest_test_regex: 'test_backup_snapshot_cleanup_incremental_forces_full_backup'
- job:
name: cinder-tempest-plugin-cbak-ceph-zed
parent: cinder-tempest-plugin-cbak-ceph

View File

@ -22,6 +22,10 @@ cinder_option = [
cfg.BoolOpt('volume_revert',
default=False,
help='Enable to run Cinder volume revert tests'),
cfg.BoolOpt('backup_keep_snapshots_option',
default=False,
help='Enable to run Cinder test for Ceph driver with '
'backup_ceph_max_snapshots config option')
]
# The barbican service is discovered by config_tempest [1], and will appear

View File

@ -0,0 +1,81 @@
# Copyright (c) 2022 inovex GmbH
# 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 import config
from tempest.lib import decorators
from cinder_tempest_plugin.api.volume import base
CONF = config.CONF
class VolumesBackupsTest(base.BaseVolumeTest):
@classmethod
def skip_checks(cls):
super(VolumesBackupsTest, cls).skip_checks()
if not CONF.volume_feature_enabled.backup_keep_snapshots_option:
raise cls.skipException("backup_ceph_max_snapshots "
"option not enabled")
@decorators.idempotent_id('10c43668-808e-48b6-bd37-92531f59183b')
def test_backup_snapshot_cleanup_incremental_forces_full_backup(self):
"""Test incremental backup forces full backup after manual deletion."""
# Assume backup_ceph_max_snapshots is set to 1
# Create volume
volume = self.create_volume()
# Create base backup
self.create_backup(volume_id=volume['id'])
# Create 2 incremental backup snapshots
snapshots = []
for _ in range(2):
backup_incr = self.create_backup(
volume_id=volume['id'],
incremental=True)
snapshots.append(backup_incr)
# Snapshots are returned in reverse order of creation time
listed_snaps = self.backups_client.list_backups(detail=True)
self.assertEqual(listed_snaps['backups'][0]['id'], snapshots[1]['id'])
self.assertEqual(listed_snaps['backups'][1]['id'], snapshots[0]['id'])
self.assertTrue(listed_snaps['backups'][0]['is_incremental'])
self.assertFalse(listed_snaps['backups'][0]['has_dependent_backups'])
# Manually delete latest backup snapshot; this should force the next
# incremental backup to become a full backup.
# (At least backup_ceph_max_snapshots backup snapshots must be
# deleted to achieve this situation, which is 1 in our case, so 1
# deletion is sufficient.)
self.backups_client.delete_backup(snapshots[1]['id'])
self.backups_client.wait_for_resource_deletion(snapshots[1]['id'])
# Try to create incremental backup. As there are no base backups
# available anymore (one deleted by us, one by Ceph driver),
# this should automatically become a full backup.
backup_incr = self.create_backup(
volume_id=volume['id'],
incremental=True)
listed_snaps = self.backups_client.list_backups(detail=True)
self.assertEqual(listed_snaps['backups'][0]['id'], backup_incr['id'])
# Assert that, even though incremental backup was requested,
# a full backup was created
self.assertFalse(listed_snaps['backups'][0]['is_incremental'])