Adds list pool stat test case

This submission is to validate the list pool stat feature.
Adds a test case to test_loadbalancer.py and support function
in XML/JSON interfaces

Change-Id: Ia284334c9127ec200a48c098d28bdaf188281887
This commit is contained in:
nayna-patel 2014-02-07 10:24:59 +00:00
parent b06283d820
commit 87b4ef2903
3 changed files with 23 additions and 0 deletions

View File

@ -209,6 +209,17 @@ class LoadBalancerTestJSON(base.BaseNetworkTest):
(self.health_monitor['id'], self.pool['id']))
self.assertEqual('204', resp['status'])
@test.attr(type='smoke')
def test_get_lb_pool_stats(self):
# Verify the details of pool stats
resp, body = self.client.list_lb_pool_stats(self.pool['id'])
self.assertEqual('200', resp['status'])
stats = body['stats']
self.assertIn("bytes_in", stats)
self.assertIn("total_connections", stats)
self.assertIn("active_connections", stats)
self.assertIn("bytes_out", stats)
class LoadBalancerTestXML(LoadBalancerTestJSON):
_interface = 'xml'

View File

@ -417,3 +417,9 @@ class NetworkClientJSON(network_client_base.NetworkClientBase):
resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body
def list_lb_pool_stats(self, pool_id):
uri = '%s/lb/pools/%s/stats' % (self.uri_prefix, pool_id)
resp, body = self.get(uri)
body = json.loads(body)
return resp, body

View File

@ -321,6 +321,12 @@ class NetworkClientXML(client_base.NetworkClientBase):
resp, body = self.delete(uri)
return resp, body
def list_lb_pool_stats(self, pool_id):
uri = '%s/lb/pools/%s/stats' % (self.uri_prefix, pool_id)
resp, body = self.get(uri)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def _root_tag_fetcher_and_xml_to_json_parse(xml_returned_body):
body = ET.fromstring(xml_returned_body)