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 b231f83f38)
This commit is contained in:
Mehdi Abaakouk 2017-07-12 20:26:35 +02:00
parent 2b50f978aa
commit 2c40cdadd1
3 changed files with 23 additions and 25 deletions

View File

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

View File

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

View File

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