Fix webhook tempests

Change-Id: I2f5e462d5c05e39cb89da9dd36abf52ff296d4ac
Implements: blueprint configurable-notifications
This commit is contained in:
Ifat Afek 2018-01-23 12:50:45 +00:00
parent 9fce59c4d1
commit 0c3151540c
3 changed files with 15 additions and 4 deletions

View File

@ -17,8 +17,7 @@ DEVSTACK_PATH="$BASE/new"
#Argument is received from Zuul
if [ "$1" = "api" ]; then
TESTS="topology|test_rca|test_alarms|test_resources|test_template
|test_webhook"
TESTS="topology|test_rca|test_alarms|test_resources|test_template|webhook"
elif [ "$1" = "datasources" ]; then
TESTS="datasources|test_events|notifiers|e2e|database"
else

View File

@ -54,18 +54,27 @@ class Webhook(NotifierBase):
if event_type == NotifierEventTypes.ACTIVATE_ALARM_EVENT \
or event_type == NotifierEventTypes.DEACTIVATE_ALARM_EVENT:
LOG.info('Webhook API starting to process %s', str(data))
LOG.info('Webhook notifier started processing %s', str(data))
webhooks = self._load_webhooks()
LOG.debug('There are %d registered webhooks', len(webhooks))
if webhooks:
for webhook in webhooks:
webhook_filters = self._get_webhook_filters(webhook)
data = self._filter_fields(data)
LOG.debug('webhook_filter: %s, filtered data: %s',
str(webhook_filters), str(data))
if self._check_against_filter(webhook_filters, data)\
and self._check_correct_tenant(webhook, data):
LOG.info('Going to post data to webhook %s',
str(webhook))
self._post_data(webhook, event_type, data)
LOG.info('Webhook API finished processing %s', str(data))
LOG.info('Webhook notifier finished processing %s', str(data))
def _post_data(self, webhook, event_type, data):
try:

View File

@ -85,6 +85,7 @@ class TestWebhook(TestActionsBase):
self._trigger_undo_action(TRIGGER_ALARM_1)
self.mock_server.reset_requests_list()
@utils.tempest_logger
def test_webhook_with_no_filter(self):
"""Test to see that a webhook with no filter receives all
@ -119,6 +120,7 @@ class TestWebhook(TestActionsBase):
self._trigger_undo_action(TRIGGER_ALARM_2)
self.mock_server.reset_requests_list()
@utils.tempest_logger
def test_webhook_with_no_match(self):
"""Test to check that filters with no match do not send event """
@ -150,6 +152,7 @@ class TestWebhook(TestActionsBase):
self._trigger_undo_action(TRIGGER_ALARM_2)
self.mock_server.reset_requests_list()
@utils.tempest_logger
def test_multiple_webhooks(self):
"""Test to check filter by type and by ID (with 2 different