Beispiel #1
0
    def test_power_on(self, mock_pwron):
        pwron = tf_vm.PowerOn(self.apt, self.instance, pwr_opts='opt')
        pwron.execute()
        mock_pwron.assert_called_once_with(self.apt, self.instance, opts='opt')

        # Validate args on taskflow.task.Task instantiation
        with mock.patch('taskflow.task.Task.__init__') as tf:
            tf_vm.PowerOn(self.apt, self.instance)
        tf.assert_called_once_with(name='pwr_vm')
Beispiel #2
0
    def test_power_on_revert(self, mock_pwroff, mock_pwron):
        flow = tf_lf.Flow('revert_power_on')
        pwron = tf_vm.PowerOn(self.apt, self.instance, pwr_opts='opt')
        flow.add(pwron)

        # Dummy Task that fails, triggering flow revert
        def failure(*a, **k):
            raise ValueError()

        flow.add(tf_tsk.FunctorTask(failure))

        # When PowerOn.execute doesn't fail, revert calls power_off
        self.assertRaises(ValueError, tf_eng.run, flow)
        mock_pwron.assert_called_once_with(self.apt, self.instance, opts='opt')
        mock_pwroff.assert_called_once_with(self.apt,
                                            self.instance,
                                            force_immediate=True)

        mock_pwron.reset_mock()
        mock_pwroff.reset_mock()

        # When PowerOn.execute fails, revert doesn't call power_off
        mock_pwron.side_effect = exception.NovaException()
        self.assertRaises(exception.NovaException, tf_eng.run, flow)
        mock_pwron.assert_called_once_with(self.apt, self.instance, opts='opt')
        self.assertEqual(0, mock_pwroff.call_count)
Beispiel #3
0
 def test_power_on(self, mock_pwron):
     pwron = tf_vm.PowerOn(self.apt, self.instance, pwr_opts='opt')
     pwron.execute()
     mock_pwron.assert_called_once_with(self.apt, self.instance, opts='opt')