From 37c4bd3023110f2a00e55439e2086d393b44a974 Mon Sep 17 00:00:00 2001 From: Martin Kopec Date: Thu, 24 Jun 2021 15:46:00 +0000 Subject: [PATCH] Add volume_size_extend opt for volume tests Volume tests had hardcoded value (1) in case they were creating a second volume with a different size than the first one (CONF.volume.volume_size). This is a problem for systems which have a chunk size other than 1. The patch is adding a new opt CONF.volume.volume_size_extend which allows customization of an extended volume size. Closes-Bug: 1917299 Change-Id: Ic8ae486224cd2a470f4f9bbad62d4d6715cc63ac --- ...-config--opt-for-volume-tests-041f7d25fc2f3e05.yaml | 10 ++++++++++ tempest/api/volume/test_volumes_clone.py | 5 +++-- tempest/api/volume/test_volumes_clone_negative.py | 4 ++-- tempest/api/volume/test_volumes_negative.py | 6 +++--- tempest/config.py | 5 +++++ 5 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/Add-volume_size_extend-config--opt-for-volume-tests-041f7d25fc2f3e05.yaml diff --git a/releasenotes/notes/Add-volume_size_extend-config--opt-for-volume-tests-041f7d25fc2f3e05.yaml b/releasenotes/notes/Add-volume_size_extend-config--opt-for-volume-tests-041f7d25fc2f3e05.yaml new file mode 100644 index 0000000000..8069bd300c --- /dev/null +++ b/releasenotes/notes/Add-volume_size_extend-config--opt-for-volume-tests-041f7d25fc2f3e05.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + Adding new config option for volume tests which allows to specify the size + a volume will be extended by (if a test does extend a volume or needs + a new bigger volume). The option is beneficial in case such tests are + executed on systems where the chunk size (the minimum size a volume can be + extended by) is other than 1 (originally hardcoded in the tests).: + + CONF.volume.volume_size_extend diff --git a/tempest/api/volume/test_volumes_clone.py b/tempest/api/volume/test_volumes_clone.py index eb5442618c..9ca1c5ede4 100644 --- a/tempest/api/volume/test_volumes_clone.py +++ b/tempest/api/volume/test_volumes_clone.py @@ -49,13 +49,14 @@ class VolumesCloneTest(base.BaseVolumeTest): # Creates a volume from another volume passing a size different from # the source volume. src_size = CONF.volume.volume_size + extend_size = CONF.volume.volume_size_extend src_vol = self.create_volume(size=src_size) # Destination volume bigger than source dst_vol = self.create_volume(source_volid=src_vol['id'], - size=src_size + 1) + size=src_size + extend_size) - self._verify_volume_clone(src_vol, dst_vol, extra_size=1) + self._verify_volume_clone(src_vol, dst_vol, extra_size=extend_size) @decorators.idempotent_id('cbbcd7c6-5a6c-481a-97ac-ca55ab715d16') @utils.services('image') diff --git a/tempest/api/volume/test_volumes_clone_negative.py b/tempest/api/volume/test_volumes_clone_negative.py index 4bfb166158..115465c95b 100644 --- a/tempest/api/volume/test_volumes_clone_negative.py +++ b/tempest/api/volume/test_volumes_clone_negative.py @@ -36,11 +36,11 @@ class VolumesCloneNegativeTest(base.BaseVolumeTest): """Test cloning a volume with decreasing size will fail""" # Creates a volume from another volume passing a size different from # the source volume. - src_size = CONF.volume.volume_size + 1 + src_size = CONF.volume.volume_size + CONF.volume.volume_size_extend src_vol = self.create_volume(size=src_size) # Destination volume smaller than source self.assertRaises(exceptions.BadRequest, self.volumes_client.create_volume, - size=src_size - 1, + size=src_size - CONF.volume.volume_size_extend, source_volid=src_vol['id']) diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py index 35dd0caf98..554fc6a84a 100644 --- a/tempest/api/volume/test_volumes_negative.py +++ b/tempest/api/volume/test_volumes_negative.py @@ -45,7 +45,7 @@ class VolumesNegativeTest(base.BaseVolumeTest): container_format=CONF.image.container_formats[0], disk_format=CONF.image.disk_formats[0], visibility='private', - min_disk=CONF.volume.volume_size + 1) + min_disk=CONF.volume.volume_size + CONF.volume.volume_size_extend) self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.images_client.delete_image, image['id']) @@ -223,7 +223,7 @@ class VolumesNegativeTest(base.BaseVolumeTest): @decorators.idempotent_id('8f05a943-013c-4063-ac71-7baf561e82eb') def test_volume_extend_with_nonexistent_volume_id(self): """Test extending non existent volume should fail""" - extend_size = self.volume['size'] + 1 + extend_size = self.volume['size'] + CONF.volume.volume_size_extend self.assertRaises(lib_exc.NotFound, self.volumes_client.extend_volume, data_utils.rand_uuid(), new_size=extend_size) @@ -231,7 +231,7 @@ class VolumesNegativeTest(base.BaseVolumeTest): @decorators.idempotent_id('aff8ba64-6d6f-4f2e-bc33-41a08ee9f115') def test_volume_extend_without_passing_volume_id(self): """Test extending volume without passing volume id should fail""" - extend_size = self.volume['size'] + 1 + extend_size = self.volume['size'] + CONF.volume.volume_size_extend self.assertRaises(lib_exc.NotFound, self.volumes_client.extend_volume, None, new_size=extend_size) diff --git a/tempest/config.py b/tempest/config.py index c409db66f2..6715a00d44 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -1000,6 +1000,11 @@ VolumeGroup = [ cfg.IntOpt('volume_size', default=1, help='Default size in GB for volumes created by volumes tests'), + cfg.IntOpt('volume_size_extend', + default=1, + help="Size in GB a volume is extended by - if a test " + "extends a volume, the size of the new volume will be " + "volume_size + volume_size_extend."), cfg.ListOpt('manage_volume_ref', default=['source-name', 'volume-%s'], help="A reference to existing volume for volume manage. "