Check release is_deployable during upgrade notification
This patch adds check for "is_deployable" flag, which skips creating notifications for releases with is_deployable equal False. Change-Id: Id8d0ada07fdb1cfc8c37822ec25cb52608002d24 Closes-Bug: #1477958
This commit is contained in:
parent
e6dae705a8
commit
a67e758546
|
@ -125,6 +125,10 @@ class OpenStackUpgrader(UpgradeEngine):
|
|||
# save release id for futher possible rollback
|
||||
self._rollback_ids['release'].append(response['id'])
|
||||
self.upload_release_deployment_tasks(response)
|
||||
|
||||
if not release.get('is_deployable', True):
|
||||
continue
|
||||
|
||||
# add notification abot successfull releases
|
||||
logger.debug('Add notification about new release: %s (%s)',
|
||||
release['name'],
|
||||
|
|
|
@ -174,6 +174,72 @@ class TestOpenStackUpgrader(BaseTestCase):
|
|||
for type_ in ('release', 'notification'):
|
||||
self.assertEqual(len(self.upgrader._rollback_ids[type_]), 1)
|
||||
|
||||
@mock.patch(
|
||||
'fuel_upgrade.engines.openstack.glob.glob', return_value=['path'])
|
||||
@mock.patch(
|
||||
'fuel_upgrade.utils.iterfiles_filter',
|
||||
return_value=['/fake/path/tasks.yaml'])
|
||||
@mock.patch(
|
||||
'fuel_upgrade.engines.openstack.NailgunClient.put_deployment_tasks')
|
||||
@mock.patch(
|
||||
'fuel_upgrade.engines.openstack.NailgunClient.create_notification')
|
||||
@mock.patch(
|
||||
'fuel_upgrade.engines.openstack.NailgunClient.create_release')
|
||||
@mock.patch(
|
||||
'fuel_upgrade.engines.openstack.NailgunClient.get_releases',
|
||||
return_value=[])
|
||||
def test_install_releases_is_not_deployable(self, _, mock_cr, mock_cn,
|
||||
mock_pd, mock_files, gl):
|
||||
# use already parsed text, because mock_open returns input without any
|
||||
# changes, but we expect yaml parsed json
|
||||
releases_raw = ''' [
|
||||
{
|
||||
"pk": 1,
|
||||
"fields": {
|
||||
"name": "releases name",
|
||||
"version": "2014.1",
|
||||
"operating_system": "CentOS",
|
||||
}
|
||||
}, {
|
||||
"pk": 2,
|
||||
"fields": {
|
||||
"name": "Undeployable releases name",
|
||||
"version": "2014.1",
|
||||
"operating_system": "CentOS",
|
||||
"is_deployable": False,
|
||||
}
|
||||
}
|
||||
]
|
||||
'''
|
||||
|
||||
with mock.patch('fuel_upgrade.engines.openstack.io.open',
|
||||
self.mock_open(releases_raw)):
|
||||
upgrader = OpenStackUpgrader(self.fake_config)
|
||||
|
||||
# test one release
|
||||
release_response = [{'id': '1', 'version': '111'},
|
||||
{'id': '2', 'version': '222'}]
|
||||
mock_cr.side_effect = release_response
|
||||
mock_cn.return_value = {'id': '100'}
|
||||
|
||||
with mock.patch('fuel_upgrade.engines.openstack.utils.read_from_yaml',
|
||||
return_value=self.tasks):
|
||||
upgrader.install_releases()
|
||||
|
||||
self.called_times(mock_files, 2)
|
||||
|
||||
self.called_times(mock_cr, 2)
|
||||
# notification should be called only once
|
||||
self.called_once(mock_cn)
|
||||
msg = 'New release available: releases name (2014.1)'
|
||||
mock_cn.assert_called_with({'topic': 'release', 'message': msg})
|
||||
|
||||
self.called_times(mock_pd, 2)
|
||||
|
||||
self.assertEqual(len(upgrader._rollback_ids['release']), 2)
|
||||
# notification should be called only once
|
||||
self.assertEqual(len(upgrader._rollback_ids['notification']), 1)
|
||||
|
||||
@mock.patch(
|
||||
'fuel_upgrade.engines.openstack.NailgunClient.put_deployment_tasks')
|
||||
@mock.patch(
|
||||
|
|
Loading…
Reference in New Issue