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
This commit is contained in:
Nolan Brubaker 2017-05-31 14:01:10 -04:00
parent dc46ab7ba6
commit b9bbfc92bf

View File

@ -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
}