Add allow_delete_snapshot_before_volume config option

Adds allow_delete_snapshot_before_volume config option, that controls
whether to test only situation where first test deletes volume and
then snapshot or also second situation, where first test deletes
snapshot and then volume. Second situation is impossible with Ceph [1].

[1] https://docs.openstack.org/cinder/ussuri/drivers.html#rbddriver

Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Change-Id: Ib422331892f077d78e3f2efbdd88abafc4c52b9a
This commit is contained in:
Oleksii Petrenko 2020-07-20 19:57:18 +03:00 committed by Ivan Kolodyazhny
parent d9bf46371e
commit 97797197af
3 changed files with 55 additions and 13 deletions

View File

@ -161,7 +161,14 @@ VolumeGroup = [
help='Default volume type'),
cfg.StrOpt('volume_size',
default='1',
help='Default volume size ')
help='Default volume size '),
cfg.BoolOpt('allow_delete_snapshot_before_volume',
default=True,
help='Set to False to disallow running the volume test where '
'first snapshot is deleted and then volume booted from '
'this snapshot is deleted, but instead run only the test '
'that deletes volume first and then snapshot. '
'Set to True to run both tests.')
]
PluginGroup = [

View File

@ -104,3 +104,4 @@ flavor=m1.tiny
[volume]
volume_type=lvmdriver-1
volume_size=1
allow_delete_snapshot_before_volume=True

View File

@ -9,9 +9,14 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import pytest
from openstack_dashboard.test.integration_tests import config
from openstack_dashboard.test.integration_tests import helpers
from openstack_dashboard.test.integration_tests.regions import messages
CONFIG = config.get_config()
class TestVolumeSnapshotsBasic(helpers.TestCase):
"""Login as demo user"""
@ -214,18 +219,7 @@ class TestVolumeSnapshotsAdvanced(helpers.TestCase):
self.addCleanup(cleanup)
def test_create_volume_from_snapshot(self):
"""Test checks possibility to create volume from snapshot
Steps:
1. Login to Horizon Dashboard as regular user
2. Navigate to Project -> Volumes -> Volumes page
3. Create snapshot for existed volume
4. Create new volume from snapshot
5. Check the volume is created and has 'Available' status
6. Delete volume snapshot
7. Delete volume
"""
def create_volume_from_snapshot(self):
volumes_page = self.home_pg.go_to_project_volumes_volumespage()
volumes_snapshot_page = volumes_page.create_volume_snapshot(
self.VOLUME_NAME, self.VOLUME_SNAPSHOT_NAME)
@ -239,7 +233,9 @@ class TestVolumeSnapshotsAdvanced(helpers.TestCase):
self.VOLUME_SNAPSHOT_NAME, new_volume)
self.assertTrue(volumes_page.is_volume_present(new_volume))
self.assertTrue(volumes_page.is_volume_status(new_volume, 'Available'))
return new_volume
def delete_snapshot(self):
volumes_snapshot_page = self.volumes_snapshot_page
volumes_snapshot_page.delete_volume_snapshot(self.VOLUME_SNAPSHOT_NAME)
self.assertTrue(
@ -249,9 +245,47 @@ class TestVolumeSnapshotsAdvanced(helpers.TestCase):
self.assertTrue(volumes_snapshot_page.is_volume_snapshot_deleted(
self.VOLUME_SNAPSHOT_NAME))
def delete_volume(self, new_volume):
volumes_page = self.home_pg.go_to_project_volumes_volumespage()
volumes_page.delete_volume(new_volume)
self.assertTrue(
volumes_page.find_message_and_dismiss(messages.INFO))
self.assertFalse(volumes_page.find_message_and_dismiss(messages.ERROR))
self.assertTrue(volumes_page.is_volume_deleted(new_volume))
@pytest.mark.skipif(
not CONFIG.volume.allow_delete_snapshot_before_volume,
reason="Skipped due to allow_delete_snapshot_before_volume=False")
def test_create_volume_from_snapshot(self):
"""Test checks possibility to create volume from snapshot
Steps:
1. Login to Horizon Dashboard as regular user
2. Navigate to Project -> Volumes -> Volumes page
3. Create snapshot for existed volume
4. Create new volume from snapshot
5. Check the volume is created and has 'Available' status
6. Delete volume snapshot
7. Delete volume
"""
new_volume = self.create_volume_from_snapshot()
self.delete_snapshot()
self.delete_volume(new_volume)
def test_create_volume_from_snapshot_delete_volume_first(self):
"""Test checks possibility to create volume from snapshot
Steps:
1. Login to Horizon Dashboard as regular user
2. Navigate to Project -> Volumes -> Volumes page
3. Create snapshot for existed volume
4. Create new volume from snapshot
5. Check the volume is created and has 'Available' status
6. Delete volume
7. Delete volume snapshot
"""
new_volume = self.create_volume_from_snapshot()
self.delete_volume(new_volume)
self.delete_snapshot()