Ejemplo n.º 1
0
    def test_loop_execution_no_wait(self):
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/loop.bpmn")

        process_executor = ProcessExecutor(adhesive.process, wait_tasks=False)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "Build Germanium Image on mac": 1,
                "Build Germanium Image on windows": 1,
                "Build Germanium Image on linux": 1,
                "Test Browser ie on linux": 1,
                "Cleanup Platform linux": 3,
                "Cleanup Platform windows": 3,
                "Cleanup Platform mac": 3,
                "Test Browser chrome on linux": 1,
                "Test Browser edge on linux": 1,
                "Test Browser edge on windows": 1,
                "Test Browser chrome on windows": 1,
                "Test Browser ie on windows": 1,
                "Test Browser chrome on mac": 1,
                "Test Browser edge on mac": 1,
                "Test Browser ie on mac": 1,
            },
            data.executions,
        )

        self.assertFalse(process_executor.events)
Ejemplo n.º 2
0
    def test_link_back_execution(self):
        adhesive.process.process = read_bpmn_file("test/adhesive/xml/link-back.bpmn")

        process_executor = ProcessExecutor(adhesive.process)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "Increment X by 1": 5,
                "Build Germanium Image": 1,
            },
            data.executions,
        )
        self.assertFalse(process_executor.events)
Ejemplo n.º 3
0
    def test_link_back_execution(self):
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/user-task-join.bpmn"
        )

        process_executor = ProcessExecutor(
            adhesive.process, ut_provider=TestUserTaskProvider()
        )
        data = process_executor.execute()

        self.assertEqual("OK", data.OK)
        self.assertEqual("Cancel", data.Cancel)
        self.assertEqual("branch", data.branch)
        self.assertEqual("12.0", data.version)

        self.assertFalse(process_executor.events)
Ejemplo n.º 4
0
    def test_basic_execution(self):
        """
        Load a simple process and execute it.
        """
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/adhesive-basic.bpmn")

        process_executor = ProcessExecutor(adhesive.process)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "Build Germanium Image": 1,
            },
            data.executions,
        )
        self.assertFalse(process_executor.events)
Ejemplo n.º 5
0
    def test_parallel_gateway_non_wait(self):
        """
        Load a process with a gateway and test it..
        """
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/gateway-parallel.bpmn")

        process_executor = ProcessExecutor(adhesive.process)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "Test Chrome": 3,
                "Build Germanium Image": 3,
            },
            data.executions,
        )
        self.assertFalse(process_executor.events)
    def test_error_propagates_up(self):
        """
        Load a process with a gateway and test it..
        """
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/error-event-subprocess-propagates-up.bpmn")

        process_executor = ProcessExecutor(adhesive.process)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "Error Was Caught": 1,
            },
            data.executions,
        )

        self.assertFalse(process_executor.events)
Ejemplo n.º 7
0
    def test_log_redirection(self):
        """
        Load a process with a gateway and test it..
        """
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/redirect-logs.bpmn")

        process_executor = ProcessExecutor(adhesive.process)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "sh: echo hello world && echo bad world >&2 && echo good world":
                1,
                "Store current execution id": 1,
            },
            data.executions,
        )
        self.assertFalse(process_executor.events)

        adhesive_temp_folder = config.current.temp_folder
        path_to_glob = os.path.join(adhesive_temp_folder, data.execution_id,
                                    "logs", "_4", "*", "stdout")

        log_path = glob.glob(path_to_glob)

        if not log_path:
            raise Exception(
                f"Unable to match any file for glob {path_to_glob}")

        with open(log_path[0], "rt") as f:
            self.assertEqual(
                f.read(),
                "sh: echo hello world && "
                "echo bad world >&2 && "
                "echo good world\nhello world\ngood world\n",
            )

        log_path = glob.glob(
            os.path.join(adhesive_temp_folder, data.execution_id, "logs", "_4",
                         "*", "stderr"))

        with open(log_path[0], "rt") as f:
            self.assertEqual(f.read(), "bad world\n")
Ejemplo n.º 8
0
    def test_script_task_execution(self):
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/script.bpmn")

        process_executor = ProcessExecutor(adhesive.process)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "Script Task": 1,
                "Build Germanium Image": 1,
            },
            data.executions,
        )

        self.assertFalse(
            process_executor.events,
            "Some events were not unregistered and/or executed.",
        )
    def test_exclusive_gateway_non_wait(self):
        """
        Load a process with a gateway and test it..
        """
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/gateway-exclusive-sign.bpmn")

        process_executor = ProcessExecutor(adhesive.process, wait_tasks=False)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "Test Chrome": 1,
                "Test Firefox": 1,
                "Build Germanium Image": 2,
            },
            data.executions,
        )
        self.assertFalse(process_executor.events)
Ejemplo n.º 10
0
    def test_inclusive_gateway(self):
        """
        Load a process with a gateway and test it..
        """
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/gateway-inclusive.bpmn")

        process_executor = ProcessExecutor(adhesive.process)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "Test Chrome": 1,
                "Test Firefox": 1,
                "Build Germanium Image": 1,
                "Cleanup Broken Tasks": 1,
            },
            data.executions,
        )
        self.assertFalse(process_executor.events)
Ejemplo n.º 11
0
    def test_exclusive_gateway_non_wait(self):
        """
        Load a process with a gateway and test it..
        """
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/gateway-complex.bpmn")

        process_executor = ProcessExecutor(adhesive.process, wait_tasks=False)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "Test Firefox": 1,
                "Test Chrome": 1,
                "Test Browser chrome on linux": 2,
                "Test Browser firefox on linux": 2,
            },
            data.executions,
        )
        self.assertFalse(process_executor.events)
    def test_simple_execution_non_wait(self):
        """
        Load a simple process and execute it.
        """
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/adhesive.bpmn")

        process_executor = ProcessExecutor(adhesive.process, wait_tasks=False)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "Ensure Docker Tooling": 1,
                "Build Germanium Image": 1,
                "Test Chrome": 1,
                "Test Firefox": 1,
            },
            data.executions,
        )
        self.assertFalse(process_executor.events)
Ejemplo n.º 13
0
    def test_error_interrupting(self):
        """
        Load a process with a gateway and test it..
        """
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/error-event-interrupting.bpmn"
        )

        process_executor = ProcessExecutor(adhesive.process)
        data = process_executor.execute()

        print(data._error)

        assert_equal_execution(
            {
                "Cleanup Broken Tasks": 1,
            },
            data.executions,
        )
        self.assertFalse(process_executor.events)
Ejemplo n.º 14
0
    def test_sub_process_execution(self):
        """
        Load a process that contains a sub process and execute it.
        """
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/adhesive_subprocess.bpmn")

        process_executor = ProcessExecutor(adhesive.process)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "Ensure Docker Tooling": 1,
                "Build Germanium Image": 1,
                "Prepare Firefox": 1,
                "Test Firefox": 1,
                "Test Chrome": 1,
            },
            data.executions,
        )
        self.assertFalse(process_executor.events)
Ejemplo n.º 15
0
    def test_lane_non_wait(self):
        """
        Load a process with a gateway and test it..
        """
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/lane.bpmn")

        process_executor = ProcessExecutor(adhesive.process, wait_tasks=False)
        data = process_executor.execute()

        assert_equal_execution(
            {
                "Prepare Firefox": 1,
                "Test Chrome": 1,
                "Test Firefox": 2,
                "Ensure Docker Tooling": 1,
                "Build Germanium Image": 4,
            },
            data.executions,
        )
        self.assertFalse(process_executor.events)
Ejemplo n.º 16
0
def _build(
    ut_provider: Optional["UserTaskProvider"] = None,
    wait_tasks: bool = True,
    initial_data=None,
):

    configure_logging(config.current)

    if ut_provider is None:
        ut_provider = ConsoleUserTaskProvider()

    return ProcessExecutor(
        process, ut_provider=ut_provider,
        wait_tasks=wait_tasks).execute(initial_data=initial_data)
Ejemplo n.º 17
0
    def test_parallel_sub_processes_tasks_non_wait(self):
        """
        Load a bunch of tasks in parallel.
        :return:
        """
        ProcessExecutor.pool = pebble.pool.ProcessPool(max_workers=6)
        adhesive.process.process = read_bpmn_file(
            "test/adhesive/xml/parallel5-sub-processes.bpmn")

        start_time = time.time() * 1000.0
        ProcessExecutor(adhesive.process, wait_tasks=False).execute()
        end_time = time.time() * 1000.0

        # the whole thing should be faster than 2 secs
        total_time = end_time - start_time
        self.assertTrue(
            total_time < 2000,
            f"Total time ({total_time}) should be less than 2000ms.")
        self.assertTrue(
            total_time >= 1000,
            f"Total time ({total_time}) should be more than 1000ms.")