Return complete response from limits,migration client
Currently compute limits and migration client returns Response by removing top key from Response. For example- return service_client.ResponseBody(resp, body['limits']) As service clients are in direction to move to Tempest-lib, all service clients should return Response without any truncation. One good example is Resource pagination links which are lost with current way of return value. Resource pagination links are present in parallel (not inside) to top key of Response. This patch makes compute limits and migration client to return complete Response body. Change-Id: Ice3665e91ff34409f6f105303213303d1fca1816 Implements: blueprint method-return-value-and-move-service-clients-to-lib
This commit is contained in:
@@ -111,7 +111,8 @@ class LiveBlockMigrationTestJSON(base.BaseV2ComputeAdminTest):
|
||||
|
||||
self._migrate_server_to(server_id, target_host)
|
||||
waiters.wait_for_server_status(self.servers_client, server_id, state)
|
||||
migration_list = self.admin_migration_client.list_migrations()
|
||||
migration_list = (self.admin_migration_client.list_migrations()
|
||||
['migrations'])
|
||||
|
||||
msg = ("Live Migration failed. Migrations list for Instance "
|
||||
"%s: [" % server_id)
|
||||
|
||||
@@ -49,7 +49,7 @@ class MigrationsAdminTest(base.BaseV2ComputeAdminTest):
|
||||
waiters.wait_for_server_status(self.servers_client,
|
||||
server_id, 'ACTIVE')
|
||||
|
||||
body = self.client.list_migrations()
|
||||
body = self.client.list_migrations()['migrations']
|
||||
|
||||
instance_uuids = [x['instance_uuid'] for x in body]
|
||||
self.assertIn(server_id, instance_uuids)
|
||||
|
||||
@@ -112,7 +112,7 @@ class QuotasAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
||||
default_sg_quota = quota_set['security_groups']
|
||||
|
||||
# Set the quota to number of used security groups
|
||||
sg_quota = self.limits_client.show_limits()['absolute'][
|
||||
sg_quota = self.limits_client.show_limits()['limits']['absolute'][
|
||||
'totalSecurityGroupsUsed']
|
||||
|
||||
quota_set =\
|
||||
|
||||
@@ -27,7 +27,7 @@ class AbsoluteLimitsTestJSON(base.BaseV2ComputeTest):
|
||||
@test.idempotent_id('b54c66af-6ab6-4cf0-a9e5-a0cb58d75e0b')
|
||||
def test_absLimits_get(self):
|
||||
# To check if all limits are present in the response
|
||||
limits = self.client.show_limits()
|
||||
limits = self.client.show_limits()['limits']
|
||||
absolute_limits = limits['absolute']
|
||||
expected_elements = ['maxImageMeta', 'maxPersonality',
|
||||
'maxPersonalitySize',
|
||||
|
||||
@@ -38,7 +38,7 @@ class AbsoluteLimitsNegativeTestJSON(base.BaseV2ComputeTest):
|
||||
def test_max_image_meta_exceed_limit(self):
|
||||
# We should not create vm with image meta over maxImageMeta limit
|
||||
# Get max limit value
|
||||
limits = self.client.show_limits()
|
||||
limits = self.client.show_limits()['limits']
|
||||
max_meta = limits['absolute']['maxImageMeta']
|
||||
|
||||
# No point in running this test if there is no limit.
|
||||
|
||||
@@ -34,7 +34,7 @@ class ServerPersonalityTestJSON(base.BaseV2ComputeTest):
|
||||
# number of files are injected into the server.
|
||||
file_contents = 'This is a test file.'
|
||||
personality = []
|
||||
limits = self.user_client.show_limits()
|
||||
limits = self.user_client.show_limits()['limits']
|
||||
max_file_limit = limits['absolute']['maxPersonality']
|
||||
if max_file_limit == -1:
|
||||
raise self.skipException("No limit for personality files")
|
||||
@@ -52,7 +52,7 @@ class ServerPersonalityTestJSON(base.BaseV2ComputeTest):
|
||||
# Server should be created successfully if maximum allowed number of
|
||||
# files is injected into the server during creation.
|
||||
file_contents = 'This is a test file.'
|
||||
limits = self.user_client.show_limits()
|
||||
limits = self.user_client.show_limits()['limits']
|
||||
max_file_limit = limits['absolute']['maxPersonality']
|
||||
if max_file_limit == -1:
|
||||
raise self.skipException("No limit for personality files")
|
||||
|
||||
@@ -372,7 +372,7 @@ class NovaQuotaService(BaseService):
|
||||
|
||||
def dry_run(self):
|
||||
client = self.limits_client
|
||||
quotas = client.show_limits()
|
||||
quotas = client.show_limits()['limits']
|
||||
self.data['compute_quotas'] = quotas['absolute']
|
||||
|
||||
|
||||
|
||||
@@ -25,4 +25,4 @@ class LimitsClient(service_client.ServiceClient):
|
||||
resp, body = self.get("limits")
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.get_limit, resp, body)
|
||||
return service_client.ResponseBody(resp, body['limits'])
|
||||
return service_client.ResponseBody(resp, body)
|
||||
|
||||
@@ -31,4 +31,4 @@ class MigrationsClient(service_client.ServiceClient):
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
self.validate_response(schema.list_migrations, resp, body)
|
||||
return service_client.ResponseBodyList(resp, body['migrations'])
|
||||
return service_client.ResponseBody(resp, body)
|
||||
|
||||
@@ -31,27 +31,33 @@ class TestLimitsClient(base.TestCase):
|
||||
fake_auth, 'compute', 'regionOne')
|
||||
|
||||
def _test_show_limits(self, bytes_body=False):
|
||||
expected = {"rate": [],
|
||||
"absolute": {"maxServerMeta": 128,
|
||||
"maxPersonality": 5,
|
||||
"totalServerGroupsUsed": 0,
|
||||
"maxImageMeta": 128,
|
||||
"maxPersonalitySize": 10240,
|
||||
"maxServerGroups": 10,
|
||||
"maxSecurityGroupRules": 20,
|
||||
"maxTotalKeypairs": 100,
|
||||
"totalCoresUsed": 0,
|
||||
"totalRAMUsed": 0,
|
||||
"totalInstancesUsed": 0,
|
||||
"maxSecurityGroups": 10,
|
||||
"totalFloatingIpsUsed": 0,
|
||||
"maxTotalCores": 20,
|
||||
"totalSecurityGroupsUsed": 0,
|
||||
"maxTotalFloatingIps": 10,
|
||||
"maxTotalInstances": 10,
|
||||
"maxTotalRAMSize": 51200,
|
||||
"maxServerGroupMembers": 10}}
|
||||
serialized_body = json.dumps({"limits": expected})
|
||||
expected = {
|
||||
"limits": {
|
||||
"rate": [],
|
||||
"absolute": {
|
||||
"maxServerMeta": 128,
|
||||
"maxPersonality": 5,
|
||||
"totalServerGroupsUsed": 0,
|
||||
"maxImageMeta": 128,
|
||||
"maxPersonalitySize": 10240,
|
||||
"maxServerGroups": 10,
|
||||
"maxSecurityGroupRules": 20,
|
||||
"maxTotalKeypairs": 100,
|
||||
"totalCoresUsed": 0,
|
||||
"totalRAMUsed": 0,
|
||||
"totalInstancesUsed": 0,
|
||||
"maxSecurityGroups": 10,
|
||||
"totalFloatingIpsUsed": 0,
|
||||
"maxTotalCores": 20,
|
||||
"totalSecurityGroupsUsed": 0,
|
||||
"maxTotalFloatingIps": 10,
|
||||
"maxTotalInstances": 10,
|
||||
"maxTotalRAMSize": 51200,
|
||||
"maxServerGroupMembers": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
serialized_body = json.dumps(expected)
|
||||
if bytes_body:
|
||||
serialized_body = serialized_body.encode('utf-8')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user