From 2c40cdadd1112a3f3304362876c08e3d6d9d000e Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Wed, 12 Jul 2017 20:26:35 +0200 Subject: [PATCH] Fix gating * Install mongodb mongodb is not installed anymore * cap pifpaf Some libraries now use pbr>=2.0, recent cliff and stevedore. * Add sqlalchemy_util to all tests because it's used by gabbi * simplify crud notification test test_alarms_sends_notification will hang forever if it fails. we don't really need to test that its notification is received by other, just that it sends a notification. drop the test so it verifies only that. Change-Id: I05462398ccce224ee1e008c5ad2eab64b975192c (cherry picked from commit b231f83f381942a1dbc06ec6c36a54be73b46709) --- .../functional/api/v2/test_alarm_scenarios.py | 37 +++++++------------ aodh/tests/functional/hooks/post_test_hook.sh | 8 +++- setup.cfg | 3 +- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/aodh/tests/functional/api/v2/test_alarm_scenarios.py b/aodh/tests/functional/api/v2/test_alarm_scenarios.py index ad695dfb6..9eef8ffe6 100644 --- a/aodh/tests/functional/api/v2/test_alarm_scenarios.py +++ b/aodh/tests/functional/api/v2/test_alarm_scenarios.py @@ -20,7 +20,6 @@ import uuid from gnocchiclient import exceptions import mock -import oslo_messaging.conffixture from oslo_serialization import jsonutils import six from six import moves @@ -1716,30 +1715,22 @@ class TestAlarms(TestAlarmsBase): } } - endpoint = mock.MagicMock() - target = oslo_messaging.Target(topic="notifications") - listener = messaging.get_batch_notification_listener( - self.transport, [target], [endpoint]) - listener.start() - endpoint.info.side_effect = lambda *args: listener.stop() - self.post_json('/alarms', params=json, headers=self.auth_headers) - listener.wait() - - class NotificationsMatcher(object): - def __eq__(self, notifications): - payload = notifications[0]['payload'] - return (payload['detail']['name'] == 'sent_notification' and - payload['type'] == 'creation' and - payload['detail']['rule']['meter_name'] == 'ameter' and - set(['alarm_id', 'detail', 'event_id', 'on_behalf_of', - 'project_id', 'timestamp', + with mock.patch.object(messaging, 'get_notifier') as get_notifier: + notifier = get_notifier.return_value + self.post_json('/alarms', params=json, headers=self.auth_headers) + get_notifier.assert_called_once_with(mock.ANY, + publisher_id='aodh.api') + calls = notifier.info.call_args_list + self.assertEqual(1, len(calls)) + args, _ = calls[0] + context, event_type, payload = args + self.assertEqual('alarm.creation', event_type) + self.assertEqual('sent_notification', payload['detail']['name']) + self.assertEqual('ameter', payload['detail']['rule']['meter_name']) + self.assertTrue(set(['alarm_id', 'detail', 'event_id', 'on_behalf_of', + 'project_id', 'timestamp', 'type', 'user_id']).issubset(payload.keys())) - def __ne__(self, other): - return not self.__eq__(other) - - endpoint.info.assert_called_once_with(NotificationsMatcher()) - def test_alarm_sends_notification(self): with mock.patch.object(messaging, 'get_notifier') as get_notifier: notifier = get_notifier.return_value diff --git a/aodh/tests/functional/hooks/post_test_hook.sh b/aodh/tests/functional/hooks/post_test_hook.sh index 992d34ad9..2dcf8b2b9 100755 --- a/aodh/tests/functional/hooks/post_test_hook.sh +++ b/aodh/tests/functional/hooks/post_test_hook.sh @@ -53,7 +53,13 @@ echo "Running aodh functional test suite" set +e # NOTE(ityaptin) Expect a script param which contains at least one backend name -AODH_TEST_BACKEND="${1:?test backend required}" sudo -E -H -u ${STACK_USER:-${USER}} tox -efunctional +export AODH_TEST_BACKEND="${1:?test backend required}" + +case $AODH_TEST_BACKEND in + mongodb) sudo apt-get install -y mongodb-server ;; +esac + +sudo -E -H -u ${STACK_USER:-${USER}} tox -efunctional EXIT_CODE=$? set -e diff --git a/setup.cfg b/setup.cfg index 5262aaefe..dcd292770 100644 --- a/setup.cfg +++ b/setup.cfg @@ -64,7 +64,7 @@ doc = openstackdocstheme>=1.0.3 # Apache-2.0 test = - pifpaf>=0.1.0 + pifpaf>=0.1.0,<0.13.0 oslotest>=1.5.1 # Apache-2.0 coverage>=3.6 fixtures>=1.3.1 @@ -74,6 +74,7 @@ test = testresources>=0.2.4 # Apache-2.0/BSD testtools>=1.4.0 gabbi>=0.12.0 # Apache-2.0 + sqlalchemy-utils # Provides subunit-trace os-testr python-subunit>=0.0.18