From b9bbfc92bf004a436bd818b8a7c18ad843e7f046 Mon Sep 17 00:00:00 2001 From: Nolan Brubaker Date: Wed, 31 May 2017 14:01:10 -0400 Subject: [PATCH] Add Neutron API test Query the Neutron API for networks. Added the get_objects helper method since simply listing resources appears to be a fairly common operation in these tests. Will refactor existing tests to conform to this standard in a separate patch. Change-Id: I78fab1083e90bff8db46842b87f73556df153541 --- bowling_ball/rolling_tests.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/bowling_ball/rolling_tests.py b/bowling_ball/rolling_tests.py index 30f326f8..10006799 100755 --- a/bowling_ball/rolling_tests.py +++ b/bowling_ball/rolling_tests.py @@ -59,6 +59,9 @@ class ServiceTest(object): """Any post-test clean up work that needs to be done and not timed.""" raise NotImplementedError + def __init__(self): + self.get_connection() + def configure_logger(self, logger, console_logging=False): """Configure a stream and file log for a given service @@ -120,8 +123,25 @@ class ServiceTest(object): user_domain_id='default', project_domain_id='default', profile=prof) + self.conn = conn + return conn + def get_objects(self, service, name): + """Retrieve some sort of object from OpenStack APIs + + This applies to high level concepts like 'flavors', 'networks', + 'subnets', etc. + + :params: service - an openstack service corresponding to the OpenStack + SDK module used, such as 'compute', 'network', etc. + :param: name - name of a type of object, such as a 'network', + 'server', 'volume', etc owned by an OpenStack service + """ + + objs = [obj for obj in getattr(getattr(self.conn, service), name)()] + return objs + class KeystoneTest(ServiceTest): service_name = 'keystone' @@ -203,6 +223,20 @@ class NovaTest(ServiceTest): return msg +class NeutronTest(ServiceTest): + service_name = 'neutron' + description = 'Query for a list of networks' + + def run(self): + networks = self.get_objects('network', 'networks') + + msg = 'API reached, no networks found' + if networks: + msg = 'Network list received' + + return msg + + class TestRunner(object): """Run a test in a loop, with the option to gracefully exit""" stop_now = False @@ -294,6 +328,7 @@ available_tests = { 'keystone': KeystoneTest, 'glance': GlanceTest, 'nova': NovaTest, + 'neutron': NeutronTest }