diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample index 50dc00c0e2..a184c7671d 100644 --- a/etc/tempest.conf.sample +++ b/etc/tempest.conf.sample @@ -211,7 +211,7 @@ # admin credentials are known. (boolean value) #allow_tenant_isolation=false -# Valid secondary image reference to be used in tests. (string +# Valid primary image reference to be used in tests. (string # value) #image_ref={$IMAGE_ID} @@ -978,6 +978,10 @@ # value) #disk_format=raw +# Default size in GB for volumes created by volumes tests +# (integer value) +#volume_size=1 + [volume-feature-enabled] diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py index be5d76bbbe..58da440ea6 100644 --- a/tempest/api/volume/test_volumes_get.py +++ b/tempest/api/volume/test_volumes_get.py @@ -51,8 +51,7 @@ class VolumesGetTest(base.BaseVolumeV1Test): v_name = data_utils.rand_name('Volume') metadata = {'Type': 'Test'} # Create a volume - resp, volume = self.client.create_volume(size=1, - display_name=v_name, + resp, volume = self.client.create_volume(display_name=v_name, metadata=metadata, **kwargs) self.assertEqual(200, resp.status) diff --git a/tempest/config.py b/tempest/config.py index 723504c544..c0ab3237e0 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -126,7 +126,7 @@ ComputeGroup = [ "OpenStack Identity API admin credentials are known."), cfg.StrOpt('image_ref', default="{$IMAGE_ID}", - help="Valid secondary image reference to be used in tests."), + help="Valid primary image reference to be used in tests."), cfg.StrOpt('image_ref_alt', default="{$IMAGE_ID_ALT}", help="Valid secondary image reference to be used in tests."), @@ -441,6 +441,9 @@ VolumeGroup = [ cfg.StrOpt('disk_format', default='raw', help='Disk format to use when copying a volume to image'), + cfg.IntOpt('volume_size', + default=1, + help='Default size in GB for volumes created by volumes tests'), ] volume_feature_group = cfg.OptGroup(name='volume-feature-enabled', diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py index e4d2e8dbb9..b55a0373e4 100644 --- a/tempest/services/volume/json/volumes_client.py +++ b/tempest/services/volume/json/volumes_client.py @@ -67,10 +67,10 @@ class VolumesClientJSON(rest_client.RestClient): body = json.loads(body) return resp, body['volume'] - def create_volume(self, size, **kwargs): + def create_volume(self, size=None, **kwargs): """ Creates a new Volume. - size(Required): Size of volume in GB. + size: Size of volume in GB. Following optional keyword arguments are accepted: display_name: Optional Volume Name. metadata: A dictionary of values to be used as metadata. @@ -78,6 +78,10 @@ class VolumesClientJSON(rest_client.RestClient): snapshot_id: When specified the volume is created from this snapshot imageRef: When specified the volume is created from this image """ + # for bug #1293885: + # If no size specified, read volume size from CONF + if size is None: + size = CONF.volume.volume_size post_body = {'size': size} post_body.update(kwargs) post_body = json.dumps({'volume': post_body}) diff --git a/tempest/services/volume/v2/json/volumes_client.py b/tempest/services/volume/v2/json/volumes_client.py index 5bfa75fc1d..df20a2ac8a 100644 --- a/tempest/services/volume/v2/json/volumes_client.py +++ b/tempest/services/volume/v2/json/volumes_client.py @@ -68,10 +68,10 @@ class VolumesV2ClientJSON(rest_client.RestClient): body = json.loads(body) return resp, body['volume'] - def create_volume(self, size, **kwargs): + def create_volume(self, size=None, **kwargs): """ Creates a new Volume. - size(Required): Size of volume in GB. + size: Size of volume in GB. Following optional keyword arguments are accepted: name: Optional Volume Name. metadata: A dictionary of values to be used as metadata. @@ -79,6 +79,10 @@ class VolumesV2ClientJSON(rest_client.RestClient): snapshot_id: When specified the volume is created from this snapshot imageRef: When specified the volume is created from this image """ + # for bug #1293885: + # If no size specified, read volume size from CONF + if size is None: + size = CONF.volume.volume_size post_body = {'size': size} post_body.update(kwargs) post_body = json.dumps({'volume': post_body}) diff --git a/tempest/services/volume/v2/xml/volumes_client.py b/tempest/services/volume/v2/xml/volumes_client.py index e735a657e4..1fdaf19b0f 100644 --- a/tempest/services/volume/v2/xml/volumes_client.py +++ b/tempest/services/volume/v2/xml/volumes_client.py @@ -117,10 +117,10 @@ class VolumesV2ClientXML(rest_client.RestClient): body = self._check_if_bootable(body) return resp, body - def create_volume(self, size, **kwargs): + def create_volume(self, size=None, **kwargs): """Creates a new Volume. - :param size: Size of volume in GB. (Required) + :param size: Size of volume in GB. :param name: Optional Volume Name. :param metadata: An optional dictionary of values for metadata. :param volume_type: Optional Name of volume_type for the volume @@ -129,6 +129,10 @@ class VolumesV2ClientXML(rest_client.RestClient): :param imageRef: When specified the volume is created from this image """ + # for bug #1293885: + # If no size specified, read volume size from CONF + if size is None: + size = CONF.volume.volume_size # NOTE(afazekas): it should use a volume namespace volume = common.Element("volume", xmlns=common.XMLNS_11, size=size) diff --git a/tempest/services/volume/xml/volumes_client.py b/tempest/services/volume/xml/volumes_client.py index 6866dad9e8..65bc321be8 100644 --- a/tempest/services/volume/xml/volumes_client.py +++ b/tempest/services/volume/xml/volumes_client.py @@ -118,10 +118,10 @@ class VolumesClientXML(rest_client.RestClient): body = self._check_if_bootable(body) return resp, body - def create_volume(self, size, **kwargs): + def create_volume(self, size=None, **kwargs): """Creates a new Volume. - :param size: Size of volume in GB. (Required) + :param size: Size of volume in GB. :param display_name: Optional Volume Name. :param metadata: An optional dictionary of values for metadata. :param volume_type: Optional Name of volume_type for the volume @@ -130,6 +130,10 @@ class VolumesClientXML(rest_client.RestClient): :param imageRef: When specified the volume is created from this image """ + # for bug #1293885: + # If no size specified, read volume size from CONF + if size is None: + size = CONF.volume.volume_size # NOTE(afazekas): it should use a volume namespace volume = common.Element("volume", xmlns=common.XMLNS_11, size=size)