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:
parent
dc46ab7ba6
commit
b9bbfc92bf
@ -59,6 +59,9 @@ class ServiceTest(object):
|
|||||||
"""Any post-test clean up work that needs to be done and not timed."""
|
"""Any post-test clean up work that needs to be done and not timed."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.get_connection()
|
||||||
|
|
||||||
def configure_logger(self, logger, console_logging=False):
|
def configure_logger(self, logger, console_logging=False):
|
||||||
"""Configure a stream and file log for a given service
|
"""Configure a stream and file log for a given service
|
||||||
|
|
||||||
@ -120,8 +123,25 @@ class ServiceTest(object):
|
|||||||
user_domain_id='default',
|
user_domain_id='default',
|
||||||
project_domain_id='default',
|
project_domain_id='default',
|
||||||
profile=prof)
|
profile=prof)
|
||||||
|
self.conn = conn
|
||||||
|
|
||||||
return 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):
|
class KeystoneTest(ServiceTest):
|
||||||
service_name = 'keystone'
|
service_name = 'keystone'
|
||||||
@ -203,6 +223,20 @@ class NovaTest(ServiceTest):
|
|||||||
return msg
|
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):
|
class TestRunner(object):
|
||||||
"""Run a test in a loop, with the option to gracefully exit"""
|
"""Run a test in a loop, with the option to gracefully exit"""
|
||||||
stop_now = False
|
stop_now = False
|
||||||
@ -294,6 +328,7 @@ available_tests = {
|
|||||||
'keystone': KeystoneTest,
|
'keystone': KeystoneTest,
|
||||||
'glance': GlanceTest,
|
'glance': GlanceTest,
|
||||||
'nova': NovaTest,
|
'nova': NovaTest,
|
||||||
|
'neutron': NeutronTest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user