Exemple #1
0
 def test_cancel_workers_when_no_resource_found(self, mock_get_locked,
                                                mock_ccr, mock_wccr,
                                                mock_wc):
     mock_tgm = mock.Mock()
     _worker = worker.WorkerService('host-1', 'topic-1', 'engine-001',
                                    mock_tgm)
     stack = mock.MagicMock()
     stack.id = 'stack_id'
     mock_get_locked.return_value = []
     worker._cancel_workers(stack, mock_tgm, 'engine-001',
                            _worker._rpc_client)
     self.assertFalse(mock_wccr.called)
     self.assertFalse(mock_ccr.called)
Exemple #2
0
 def test_cancel_workers_when_no_resource_found(self, mock_get_locked,
                                                mock_ccr, mock_wccr,
                                                mock_wc):
     mock_tgm = mock.Mock()
     _worker = worker.WorkerService('host-1', 'topic-1', 'engine-001',
                                    mock_tgm)
     stack = mock.MagicMock()
     stack.id = 'stack_id'
     mock_get_locked.return_value = []
     worker._cancel_workers(stack, mock_tgm, 'engine-001',
                            _worker._rpc_client)
     self.assertFalse(mock_wccr.called)
     self.assertFalse(mock_ccr.called)
Exemple #3
0
 def test_cancel_workers_with_resources_found(self, mock_get_locked,
                                              mock_ccr, mock_wccr,
                                              mock_wc):
     mock_tgm = mock.Mock()
     _worker = worker.WorkerService('host-1', 'topic-1', 'engine-001',
                                    mock_tgm)
     stack = mock.MagicMock()
     stack.id = 'stack_id'
     mock_get_locked.return_value = ['engine-001', 'engine-007',
                                     'engine-008']
     worker._cancel_workers(stack, mock_tgm, 'engine-001',
                            _worker._rpc_client)
     mock_wccr.assert_called_once_with(stack.id, 'engine-001', mock_tgm)
     self.assertEqual(2, mock_ccr.call_count)
     calls = [mock.call(stack.context, stack.id, 'engine-007'),
              mock.call(stack.context, stack.id, 'engine-008')]
     mock_ccr.assert_has_calls(calls, any_order=True)
     self.assertTrue(mock_wc.called)
Exemple #4
0
 def test_cancel_workers_with_resources_found(self, mock_get_locked,
                                              mock_ccr, mock_wccr,
                                              mock_wc):
     mock_tgm = mock.Mock()
     _worker = worker.WorkerService('host-1', 'topic-1', 'engine-001',
                                    mock_tgm)
     stack = mock.MagicMock()
     stack.id = 'stack_id'
     mock_get_locked.return_value = ['engine-001', 'engine-007',
                                     'engine-008']
     worker._cancel_workers(stack, mock_tgm, 'engine-001',
                            _worker._rpc_client)
     mock_wccr.assert_called_once_with(stack.id, 'engine-001', mock_tgm)
     self.assertEqual(2, mock_ccr.call_count)
     calls = [mock.call(stack.context, stack.id, 'engine-007'),
              mock.call(stack.context, stack.id, 'engine-008')]
     mock_ccr.assert_has_calls(calls, any_order=True)
     self.assertTrue(mock_wc.called)