Add a version API test for Nova v3 API
The version API of Nova returns the API version information with the
following body:
{"version":
{"id": "v3.0",
"status": "EXPERIMENTAL",
"updated": "2013-07-23T11:33:21Z",
..
}
}
This patch adds the API test.
Partially implements blueprint nova-v3-api-tests
Change-Id: Ibd6c3b4f3228340b265cbc9a0e7fe2dbc93c691c
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index b060f15..6ef43bc 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -273,6 +273,7 @@
cls.aggregates_client = cls.os.aggregates_v3_client
cls.hosts_client = cls.os.hosts_v3_client
cls.quotas_client = cls.os.quotas_v3_client
+ cls.version_client = cls.os.version_v3_client
@classmethod
def create_image_from_server(cls, server_id, **kwargs):
diff --git a/tempest/api/compute/v3/test_version.py b/tempest/api/compute/v3/test_version.py
new file mode 100644
index 0000000..166d161
--- /dev/null
+++ b/tempest/api/compute/v3/test_version.py
@@ -0,0 +1,34 @@
+# Copyright 2014 NEC 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.
+
+
+from tempest.api.compute import base
+from tempest import test
+
+
+class VersionV3TestJSON(base.BaseV3ComputeTest):
+ _interface = 'json'
+
+ @test.attr(type='gate')
+ def test_version(self):
+ # Get version information
+ resp, version = self.version_client.get_version()
+ self.assertEqual(200, resp.status)
+ self.assertIn("id", version)
+ self.assertEqual("v3.0", version["id"])
+
+
+class VersionV3TestXML(VersionV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/clients.py b/tempest/clients.py
index 83b72c6..b0b9409 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -74,6 +74,8 @@
ServicesV3ClientJSON
from tempest.services.compute.v3.json.tenant_usages_client import \
TenantUsagesV3ClientJSON
+from tempest.services.compute.v3.json.version_client import \
+ VersionV3ClientJSON
from tempest.services.compute.v3.xml.aggregates_client import \
AggregatesV3ClientXML
from tempest.services.compute.v3.xml.availability_zone_client import \
@@ -96,6 +98,7 @@
ServicesV3ClientXML
from tempest.services.compute.v3.xml.tenant_usages_client import \
TenantUsagesV3ClientXML
+from tempest.services.compute.v3.xml.version_client import VersionV3ClientXML
from tempest.services.compute.xml.aggregates_client import AggregatesClientXML
from tempest.services.compute.xml.availability_zone_client import \
AvailabilityZoneClientXML
@@ -272,6 +275,7 @@
self.tenant_usages_v3_client = TenantUsagesV3ClientXML(
*client_args)
self.tenant_usages_client = TenantUsagesClientXML(*client_args)
+ self.version_v3_client = VersionV3ClientXML(*client_args)
self.policy_client = PolicyClientXML(*client_args)
self.hosts_client = HostsClientXML(*client_args)
self.hypervisor_v3_client = HypervisorV3ClientXML(*client_args)
@@ -334,6 +338,7 @@
self.tenant_usages_v3_client = TenantUsagesV3ClientJSON(
*client_args)
self.tenant_usages_client = TenantUsagesClientJSON(*client_args)
+ self.version_v3_client = VersionV3ClientJSON(*client_args)
self.policy_client = PolicyClientJSON(*client_args)
self.hosts_client = HostsClientJSON(*client_args)
self.hypervisor_v3_client = HypervisorV3ClientJSON(*client_args)
diff --git a/tempest/services/compute/v3/json/version_client.py b/tempest/services/compute/v3/json/version_client.py
new file mode 100644
index 0000000..1773af5
--- /dev/null
+++ b/tempest/services/compute/v3/json/version_client.py
@@ -0,0 +1,32 @@
+# Copyright 2014 NEC 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 json
+
+from tempest.common import rest_client
+
+
+class VersionV3ClientJSON(rest_client.RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(VersionV3ClientJSON, self).__init__(config, username,
+ password, auth_url,
+ tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def get_version(self):
+ resp, body = self.get('')
+ body = json.loads(body)
+ return resp, body['version']
diff --git a/tempest/services/compute/v3/xml/version_client.py b/tempest/services/compute/v3/xml/version_client.py
new file mode 100644
index 0000000..7ecb31f
--- /dev/null
+++ b/tempest/services/compute/v3/xml/version_client.py
@@ -0,0 +1,37 @@
+# Copyright 2014 NEC 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.
+
+from lxml import etree
+
+from tempest.common import rest_client
+from tempest.services.compute.xml import common
+
+
+class VersionV3ClientXML(rest_client.RestClientXML):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(VersionV3ClientXML, self).__init__(config, username,
+ password, auth_url,
+ tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def _parse_array(self, node):
+ json = common.xml_to_json(node)
+ return json
+
+ def get_version(self):
+ resp, body = self.get('', self.headers)
+ body = self._parse_array(etree.fromstring(body))
+ return resp, body