Add api test for logging extension
Depends-On: I66234f45ee74c070119d84830790df296ba8d5f7
Partially-implements: blueprint security-group-logging
Related-Bug: #1468366
Change-Id: I19102b2b2c5cff78bccf05f19f30971d9b563b78
diff --git a/neutron_tempest_plugin/api/base.py b/neutron_tempest_plugin/api/base.py
index 68b5680..7b333fe 100644
--- a/neutron_tempest_plugin/api/base.py
+++ b/neutron_tempest_plugin/api/base.py
@@ -121,6 +121,7 @@
cls.admin_subnetpools = []
cls.security_groups = []
cls.projects = []
+ cls.log_objects = []
@classmethod
def resource_cleanup(cls):
@@ -213,6 +214,11 @@
cls._try_delete_resource(cls.admin_client.delete_qos_policy,
qos_policy['id'])
+ # Clean up log_objects
+ for log_object in cls.log_objects:
+ cls._try_delete_resource(cls.admin_client.delete_log,
+ log_object['id'])
+
super(BaseNetworkTest, cls).resource_cleanup()
@classmethod
@@ -516,6 +522,23 @@
return service_profile
@classmethod
+ def create_log(cls, name, description=None,
+ resource_type='security_group', resource_id=None,
+ target_id=None, event='ALL', enabled=True):
+ """Wrapper utility that returns a test log object."""
+ log_args = {'name': name,
+ 'description': description,
+ 'resource_type': resource_type,
+ 'resource_id': resource_id,
+ 'target_id': target_id,
+ 'event': event,
+ 'enabled': enabled}
+ body = cls.admin_client.create_log(**log_args)
+ log_object = body['log']
+ cls.log_objects.append(log_object)
+ return log_object
+
+ @classmethod
def get_unused_ip(cls, net_id, ip_version=None):
"""Get an unused ip address in a allocation pool of net"""
body = cls.admin_client.list_ports(network_id=net_id)