Merge "Add tempest tests for 'stats' endpoint"

This commit is contained in:
Jenkins 2017-06-02 05:01:32 +00:00 committed by Gerrit Code Review
commit b0057b30d6
2 changed files with 17 additions and 0 deletions

View File

@ -175,6 +175,10 @@ class ZunClient(rest_client.RestClient):
return self.get(
self.container_uri(container_id, action='top'), None, **kwargs)
def stats_container(self, container_id, **kwargs):
return self.get(
self.container_uri(container_id, action='stats'), None, **kwargs)
def list_services(self, **kwargs):
resp, body = self.get(self.services_uri(), **kwargs)
return self.deserialize(resp, body,

View File

@ -298,6 +298,19 @@ class TestContainer(base.BaseZunTest):
self.assertEqual(200, resp.status)
self.assertTrue('sleep 1000000' in body)
@decorators.idempotent_id('09638306-b501-4803-aafa-7e8025632cef')
def test_stats_container(self):
_, model = self._run_container()
resp, body = self.container_client.stats_container(model.uuid)
self.assertEqual(200, resp.status)
self.assertTrue('NET I/O(B)' in body)
self.assertTrue('CONTAINER' in body)
self.assertTrue('MEM LIMIT(MiB)' in body)
self.assertTrue('CPU %' in body)
self.assertTrue('MEM USAGE(MiB)' in body)
self.assertTrue('MEM %' in body)
self.assertTrue('BLOCK I/O(B)' in body)
def _assert_resource_constraints(self, container, cpu=None, memory=None):
if cpu is not None:
cpu_quota = container.get('HostConfig').get('CpuQuota')