Merge "Return complete response from services_client"
diff --git a/tempest/api/compute/admin/test_services.py b/tempest/api/compute/admin/test_services.py
index db22925..4d7dea5 100644
--- a/tempest/api/compute/admin/test_services.py
+++ b/tempest/api/compute/admin/test_services.py
@@ -31,25 +31,25 @@
@test.idempotent_id('5be41ef4-53d1-41cc-8839-5c2a48a1b283')
def test_list_services(self):
- services = self.client.list_services()
+ services = self.client.list_services()['services']
self.assertNotEqual(0, len(services))
@test.idempotent_id('f345b1ec-bc6e-4c38-a527-3ca2bc00bef5')
def test_get_service_by_service_binary_name(self):
binary_name = 'nova-compute'
- services = self.client.list_services(binary=binary_name)
+ services = self.client.list_services(binary=binary_name)['services']
self.assertNotEqual(0, len(services))
for service in services:
self.assertEqual(binary_name, service['binary'])
@test.idempotent_id('affb42d5-5b4b-43c8-8b0b-6dca054abcca')
def test_get_service_by_host_name(self):
- services = self.client.list_services()
+ services = self.client.list_services()['services']
host_name = services[0]['host']
services_on_host = [service for service in services if
service['host'] == host_name]
- services = self.client.list_services(host=host_name)
+ services = self.client.list_services(host=host_name)['services']
# we could have a periodic job checkin between the 2 service
# lookups, so only compare binary lists.
@@ -62,12 +62,12 @@
@test.idempotent_id('39397f6f-37b8-4234-8671-281e44c74025')
def test_get_service_by_service_and_host_name(self):
- services = self.client.list_services()
+ services = self.client.list_services()['services']
host_name = services[0]['host']
binary_name = services[0]['binary']
services = self.client.list_services(host=host_name,
- binary=binary_name)
+ binary=binary_name)['services']
self.assertEqual(1, len(services))
self.assertEqual(host_name, services[0]['host'])
self.assertEqual(binary_name, services[0]['binary'])
diff --git a/tempest/api/compute/admin/test_services_negative.py b/tempest/api/compute/admin/test_services_negative.py
index b9335c9..0c81ccb 100644
--- a/tempest/api/compute/admin/test_services_negative.py
+++ b/tempest/api/compute/admin/test_services_negative.py
@@ -40,22 +40,25 @@
@test.idempotent_id('d0884a69-f693-4e79-a9af-232d15643bf7')
def test_get_service_by_invalid_params(self):
# return all services if send the request with invalid parameter
- services = self.client.list_services()
- services_xxx = self.client.list_services(xxx='nova-compute')
+ services = self.client.list_services()['services']
+ services_xxx = (self.client.list_services(xxx='nova-compute')
+ ['services'])
self.assertEqual(len(services), len(services_xxx))
@test.attr(type=['negative'])
@test.idempotent_id('1e966d4a-226e-47c7-b601-0b18a27add54')
def test_get_service_by_invalid_service_and_valid_host(self):
- services = self.client.list_services()
+ services = self.client.list_services()['services']
host_name = services[0]['host']
- services = self.client.list_services(host=host_name, binary='xxx')
+ services = self.client.list_services(host=host_name,
+ binary='xxx')['services']
self.assertEqual(0, len(services))
@test.attr(type=['negative'])
@test.idempotent_id('64e7e7fb-69e8-4cb6-a71d-8d5eb0c98655')
def test_get_service_with_valid_service_and_invalid_host(self):
- services = self.client.list_services()
+ services = self.client.list_services()['services']
binary_name = services[0]['binary']
- services = self.client.list_services(host='xxx', binary=binary_name)
+ services = self.client.list_services(host='xxx',
+ binary=binary_name)['services']
self.assertEqual(0, len(services))
diff --git a/tempest/services/compute/json/services_client.py b/tempest/services/compute/json/services_client.py
index 699d3e7..232b301 100644
--- a/tempest/services/compute/json/services_client.py
+++ b/tempest/services/compute/json/services_client.py
@@ -31,7 +31,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_services, resp, body)
- return service_client.ResponseBodyList(resp, body['services'])
+ return service_client.ResponseBody(resp, body)
def enable_service(self, host_name, binary):
"""
@@ -43,7 +43,7 @@
resp, body = self.put('os-services/enable', post_body)
body = json.loads(body)
self.validate_response(schema.enable_service, resp, body)
- return service_client.ResponseBody(resp, body['service'])
+ return service_client.ResponseBody(resp, body)
def disable_service(self, host_name, binary):
"""
@@ -54,4 +54,4 @@
post_body = json.dumps({'binary': binary, 'host': host_name})
resp, body = self.put('os-services/disable', post_body)
body = json.loads(body)
- return service_client.ResponseBody(resp, body['service'])
+ return service_client.ResponseBody(resp, body)
diff --git a/tempest/tests/services/compute/test_services_client.py b/tempest/tests/services/compute/test_services_client.py
index 61ca830..7d87711 100644
--- a/tempest/tests/services/compute/test_services_client.py
+++ b/tempest/tests/services/compute/test_services_client.py
@@ -49,7 +49,8 @@
fake_auth, 'compute', 'regionOne')
def _test_list_services(self, bytes_body=False):
- serialized_body = json.dumps({"services": self.FAKE_SERVICES})
+ expected = {"services": self.FAKE_SERVICES}
+ serialized_body = json.dumps(expected)
if bytes_body:
serialized_body = serialized_body.encode('utf-8')
@@ -58,7 +59,7 @@
'tempest.common.service_client.ServiceClient.get',
return_value=mocked_resp))
resp = self.client.list_services()
- self.assertEqual(self.FAKE_SERVICES, resp)
+ self.assertEqual(expected, resp)
def test_list_services_with_str_body(self):
self._test_list_services()
@@ -67,7 +68,8 @@
self._test_list_services(bytes_body=True)
def _test_enable_service(self, bytes_body=False):
- serialized_body = json.dumps({"service": self.FAKE_SERVICE})
+ expected = {"service": self.FAKE_SERVICE}
+ serialized_body = json.dumps(expected)
if bytes_body:
serialized_body = serialized_body.encode('utf-8')
@@ -76,7 +78,7 @@
'tempest.common.service_client.ServiceClient.put',
return_value=mocked_resp))
resp = self.client.enable_service("nova-conductor", "controller")
- self.assertEqual(self.FAKE_SERVICE, resp)
+ self.assertEqual(expected, resp)
def test_enable_service_with_str_body(self):
self._test_enable_service()
@@ -87,8 +89,8 @@
def _test_disable_service(self, bytes_body=False):
fake_service = copy.deepcopy(self.FAKE_SERVICE)
fake_service["status"] = "disable"
-
- serialized_body = json.dumps({"service": self.FAKE_SERVICE})
+ expected = {"service": self.FAKE_SERVICE}
+ serialized_body = json.dumps(expected)
if bytes_body:
serialized_body = serialized_body.encode('utf-8')
@@ -97,7 +99,7 @@
'tempest.common.service_client.ServiceClient.put',
return_value=mocked_resp))
resp = self.client.disable_service("nova-conductor", "controller")
- self.assertEqual(self.FAKE_SERVICE, resp)
+ self.assertEqual(expected, resp)
def test_disable_service_with_str_body(self):
self._test_enable_service()