Merge "Fix some nits in object storage clients release notes"
diff --git a/releasenotes/notes/add-volume-group-types-tempest-tests-1298ab8cb4fe8b7b.yaml b/releasenotes/notes/add-volume-group-types-tempest-tests-1298ab8cb4fe8b7b.yaml
new file mode 100644
index 0000000..4fd3bee
--- /dev/null
+++ b/releasenotes/notes/add-volume-group-types-tempest-tests-1298ab8cb4fe8b7b.yaml
@@ -0,0 +1,5 @@
+---
+features:
+  - |
+    Add list_group_type and show_group_type in the group_types client for
+    the volume service. Add tests for create/delete/show/list group types.
diff --git a/releasenotes/notes/remove-support-of-py34-7d59fdb431fefe24.yaml b/releasenotes/notes/remove-support-of-py34-7d59fdb431fefe24.yaml
new file mode 100644
index 0000000..093228a
--- /dev/null
+++ b/releasenotes/notes/remove-support-of-py34-7d59fdb431fefe24.yaml
@@ -0,0 +1,5 @@
+---
+deprecations:
+  - |
+    Remove the support of python3.4, because in Ubuntu Xenial only
+    python3.5 is available (python3.4 is restricted to <= Mitaka).
diff --git a/setup.cfg b/setup.cfg
index f52137e..04bb29f 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -16,7 +16,6 @@
     Programming Language :: Python :: 2
     Programming Language :: Python :: 2.7
     Programming Language :: Python :: 3
-    Programming Language :: Python :: 3.4
     Programming Language :: Python :: 3.5
 
 [files]
diff --git a/tempest/api/identity/admin/v3/test_oauth_consumers.py b/tempest/api/identity/admin/v3/test_oauth_consumers.py
index 970ead3..f06fb8f 100644
--- a/tempest/api/identity/admin/v3/test_oauth_consumers.py
+++ b/tempest/api/identity/admin/v3/test_oauth_consumers.py
@@ -14,7 +14,7 @@
 #    under the License.
 
 from tempest.api.identity import base
-from tempest.lib.common.utils import data_utils
+from tempest.common.utils import data_utils
 from tempest.lib.common.utils import test_utils
 from tempest.lib import decorators
 from tempest.lib import exceptions as exceptions
diff --git a/tempest/api/volume/admin/test_group_types.py b/tempest/api/volume/admin/test_group_types.py
new file mode 100644
index 0000000..0df5fbd
--- /dev/null
+++ b/tempest/api/volume/admin/test_group_types.py
@@ -0,0 +1,54 @@
+# Copyright (C) 2017 Dell Inc. or its subsidiaries.
+# 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.api.volume import base
+from tempest.lib.common.utils import data_utils
+from tempest.lib import decorators
+
+
+class GroupTypesTest(base.BaseVolumeAdminTest):
+    _api_version = 3
+    min_microversion = '3.11'
+    max_microversion = 'latest'
+
+    @decorators.idempotent_id('dd71e5f9-393e-4d4f-90e9-fa1b8d278864')
+    def test_group_type_create_list_show(self):
+        # Create/list/show group type.
+        name = data_utils.rand_name(self.__class__.__name__ + '-group-type')
+        description = data_utils.rand_name("group-type-description")
+        group_specs = {"consistent_group_snapshot_enabled": "<is> False"}
+        params = {'name': name,
+                  'description': description,
+                  'group_specs': group_specs,
+                  'is_public': True}
+        body = self.create_group_type(**params)
+        self.assertIn('name', body)
+        err_msg = ("The created group_type %(var)s is not equal to the "
+                   "requested %(var)s")
+        self.assertEqual(name, body['name'], err_msg % {"var": "name"})
+        self.assertEqual(description, body['description'],
+                         err_msg % {"var": "description"})
+
+        group_list = (
+            self.admin_group_types_client.list_group_types()['group_types'])
+        self.assertIsInstance(group_list, list)
+        self.assertNotEmpty(group_list)
+
+        fetched_group_type = self.admin_group_types_client.show_group_type(
+            body['id'])['group_type']
+        for key in params.keys():
+            self.assertEqual(params[key], fetched_group_type[key],
+                             '%s of the fetched group_type is different '
+                             'from the created group_type' % key)
diff --git a/tempest/common/credentials_factory.py b/tempest/common/credentials_factory.py
index a4cf009..fd875be 100644
--- a/tempest/common/credentials_factory.py
+++ b/tempest/common/credentials_factory.py
@@ -147,12 +147,16 @@
                 'A valid credential provider is needed')
 
 
-# We want a helper function here to check and see if admin credentials
-# are available so we can do a single call from skip_checks if admin
-# creds area available.
-# This depends on identity_version as there may be admin credentials
-# available for v2 but not for v3.
 def is_admin_available(identity_version):
+    """Helper to check for admin credentials
+
+    Helper function to check if a set of admin credentials is available so we
+    can do a single call from skip_checks.
+    This helper depends on identity_version as there may be admin credentials
+    available for v2 but not for v3.
+
+    :param identity_version: 'v2' or 'v3'
+    """
     is_admin = True
     # If dynamic credentials is enabled admin will be available
     if CONF.auth.use_dynamic_credentials:
@@ -173,12 +177,16 @@
     return is_admin
 
 
-# We want a helper function here to check and see if alt credentials
-# are available so we can do a single call from skip_checks if alt
-# creds area available.
-# This depends on identity_version as there may be alt credentials
-# available for v2 but not for v3.
 def is_alt_available(identity_version):
+    """Helper to check for alt credentials
+
+    Helper function to check if a second set of credentials is available (aka
+    alt credentials) so we can do a single call from skip_checks.
+    This helper depends on identity_version as there may be alt credentials
+    available for v2 but not for v3.
+
+    :param identity_version: 'v2' or 'v3'
+    """
     # If dynamic credentials is enabled alt will be available
     if CONF.auth.use_dynamic_credentials:
         return True
@@ -216,9 +224,19 @@
 }
 
 
-# Read credentials from configuration, builds a Credentials object
-# based on the specified or configured version
 def get_configured_admin_credentials(fill_in=True, identity_version=None):
+    """Get admin credentials from the config file
+
+    Read credentials from configuration, builds a Credentials object based on
+    the specified or configured version
+
+    :param fill_in: If True, a request to the Token API is submitted, and the
+                    credential object is filled in with all names and IDs from
+                    the token API response.
+    :param identity_version: The identity version to talk to and the type of
+                             credentials object to be created. 'v2' or 'v3'.
+    :returns: An object of a sub-type of `auth.Credentials`
+    """
     identity_version = identity_version or CONF.identity.auth_version
 
     if identity_version not in ('v2', 'v3'):
@@ -250,6 +268,19 @@
 # Wrapper around auth.get_credentials to use the configured identity version
 # if none is specified
 def get_credentials(fill_in=True, identity_version=None, **kwargs):
+    """Get credentials from dict based on config
+
+    Wrapper around auth.get_credentials to use the configured identity version
+    if none is specified.
+
+    :param fill_in: If True, a request to the Token API is submitted, and the
+                    credential object is filled in with all names and IDs from
+                    the token API response.
+    :param identity_version: The identity version to talk to and the type of
+                             credentials object to be created. 'v2' or 'v3'.
+    :param kwargs: Attributes to be used to build the Credentials object.
+    :returns: An object of a sub-type of `auth.Credentials`
+    """
     params = dict(DEFAULT_PARAMS, **kwargs)
     identity_version = identity_version or CONF.identity.auth_version
     # In case of "v3" add the domain from config if not specified
diff --git a/tempest/lib/common/rest_client.py b/tempest/lib/common/rest_client.py
index 63cf07f..f58d737 100644
--- a/tempest/lib/common/rest_client.py
+++ b/tempest/lib/common/rest_client.py
@@ -371,7 +371,7 @@
         on the endpoint in the catalog will return a list of supported API
         versions.
 
-        :return tuple with response headers and list of version numbers
+        :return: tuple with response headers and list of version numbers
         :rtype: tuple
         """
         resp, body = self.get('')
diff --git a/tempest/lib/services/clients.py b/tempest/lib/services/clients.py
index cd3bab0..5f230b7 100644
--- a/tempest/lib/services/clients.py
+++ b/tempest/lib/services/clients.py
@@ -161,7 +161,7 @@
         :param kwargs: Parameters to be passed to all clients. Parameters
             values can be overwritten when clients are initialised, but
             parameters cannot be deleted.
-        :raise ImportError if the specified module_path cannot be imported
+        :raise ImportError: if the specified module_path cannot be imported
 
         Example::
 
diff --git a/tempest/lib/services/network/versions_client.py b/tempest/lib/services/network/versions_client.py
index a9c3bbf..f87fe87 100644
--- a/tempest/lib/services/network/versions_client.py
+++ b/tempest/lib/services/network/versions_client.py
@@ -15,7 +15,6 @@
 import time
 
 from oslo_serialization import jsonutils as json
-from six.moves import urllib
 
 from tempest.lib.services.network import base
 
@@ -25,9 +24,7 @@
     def list_versions(self):
         """Do a GET / to fetch available API version information."""
 
-        endpoint = self.base_url
-        url = urllib.parse.urlparse(endpoint)
-        version_url = '%s://%s/' % (url.scheme, url.netloc)
+        version_url = self._get_base_version_url()
 
         # Note: we do a raw_request here because we want to use
         # an unversioned URL, not "v2/$project_id/".
diff --git a/tempest/lib/services/volume/v2/volumes_client.py b/tempest/lib/services/volume/v2/volumes_client.py
index d31259f..62b9992 100644
--- a/tempest/lib/services/volume/v2/volumes_client.py
+++ b/tempest/lib/services/volume/v2/volumes_client.py
@@ -318,6 +318,7 @@
         post_body = json.dumps({'os-retype': kwargs})
         resp, body = self.post('volumes/%s/action' % volume_id, post_body)
         self.expected_success(202, resp.status)
+        return rest_client.ResponseBody(resp, body)
 
     def force_detach_volume(self, volume_id, **kwargs):
         """Force detach a volume.
diff --git a/tempest/lib/services/volume/v3/group_types_client.py b/tempest/lib/services/volume/v3/group_types_client.py
index a6edbf5..97bac48 100644
--- a/tempest/lib/services/volume/v3/group_types_client.py
+++ b/tempest/lib/services/volume/v3/group_types_client.py
@@ -14,6 +14,7 @@
 #    under the License.
 
 from oslo_serialization import jsonutils as json
+from six.moves.urllib import parse as urllib
 
 from tempest.lib.common import rest_client
 from tempest.lib.services.volume import base_client
@@ -46,3 +47,31 @@
         resp, body = self.delete("group_types/%s" % group_type_id)
         self.expected_success(202, resp.status)
         return rest_client.ResponseBody(resp, body)
+
+    def list_group_types(self, **params):
+        """List all the group_types created.
+
+        For a full list of available parameters, please refer to the official
+        API reference:
+        https://developer.openstack.org/api-ref/block-storage/v3/#list-group-types
+        """
+        url = 'group_types'
+        if params:
+            url += '?%s' % urllib.urlencode(params)
+
+        resp, body = self.get(url)
+        body = json.loads(body)
+        self.expected_success(200, resp.status)
+        return rest_client.ResponseBody(resp, body)
+
+    def show_group_type(self, group_type_id):
+        """Returns the details of a single group_type.
+
+        For more information, please refer to the official API reference:
+        https://developer.openstack.org/api-ref/block-storage/v3/#show-group-type-details
+        """
+        url = "group_types/%s" % group_type_id
+        resp, body = self.get(url)
+        body = json.loads(body)
+        self.expected_success(200, resp.status)
+        return rest_client.ResponseBody(resp, body)
diff --git a/tempest/releasenotes/notes/add-return-value-to-retype-volume-a401aa619aaa2457.yaml b/tempest/releasenotes/notes/add-return-value-to-retype-volume-a401aa619aaa2457.yaml
new file mode 100644
index 0000000..4abfe9e
--- /dev/null
+++ b/tempest/releasenotes/notes/add-return-value-to-retype-volume-a401aa619aaa2457.yaml
@@ -0,0 +1,5 @@
+---
+fixes:
+  Add a missing return statement to the retype_volume API in the v2 volumes_client library.
+  This changes the response body from None to an empty dictionary.
+
diff --git a/tempest/tests/lib/services/volume/v2/test_extensions_client.py b/tempest/tests/lib/services/volume/v2/test_extensions_client.py
new file mode 100644
index 0000000..c0ee421
--- /dev/null
+++ b/tempest/tests/lib/services/volume/v2/test_extensions_client.py
@@ -0,0 +1,70 @@
+# Copyright 2017 FiberHome Telecommunication Technologies CO.,LTD
+# 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.lib.services.volume.v2 import extensions_client
+from tempest.tests.lib import fake_auth_provider
+from tempest.tests.lib.services import base
+
+
+class TestExtensionsClient(base.BaseServiceTest):
+
+    FAKE_EXTENSION_LIST = {
+        "extensions": [
+            {
+                "updated": "2012-03-12T00:00:00+00:00",
+                "name": "QuotaClasses",
+                "links": [],
+                "namespace": "fake-namespace-1",
+                "alias": "os-quota-class-sets",
+                "description": "Quota classes management support."
+            },
+            {
+                "updated": "2013-05-29T00:00:00+00:00",
+                "name": "VolumeTransfer",
+                "links": [],
+                "namespace": "fake-namespace-2",
+                "alias": "os-volume-transfer",
+                "description": "Volume transfer management support."
+            },
+            {
+                "updated": "2014-02-10T00:00:00+00:00",
+                "name": "VolumeManage",
+                "links": [],
+                "namespace": "fake-namespace-3",
+                "alias": "os-volume-manage",
+                "description": "Manage existing backend storage by Cinder."
+            }
+        ]
+    }
+
+    def setUp(self):
+        super(TestExtensionsClient, self).setUp()
+        fake_auth = fake_auth_provider.FakeAuthProvider()
+        self.client = extensions_client.ExtensionsClient(fake_auth,
+                                                         'volume',
+                                                         'regionOne')
+
+    def _test_list_extensions(self, bytes_body=False):
+        self.check_service_client_function(
+            self.client.list_extensions,
+            'tempest.lib.common.rest_client.RestClient.get',
+            self.FAKE_EXTENSION_LIST,
+            bytes_body)
+
+    def test_list_extensions_with_str_body(self):
+        self._test_list_extensions()
+
+    def test_list_extensions_with_bytes_body(self):
+        self._test_list_extensions(bytes_body=True)
diff --git a/tempest/tests/lib/services/volume/v2/test_limits_client.py b/tempest/tests/lib/services/volume/v2/test_limits_client.py
new file mode 100644
index 0000000..202054c
--- /dev/null
+++ b/tempest/tests/lib/services/volume/v2/test_limits_client.py
@@ -0,0 +1,59 @@
+# Copyright 2017 FiberHome Telecommunication Technologies CO.,LTD
+# 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.lib.services.volume.v2 import limits_client
+from tempest.tests.lib import fake_auth_provider
+from tempest.tests.lib.services import base
+
+
+class TestLimitsClient(base.BaseServiceTest):
+
+    FAKE_LIMIT_INFO = {
+        "limits": {
+            "rate": [],
+            "absolute": {
+                "totalSnapshotsUsed": 0,
+                "maxTotalBackups": 10,
+                "maxTotalVolumeGigabytes": 1000,
+                "maxTotalSnapshots": 10,
+                "maxTotalBackupGigabytes": 1000,
+                "totalBackupGigabytesUsed": 0,
+                "maxTotalVolumes": 10,
+                "totalVolumesUsed": 0,
+                "totalBackupsUsed": 0,
+                "totalGigabytesUsed": 0
+            }
+        }
+    }
+
+    def setUp(self):
+        super(TestLimitsClient, self).setUp()
+        fake_auth = fake_auth_provider.FakeAuthProvider()
+        self.client = limits_client.LimitsClient(fake_auth,
+                                                 'volume',
+                                                 'regionOne')
+
+    def _test_show_limits(self, bytes_body=False):
+        self.check_service_client_function(
+            self.client.show_limits,
+            'tempest.lib.common.rest_client.RestClient.get',
+            self.FAKE_LIMIT_INFO,
+            bytes_body)
+
+    def test_show_limits_with_str_body(self):
+        self._test_show_limits()
+
+    def test_show_limits_with_bytes_body(self):
+        self._test_show_limits(bytes_body=True)
diff --git a/tempest/tests/lib/services/volume/v2/test_volumes_client.py b/tempest/tests/lib/services/volume/v2/test_volumes_client.py
index befb1f6..e53e0a2 100644
--- a/tempest/tests/lib/services/volume/v2/test_volumes_client.py
+++ b/tempest/tests/lib/services/volume/v2/test_volumes_client.py
@@ -33,6 +33,22 @@
                                                    'volume',
                                                    'regionOne')
 
+    def _test_retype_volume(self, bytes_body=False):
+        kwargs = {
+            "new_type": "dedup-tier-replication",
+            "migration_policy": "never"
+        }
+
+        self.check_service_client_function(
+            self.client.retype_volume,
+            'tempest.lib.common.rest_client.RestClient.post',
+            {},
+            to_utf=bytes_body,
+            status=202,
+            volume_id="a3be971b-8de5-4bdf-bdb8-3d8eb0fb69f8",
+            **kwargs
+        )
+
     def _test_force_detach_volume(self, bytes_body=False):
         kwargs = {
             'attachment_id': '6980e295-920f-412e-b189-05c50d605acd',
@@ -71,3 +87,9 @@
 
     def test_show_volume_metadata_item_with_bytes_body(self):
         self._test_show_volume_metadata_item(bytes_body=True)
+
+    def test_retype_volume_with_str_body(self):
+        self._test_retype_volume()
+
+    def test_retype_volume_with_bytes_body(self):
+        self._test_retype_volume(bytes_body=True)
diff --git a/tempest/tests/lib/services/volume/v3/test_group_types_client.py b/tempest/tests/lib/services/volume/v3/test_group_types_client.py
index 95498c7..0f456a2 100644
--- a/tempest/tests/lib/services/volume/v3/test_group_types_client.py
+++ b/tempest/tests/lib/services/volume/v3/test_group_types_client.py
@@ -27,6 +27,46 @@
         }
     }
 
+    FAKE_INFO_GROUP_TYPE = {
+        "group_type": {
+            "id": "0e701ab8-1bec-4b9f-b026-a7ba4af13578",
+            "name": "group-type-001",
+            "description": "Test group type 1",
+            "is_public": True,
+            "created_at": "20127-06-20T03:50:07Z",
+            "group_specs": {},
+        }
+    }
+
+    FAKE_LIST_GROUP_TYPES = {
+        "group_types": [
+            {
+                "id": "0e701ab8-1bec-4b9f-b026-a7ba4af13578",
+                "name": "group-type-001",
+                "description": "Test group type 1",
+                "is_public": True,
+                "created_at": "2017-06-20T03:50:07Z",
+                "group_specs": {},
+            },
+            {
+                "id": "e479997c-650b-40a4-9dfe-77655818b0d2",
+                "name": "group-type-002",
+                "description": "Test group type 2",
+                "is_public": True,
+                "created_at": "2017-06-19T01:52:47Z",
+                "group_specs": {},
+            },
+            {
+                "id": "c5c4769e-213c-40a6-a568-8e797bb691d4",
+                "name": "group-type-003",
+                "description": "Test group type 3",
+                "is_public": True,
+                "created_at": "2017-06-18T06:34:32Z",
+                "group_specs": {},
+            }
+        ]
+    }
+
     def setUp(self):
         super(TestGroupTypesClient, self).setUp()
         fake_auth = fake_auth_provider.FakeAuthProvider()
@@ -42,6 +82,21 @@
             bytes_body,
             status=202)
 
+    def _test_show_group_type(self, bytes_body=False):
+        self.check_service_client_function(
+            self.client.show_group_type,
+            'tempest.lib.common.rest_client.RestClient.get',
+            self.FAKE_INFO_GROUP_TYPE,
+            bytes_body,
+            group_type_id="3fbbcccf-d058-4502-8844-6feeffdf4cb5")
+
+    def _test_list_group_types(self, bytes_body=False):
+        self.check_service_client_function(
+            self.client.list_group_types,
+            'tempest.lib.common.rest_client.RestClient.get',
+            self.FAKE_LIST_GROUP_TYPES,
+            bytes_body)
+
     def test_create_group_type_with_str_body(self):
         self._test_create_group_type()
 
@@ -55,3 +110,15 @@
             {},
             group_type_id='0e58433f-d108-4bf3-a22c-34e6b71ef86b',
             status=202)
+
+    def test_show_group_type_with_str_body(self):
+        self._test_show_group_type()
+
+    def test_show_group_type_with_bytes_body(self):
+        self._test_show_group_type(bytes_body=True)
+
+    def test_list_group_types_with_str_body(self):
+        self._test_list_group_types()
+
+    def test_list_group_types_with_bytes_body(self):
+        self._test_list_group_types(bytes_body=True)