Beispiel #1
0
 def test_ceilometer_upgrade_helper_incomplete(self, mock_config,
                                               mock_ceilometer_upgrade):
     self.get_os_codename_install_source.return_value = 'ocata'
     self.CONFIGS = MagicMock()
     with self.assertRaises(utils.FailedAction):
         utils.ceilometer_upgrade_helper(self.CONFIGS)
     mock_ceilometer_upgrade.assert_not_called()
 def test_ceilometer_upgrade_helper_incomplete(self, mock_config,
                                               mock_ceilometer_upgrade):
     self.get_os_codename_install_source.return_value = 'ocata'
     self.CONFIGS = MagicMock()
     with self.assertRaises(utils.FailedAction):
         utils.ceilometer_upgrade_helper(self.CONFIGS)
     mock_ceilometer_upgrade.assert_not_called()
Beispiel #3
0
 def test_ceilometer_upgrade_helper_with_metrics(self, mock_config,
                                                 mock_ceilometer_upgrade):
     self.get_os_codename_install_source.return_value = 'ocata'
     self.CONFIGS = MagicMock()
     self.CONFIGS.complete_contexts.return_value = [
         'metric-service', 'identity-service', 'mongodb'
     ]
     utils.ceilometer_upgrade_helper(self.CONFIGS)
     mock_ceilometer_upgrade.assert_called_once_with(action=True)
 def test_ceilometer_upgrade_helper_queens(self, mock_config,
                                           mock_ceilometer_upgrade):
     self.get_os_codename_install_source.return_value = 'queens'
     self.CONFIGS = MagicMock()
     self.CONFIGS.complete_contexts.return_value = [
         'metric-service',
         'identity-credentials',
     ]
     utils.ceilometer_upgrade_helper(self.CONFIGS)
     mock_ceilometer_upgrade.assert_called_once_with(action=True)
 def test_ceilometer_upgrade_helper_raise(self, mock_config,
                                          mock_ceilometer_upgrade,
                                          mock_subprocess):
     self.get_os_codename_install_source.return_value = 'ocata'
     self.CONFIGS = MagicMock()
     self.CONFIGS.complete_contexts.return_value = [
         'metric-service', 'identity-service', 'mongodb'
     ]
     mock_ceilometer_upgrade.side_effect = utils.FailedAction("message")
     with self.assertRaises(utils.FailedAction):
         utils.ceilometer_upgrade_helper(self.CONFIGS)
     mock_ceilometer_upgrade.assert_called_once_with(action=True)
Beispiel #6
0
def ceilometer_upgrade(args):
    """Run ceilometer-upgrade

    @raises Exception if the ceilometer-upgrade fails.
    """
    try:
        ceilometer_upgrade_helper(register_configs())
        action_set({'outcome': 'success, ceilometer-upgrade completed.'})
    except FailedAction as e:
        if e.outcome:
            action_set({'outcome': e.outcome})
        if e.trace:
            action_set({'traceback': e.trace})
        raise Exception(str(e.message))
Beispiel #7
0
def ceilometer_upgrade(args):
    """Run ceilometer-upgrade

    @raises Exception if the ceilometer-upgrade fails.
    """
    try:
        ceilometer_upgrade_helper(register_configs())
        action_set({'outcome': 'success, ceilometer-upgrade completed.'})
    except FailedAction as e:
        if e.outcome:
            action_set({'outcome': e.outcome})
        if e.trace:
            action_set({'traceback': e.trace})
        raise Exception(str(e))
    assess_status(register_configs())
Beispiel #8
0
 def test_ceilometer_upgrade_helper_raise(self, mock_config,
                                          mock_ceilometer_upgrade):
     self.get_os_codename_install_source.return_value = 'ocata'
     self.CONFIGS = MagicMock()
     self.CONFIGS.complete_contexts.return_value = [
         'metric-service', 'identity-service', 'mongodb'
     ]
     # workaround Py3 constraint that raise only accepts an actual
     # exception, so we have to patch CalledProcessError back onto the
     # mocked out subprocess module
     import subprocess
     exc = subprocess.CalledProcessError
     mock_ceilometer_upgrade.side_effect = utils.FailedAction("message")
     with patch.object(utils, 'subprocess') as subp, \
             self.assertRaises(utils.FailedAction):
         subp.CalledProcessError = exc
         utils.ceilometer_upgrade_helper(self.CONFIGS)
     mock_ceilometer_upgrade.assert_called_once_with(action=True)
 def test_ceilometer_upgrade_helper_raise(self, mock_config,
                                          mock_ceilometer_upgrade):
     self.get_os_codename_install_source.return_value = 'ocata'
     self.CONFIGS = MagicMock()
     self.CONFIGS.complete_contexts.return_value = [
         'metric-service',
         'identity-service',
         'mongodb'
     ]
     # workaround Py3 constraint that raise only accepts an actual
     # exception, so we have to patch CalledProcessError back onto the
     # mocked out subprocess module
     import subprocess
     exc = subprocess.CalledProcessError
     mock_ceilometer_upgrade.side_effect = utils.FailedAction("message")
     with patch.object(utils, 'subprocess') as subp, \
             self.assertRaises(utils.FailedAction):
         subp.CalledProcessError = exc
         utils.ceilometer_upgrade_helper(self.CONFIGS)
     mock_ceilometer_upgrade.assert_called_once_with(action=True)