示例#1
0
 def test_cancel(self, CustomServiceOrchestrator_mock,
                      get_mock, process_command_mock, gpeo_mock):
   CustomServiceOrchestrator_mock.return_value = None
   
   initializer_module = InitializerModule()
   initializer_module.init()
   
   dummy_controller = MagicMock(initializer_module)
   config = MagicMock()
   gpeo_mock.return_value = 0
   config.get_parallel_exec_option = gpeo_mock
   
   initializer_module = InitializerModule()
   initializer_module.init()
   
   actionQueue = ActionQueue(initializer_module)
   actionQueue.start()
   actionQueue.put([self.datanode_install_command, self.hbase_install_command])
   self.assertEqual(2, actionQueue.commandQueue.qsize())
   actionQueue.reset()
   self.assertTrue(actionQueue.commandQueue.empty())
   time.sleep(0.1)
   initializer_module.stop_event.set()
   actionQueue.join()
   self.assertEqual(actionQueue.is_alive(), False, 'Action queue is not stopped.')
示例#2
0
 def test_parallel_exec_no_retry(self, CustomServiceOrchestrator_mock,
                        process_command_mock, gpeo_mock, threading_mock):
   CustomServiceOrchestrator_mock.return_value = None
   
   initializer_module = InitializerModule()
   initializer_module.init()
   
   dummy_controller = MagicMock(initializer_module)
   config = MagicMock()
   gpeo_mock.return_value = 1
   config.get_parallel_exec_option = gpeo_mock
   
   initializer_module = InitializerModule()
   initializer_module.init()
   
   actionQueue = ActionQueue(initializer_module)
   actionQueue.put([self.datanode_install_no_retry_command, self.snamenode_install_command])
   self.assertEqual(2, actionQueue.commandQueue.qsize())
   actionQueue.start()
   time.sleep(1)
   initializer_module.stop_event.set()
   actionQueue.join()
   self.assertEqual(actionQueue.is_alive(), False, 'Action queue is not stopped.')
   self.assertEqual(2, process_command_mock.call_count)
   self.assertEqual(0, threading_mock.call_count)
   process_command_mock.assert_any_calls([call(self.datanode_install_command), call(self.hbase_install_command)])
 def test_ActionQueueStartStop(self, CustomServiceOrchestrator_mock,
                               get_mock, process_command_mock, get_parallel_exec_option_mock):
   CustomServiceOrchestrator_mock.return_value = None
   dummy_controller = MagicMock()
   config = MagicMock()
   get_parallel_exec_option_mock.return_value = 0
   config.get_parallel_exec_option = get_parallel_exec_option_mock
   actionQueue = ActionQueue(config, dummy_controller)
   actionQueue.start()
   time.sleep(0.1)
   actionQueue.stop()
   actionQueue.join()
   self.assertEqual(actionQueue.stopped(), True, 'Action queue is not stopped.')
   self.assertTrue(process_command_mock.call_count > 1)
示例#4
0
 def test_ActionQueueStartStop(self, CustomServiceOrchestrator_mock,
                               get_mock, process_command_mock, get_parallel_exec_option_mock):
   CustomServiceOrchestrator_mock.return_value = None
   dummy_controller = MagicMock()
   config = MagicMock()
   get_parallel_exec_option_mock.return_value = 0
   config.get_parallel_exec_option = get_parallel_exec_option_mock
   actionQueue = ActionQueue(config, dummy_controller)
   actionQueue.start()
   time.sleep(0.1)
   actionQueue.stop()
   actionQueue.join()
   self.assertEqual(actionQueue.stopped(), True, 'Action queue is not stopped.')
   self.assertTrue(process_command_mock.call_count > 1)
 def test_parallel_exec(self, CustomServiceOrchestrator_mock,
                        process_command_mock, gpeo_mock):
   CustomServiceOrchestrator_mock.return_value = None
   dummy_controller = MagicMock()
   config = MagicMock()
   gpeo_mock.return_value = 1
   config.get_parallel_exec_option = gpeo_mock
   actionQueue = ActionQueue(config, dummy_controller)
   actionQueue.put([self.datanode_install_command, self.hbase_install_command])
   self.assertEqual(2, actionQueue.commandQueue.qsize())
   actionQueue.start()
   time.sleep(1)
   actionQueue.stop()
   actionQueue.join()
   self.assertEqual(actionQueue.stopped(), True, 'Action queue is not stopped.')
   self.assertEqual(2, process_command_mock.call_count)
   process_command_mock.assert_any_calls([call(self.datanode_install_command), call(self.hbase_install_command)])
示例#6
0
 def test_parallel_exec(self, CustomServiceOrchestrator_mock,
                        process_command_mock, gpeo_mock):
   CustomServiceOrchestrator_mock.return_value = None
   dummy_controller = MagicMock()
   config = MagicMock()
   gpeo_mock.return_value = 1
   config.get_parallel_exec_option = gpeo_mock
   actionQueue = ActionQueue(config, dummy_controller)
   actionQueue.put([self.datanode_install_command, self.hbase_install_command])
   self.assertEqual(2, actionQueue.commandQueue.qsize())
   actionQueue.start()
   time.sleep(1)
   actionQueue.stop()
   actionQueue.join()
   self.assertEqual(actionQueue.stopped(), True, 'Action queue is not stopped.')
   self.assertEqual(2, process_command_mock.call_count)
   process_command_mock.assert_any_calls([call(self.datanode_install_command), call(self.hbase_install_command)])
示例#7
0
 def test_ActionQueueStartStop(self, CustomServiceOrchestrator_mock,
                               get_mock, process_command_mock, get_parallel_exec_option_mock):
   CustomServiceOrchestrator_mock.return_value = None
   dummy_controller = MagicMock()
   config = MagicMock()
   get_parallel_exec_option_mock.return_value = 0
   config.get_parallel_exec_option = get_parallel_exec_option_mock
   
   initializer_module = InitializerModule()
   initializer_module.init()
   
   actionQueue = ActionQueue(initializer_module)
   actionQueue.start()
   time.sleep(0.1)
   initializer_module.stop_event.set()
   actionQueue.join()
   self.assertEqual(actionQueue.is_alive(), False, 'Action queue is not stopped.')
   self.assertTrue(process_command_mock.call_count > 1)
 def test_reset_queue(self, CustomServiceOrchestrator_mock,
                               get_mock, process_command_mock, gpeo_mock):
   CustomServiceOrchestrator_mock.return_value = None
   dummy_controller = MagicMock()
   dummy_controller.recovery_manager = RecoveryManager(tempfile.mktemp())
   config = MagicMock()
   gpeo_mock.return_value = 0
   config.get_parallel_exec_option = gpeo_mock
   actionQueue = ActionQueue(config, dummy_controller)
   actionQueue.start()
   actionQueue.put([self.datanode_install_command, self.hbase_install_command])
   self.assertEqual(2, actionQueue.commandQueue.qsize())
   self.assertTrue(actionQueue.tasks_in_progress_or_pending())
   actionQueue.reset()
   self.assertTrue(actionQueue.commandQueue.empty())
   self.assertFalse(actionQueue.tasks_in_progress_or_pending())
   time.sleep(0.1)
   actionQueue.stop()
   actionQueue.join()
   self.assertEqual(actionQueue.stopped(), True, 'Action queue is not stopped.')
示例#9
0
 def test_reset_queue(self, CustomServiceOrchestrator_mock,
                               get_mock, process_command_mock, gpeo_mock):
   CustomServiceOrchestrator_mock.return_value = None
   dummy_controller = MagicMock()
   dummy_controller.recovery_manager = RecoveryManager(tempfile.mktemp())
   config = MagicMock()
   gpeo_mock.return_value = 0
   config.get_parallel_exec_option = gpeo_mock
   actionQueue = ActionQueue(config, dummy_controller)
   actionQueue.start()
   actionQueue.put([self.datanode_install_command, self.hbase_install_command])
   self.assertEqual(2, actionQueue.commandQueue.qsize())
   self.assertTrue(actionQueue.tasks_in_progress_or_pending())
   actionQueue.reset()
   self.assertTrue(actionQueue.commandQueue.empty())
   self.assertFalse(actionQueue.tasks_in_progress_or_pending())
   time.sleep(0.1)
   actionQueue.stop()
   actionQueue.join()
   self.assertEqual(actionQueue.stopped(), True, 'Action queue is not stopped.')