def test_multi_process_error_stop(self): py_info = sys.version_info major_ver = py_info[0] minor_ver = py_info[1] py_ver = int(str(major_ver) + str(minor_ver)) log = LisboaLog.get_logger(self.__class__.__name__) log.info(minor_ver) if py_ver >= self.MULTI_PROC_SUPPORT_VER: step1 = SampleStep() Helper.set_property(step1, "logger", LisboaLog.get_logger(step1.__class__.__name__)) step2 = ErrorSampleStep() Helper.set_property(step2, "logger", LisboaLog.get_logger(step2.__class__.__name__)) q = StepQueue() q.force_continue = False setattr(ScenarioQueue, "step_queue", q) executor = MultiProcExecutor([step1, step2]) try: executor.execute_steps(None) self.fail("Error must be occured") except StepExecutionFailed: pass
def __invoke_steps(self, yaml_scenario_list): """ Create executable instance and push them to queue Args: yaml_scenario_list: parsed yaml list """ self._logger.info("Start to invoke scenario") # Create queue to save step instances q = StepQueue() for s_dict in yaml_scenario_list: if "multi_process_count" in s_dict.keys(): q.multi_proc_cnt = s_dict.get("multi_process_count") continue instances = [] if "parallel" in s_dict.keys(): for row in s_dict.get("parallel"): instance = self.__create_instance(row, yaml_scenario_list) Helper.set_property( instance, "logger", LisboaLog.get_logger(instance.__class__.__name__), ) instances.append(instance) StepArgument._put(row["step"], instance) else: instance = self.__create_instance(s_dict, yaml_scenario_list) Helper.set_property( instance, "logger", LisboaLog.get_logger(instance.__class__.__name__), ) instances.append(instance) StepArgument._put(s_dict["step"], instance) # Put instance to queue q.push(instances) # save queue to static area setattr(ScenarioQueue, "step_queue", q) self._logger.info("Finish to invoke scenario")
def test_multi_process_error_continue(self): py_info = sys.version_info major_ver = py_info[0] minor_ver = py_info[1] py_ver = int(str(major_ver) + str(minor_ver)) if py_ver >= self.MULTI_PROC_SUPPORT_VER: step1 = SampleStep() Helper.set_property(step1, "logger", LisboaLog.get_logger(step1.__class__.__name__)) step2 = ErrorSampleStep() Helper.set_property(step2, "logger", LisboaLog.get_logger(step2.__class__.__name__)) q = StepQueue() q.force_continue = True setattr(ScenarioQueue, "step_queue", q) executor = MultiProcExecutor([step1, step2]) executor.execute_steps(None)
class ScenarioQueue(object): """ Composition of extract, transform, load queus """ step_queue = StepQueue() class __metaclass__(type): @property def step_queue(cls): return cls.step_queue @step_queue.setter def step_queue(cls, q): cls.step_queue = q
class TestScenairoQueue(object): def setup_method(self): self._scenario_queue = StepQueue() def test_push_and_pop(self): instance = "spam" self._scenario_queue.push(instance) ret = self._scenario_queue.pop() ret == "spam" def test_size(self): instance = "spam" self._scenario_queue.push(instance) size = self._scenario_queue.size() # remove test data in queue self._scenario_queue.pop() assert size == 1 def test_is_empty(self): is_empty = self._scenario_queue.is_empty() assert is_empty is True
def test_step_queue(self): setattr(ScenarioQueue, "step_queue", StepQueue()) assert isinstance(ScenarioQueue.step_queue, StepQueue)
def setup_method(self): self._scenario_queue = StepQueue()
class TestStepQueue(object): _DUMMY_PARALLEL_CNT = 9 def setup_method(self): self._scenario_queue = StepQueue() def test_multi_proc_cnt(self): self._scenario_queue.multi_proc_cnt = self._DUMMY_PARALLEL_CNT assert self._scenario_queue.multi_proc_cnt == self._DUMMY_PARALLEL_CNT def test_push_and_pop(self): instance = "spam" self._scenario_queue.push(instance) ret = self._scenario_queue.pop() ret == "spam" def test_peek(self): instance = "spam" self._scenario_queue.push(instance) assert self._scenario_queue.peek() == "spam" def test_size(self): instance = "spam" self._scenario_queue.push(instance) size = self._scenario_queue.size() # remove test data in queue self._scenario_queue.pop() assert size == 1 def test_is_empty(self): is_empty = self._scenario_queue.is_empty() assert is_empty is True