Add server group API schema for microversion 2.13

In Nova microversion 2.13, 'project_id' and 'user_id' parameters
have been added in the response of server group APIs (Compute).
So add server group API schema for microversion 2.13.

Change-Id: I43ae2138500b337b9184ed3492ca14be6774b162
diff --git a/tempest/lib/api_schema/response/compute/v2_13/__init__.py b/tempest/lib/api_schema/response/compute/v2_13/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/lib/api_schema/response/compute/v2_13/__init__.py
diff --git a/tempest/lib/api_schema/response/compute/v2_13/servers.py b/tempest/lib/api_schema/response/compute/v2_13/servers.py
new file mode 100644
index 0000000..a90f3e4
--- /dev/null
+++ b/tempest/lib/api_schema/response/compute/v2_13/servers.py
@@ -0,0 +1,34 @@
+# Copyright 2017 NTT Corporation.  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.
+
+import copy
+
+from tempest.lib.api_schema.response.compute.v2_1 import servers
+
+
+common_server_group = copy.deepcopy(servers.common_server_group)
+common_server_group['properties']['project_id'] = {'type': 'string'}
+common_server_group['properties']['user_id'] = {'type': 'string'}
+common_server_group['required'].append('project_id')
+common_server_group['required'].append('user_id')
+
+create_show_server_group = copy.deepcopy(servers.create_show_server_group)
+create_show_server_group['response_body']['properties'][
+    'server_group'] = common_server_group
+
+delete_server_group = copy.deepcopy(servers.delete_server_group)
+
+list_server_groups = copy.deepcopy(servers.list_server_groups)
+list_server_groups['response_body']['properties']['server_groups'][
+    'items'] = common_server_group
diff --git a/tempest/lib/services/compute/server_groups_client.py b/tempest/lib/services/compute/server_groups_client.py
index 3a935b4..03cd645 100644
--- a/tempest/lib/services/compute/server_groups_client.py
+++ b/tempest/lib/services/compute/server_groups_client.py
@@ -17,12 +17,17 @@
 from oslo_serialization import jsonutils as json
 
 from tempest.lib.api_schema.response.compute.v2_1 import servers as schema
+from tempest.lib.api_schema.response.compute.v2_13 import servers as schemav213
 from tempest.lib.common import rest_client
 from tempest.lib.services.compute import base_compute_client
 
 
 class ServerGroupsClient(base_compute_client.BaseComputeClient):
 
+    schema_versions_info = [
+        {'min': None, 'max': '2.12', 'schema': schema},
+        {'min': '2.13', 'max': None, 'schema': schemav213}]
+
     def create_server_group(self, **kwargs):
         """Create the server group.
 
@@ -34,12 +39,14 @@
         resp, body = self.post('os-server-groups', post_body)
 
         body = json.loads(body)
+        schema = self.get_schema(self.schema_versions_info)
         self.validate_response(schema.create_show_server_group, resp, body)
         return rest_client.ResponseBody(resp, body)
 
     def delete_server_group(self, server_group_id):
         """Delete the given server-group."""
         resp, body = self.delete("os-server-groups/%s" % server_group_id)
+        schema = self.get_schema(self.schema_versions_info)
         self.validate_response(schema.delete_server_group, resp, body)
         return rest_client.ResponseBody(resp, body)
 
@@ -47,6 +54,7 @@
         """List the server-groups."""
         resp, body = self.get("os-server-groups")
         body = json.loads(body)
+        schema = self.get_schema(self.schema_versions_info)
         self.validate_response(schema.list_server_groups, resp, body)
         return rest_client.ResponseBody(resp, body)
 
@@ -54,5 +62,6 @@
         """Get the details of given server_group."""
         resp, body = self.get("os-server-groups/%s" % server_group_id)
         body = json.loads(body)
+        schema = self.get_schema(self.schema_versions_info)
         self.validate_response(schema.create_show_server_group, resp, body)
         return rest_client.ResponseBody(resp, body)
diff --git a/tempest/tests/lib/services/compute/test_server_groups_client.py b/tempest/tests/lib/services/compute/test_server_groups_client.py
index 1c535ca..9055a36 100644
--- a/tempest/tests/lib/services/compute/test_server_groups_client.py
+++ b/tempest/tests/lib/services/compute/test_server_groups_client.py
@@ -13,9 +13,10 @@
 #    under the License.
 
 import fixtures
-from tempest.tests.lib import fake_auth_provider
 
+from tempest.lib.services.compute import base_compute_client
 from tempest.lib.services.compute import server_groups_client
+from tempest.tests.lib import fake_auth_provider
 from tempest.tests.lib import fake_http
 from tempest.tests.lib.services import base
 
@@ -36,7 +37,7 @@
             fake_auth, 'compute', 'regionOne')
 
     def _test_create_server_group(self, bytes_body=False):
-        expected = {"server_group": TestServerGroupsClient.server_group}
+        expected = {"server_group": self.server_group}
         self.check_service_client_function(
             self.client.create_server_group,
             'tempest.lib.common.rest_client.RestClient.post', expected,
@@ -56,7 +57,7 @@
         self.client.delete_server_group('fake-group')
 
     def _test_list_server_groups(self, bytes_body=False):
-        expected = {"server_groups": [TestServerGroupsClient.server_group]}
+        expected = {"server_groups": [self.server_group]}
         self.check_service_client_function(
             self.client.list_server_groups,
             'tempest.lib.common.rest_client.RestClient.get',
@@ -69,7 +70,7 @@
         self._test_list_server_groups(bytes_body=True)
 
     def _test_show_server_group(self, bytes_body=False):
-        expected = {"server_group": TestServerGroupsClient.server_group}
+        expected = {"server_group": self.server_group}
         self.check_service_client_function(
             self.client.show_server_group,
             'tempest.lib.common.rest_client.RestClient.get',
@@ -81,3 +82,20 @@
 
     def test_show_server_group_byte_body(self):
         self._test_show_server_group(bytes_body=True)
+
+
+class TestServerGroupsClientMinV213(TestServerGroupsClient):
+
+    server_group = {
+        "id": "5bbcc3c4-1da2-4437-a48a-66f15b1b13f9",
+        "name": "test",
+        "policies": ["anti-affinity"],
+        "members": [],
+        "metadata": {},
+        "project_id": "0beb4bffb7a445eb8eb05fee3ee7660a",
+        "user_id": "86031628064a4f99bb66ec03c507dcd8"}
+
+    def setUp(self):
+        super(TestServerGroupsClientMinV213, self).setUp()
+        self.patchobject(base_compute_client, 'COMPUTE_MICROVERSION',
+                         new='2.13')