Exemple #1
0
 def testQueueExceptionsRaises(self):
     tr = TasksRunner(Mock(side_effect=EXCEPTION(EXCEPTION_MESSAGE)))
     ntasks = 3
     for _ in range(ntasks):
         tr.put_task()
     tr.run_tasks()
     self.failUnlessRaises(EXCEPTION, tr.wait_tasks_processed)
Exemple #2
0
    def _stop_instances(self, instances):
        tasksRunnner = TasksRunner(self._stop_instance,
                                   max_workers=self.max_iaas_workers,
                                   verbose=self.verboseLevel)
        for instance in instances:
            tasksRunnner.put_task(instance)

        tasksRunnner.run_tasks()
        tasksRunnner.wait_tasks_processed()
Exemple #3
0
    def __start_nodes_instances_and_clients(self, user_info, nodes_instances):
        self.__tasks_runnner = TasksRunner(
            self.__start_node_instance_and_client,
            max_workers=self.max_iaas_workers,
            verbose=self.verboseLevel)

        for node_instance in nodes_instances.values():
            self.__tasks_runnner.put_task(user_info, node_instance)

        self.__tasks_runnner.run_tasks()
Exemple #4
0
    def _stop_instances(self, instances):
        max_workers = self._get_max_workers(self.configHolder)
        tasksRunnner = TasksRunner(self._stop_instance,
                                   max_workers=max_workers,
                                   verbose=self.verboseLevel)
        for instance in instances:
            tasksRunnner.put_task(instance)

        tasksRunnner.run_tasks()
        tasksRunnner.wait_tasks_processed()
Exemple #5
0
 def testRunTaskNoExceptions(self):
     tr = TasksRunner(Mock())
     ntasks = 5
     for _ in range(ntasks):
         tr.put_task(None)
     tr.run_tasks()
     tr.wait_tasks_processed()
     assert 0 == tr.tasks_queue.qsize()
     assert tr._tasks_finished() is True
     assert len(tr.workers) == ntasks
Exemple #6
0
 def testMtasksNworkers(self):
     max_workers = 10
     tr = TasksRunner(Mock(), max_workers=10)
     ntasks = 25
     for _ in range(ntasks):
         tr.put_task(None)
     tr.run_tasks()
     tr.wait_tasks_processed()
     assert 0 == tr.tasks_queue.qsize()
     assert tr._tasks_finished() is True
     assert len(tr.workers) == max_workers
Exemple #7
0
 def testQueueExceptionsManualCheck(self):
     tr = TasksRunner(Mock(side_effect=EXCEPTION(EXCEPTION_MESSAGE)))
     ntasks = 3
     for _ in range(ntasks):
         tr.put_task(None)
     tr.run_tasks()
     while not tr._tasks_finished():
         time.sleep(1)
     assert tr._tasks_finished() is True
     assert len(tr.workers) == ntasks
     assert tr.exc_queue.qsize() == ntasks
     for _ in range(ntasks):
         _assert_exc_info(tr.exc_queue.get())
Exemple #8
0
    def set_tasks_and_run(self, nodes_instances, done_reporter):
        """
        :param nodes_instances: list of node instances
        :type nodes_instances: list [NodeInstance, ]
        :param done_reporter: function that reports back to SlipStream
        :type done_reporter: callable with signature `done_reporter(<NoneInstance>)`
        """
        self._tasks_runner = TasksRunner(self._task_executor,
                                         max_workers=self._max_workers,
                                         verbose=self._verbose_level)
        for node_instance in nodes_instances:
            self._tasks_runner.put_task(node_instance, done_reporter)

        self._tasks_runner.run_tasks()