def test_stepExecutionEvents(self):
        workflow_name = construct_workflow_name_key('basicWorkflowTest', 'helloWorldWorkflow')
        c = controller.Controller(name="testStepExecutionEventsController")
        c.load_workflows_from_file(path=config.test_workflows_path + "basicWorkflowTest.workflow")

        subs = {'testStepExecutionEventsController':
            Subscription(subscriptions=
            {workflow_name:
                Subscription(subscriptions=
                {'start':
                    Subscription(
                        events=["Function Execution Success", "Input Validated",
                                "Conditionals Executed"])})})}

        case_subscription.set_subscriptions(
            {'testStepExecutionEvents': case_subscription.CaseSubscriptions(subscriptions=subs)})

        c.execute_workflow('basicWorkflowTest', 'helloWorldWorkflow')

        running_context.shutdown_threads()

        step_execution_events_case = case_database.case_db.session.query(case_database.Case) \
            .filter(case_database.Case.name == 'testStepExecutionEvents').first()
        step_execution_event_history = step_execution_events_case.events.all()
        self.assertEqual(len(step_execution_event_history), 3,
                         'Incorrect length of event history. '
                         'Expected {0}, got {1}'.format(3, len(step_execution_event_history)))
    def test_workflowExecutionEvents(self):
        c = controller.Controller(name="testExecutionEventsController")
        c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                "multiactionWorkflowTest.workflow")

        subs = {
            'testExecutionEventsController':
            Subscription(
                subscriptions={
                    'multiactionWorkflow':
                    Subscription(events=[
                        "InstanceCreated", "StepExecutionSuccess",
                        "NextStepFound", "WorkflowShutdown"
                    ])
                })
        }

        case_subscription.set_subscriptions({
            'testExecutionEvents':
            case_subscription.CaseSubscriptions(subscriptions=subs)
        })

        c.executeWorkflow(name="multiactionWorkflow")

        execution_events_case = case_database.case_db.session.query(case_database.Cases) \
            .filter(case_database.Cases.name == 'testExecutionEvents').first()
        execution_event_history = execution_events_case.events.all()
        self.assertEqual(
            len(execution_event_history), 6,
            'Incorrect length of event history. '
            'Expected {0}, got {1}'.format(6, len(execution_event_history)))
    def test_workflowExecutionEvents(self):
        workflow_name = construct_workflow_name_key('multiactionWorkflowTest',
                                                    'multiactionWorkflow')
        c = Controller(name="testExecutionEventsController")
        c.load_workflows_from_file(path=config.test_workflows_path +
                                   "multiactionWorkflowTest.playbook")

        subs = {
            'testExecutionEventsController':
            Subscription(
                subscriptions={
                    workflow_name:
                    Subscription(events=[
                        "App Instance Created", "Step Execution Success",
                        "Next Step Found", "Workflow Shutdown"
                    ])
                })
        }

        case_subscription.set_subscriptions({
            'testExecutionEvents':
            case_subscription.CaseSubscriptions(subscriptions=subs)
        })

        c.execute_workflow('multiactionWorkflowTest', 'multiactionWorkflow')

        shutdown_pool()

        execution_events_case = case_database.case_db.session.query(case_database.Case) \
            .filter(case_database.Case.name == 'testExecutionEvents').first()
        execution_event_history = execution_events_case.events.all()
        self.assertEqual(
            len(execution_event_history), 6,
            'Incorrect length of event history. '
            'Expected {0}, got {1}'.format(6, len(execution_event_history)))
    def test_pauseResumeSchedulerExecution(self):
        c = controller.Controller(name="pauseResumeController")
        c.load_workflows_from_file(path=config.test_workflows_path + "testScheduler.workflow")

        subs = {'pauseResumeController': Subscription(events=[EVENT_SCHEDULER_START, EVENT_SCHEDULER_SHUTDOWN,
                                                              EVENT_SCHEDULER_PAUSED, EVENT_SCHEDULER_RESUMED,
                                                              EVENT_JOB_ADDED, EVENT_JOB_REMOVED,
                                                              EVENT_JOB_EXECUTED, EVENT_JOB_ERROR])}
        case_subscription.set_subscriptions({'startStop': case_subscription.CaseSubscriptions(subscriptions=subs)})
        case_subscription.set_subscriptions({'pauseResume': case_subscription.CaseSubscriptions(subscriptions=subs)})

        c.start()
        c.pause()
        time.sleep(1)
        c.resume()
        time.sleep(1)
        c.stop(wait=False)

        pause_resume_events_case = case_database.case_db.session.query(case_database.Case) \
            .filter(case_database.Case.name == 'pauseResume').first()
        pause_resume_event_history = pause_resume_events_case.events.all()

        self.assertEqual(len(pause_resume_event_history), 4,
                        'Incorrect length of event history. '
                        'Expected {0}, got {1}'.format(4, len(pause_resume_event_history)))
Exemple #5
0
    def test_ffkExecutionEvents(self):
        workflow_name = construct_workflow_name_key('basicWorkflowTest', 'helloWorldWorkflow')
        c = controller.Controller(name="testStepFFKEventsController")
        c.loadWorkflowsFromFile(path=config.testWorkflowsPath + "basicWorkflowTest.workflow")

        filter_sub = Subscription(events=['FilterSuccess', 'FilterError'])
        flag_sub = Subscription(events=['FlagArgsValid', 'FlagArgsInvalid'], subscriptions={'length': filter_sub})
        next_sub = Subscription(events=['NextStepTaken', 'NextStepNotTaken'], subscriptions={'regMatch': flag_sub})
        step_sub = Subscription(events=["FunctionExecutionSuccess", "InputValidated", "ConditionalsExecuted"],
                                subscriptions={'1': next_sub})
        subs = {'testStepFFKEventsController':
                    Subscription(subscriptions=
                                 {workflow_name:
                                      Subscription(subscriptions=
                                                   {'start': step_sub})})}

        case_subscription.set_subscriptions(
            {'testStepFFKEventsEvents': case_subscription.CaseSubscriptions(subscriptions=subs)})

        c.executeWorkflow('basicWorkflowTest', 'helloWorldWorkflow')

        step_ffk_events_case = case_database.case_db.session.query(case_database.Case) \
            .filter(case_database.Case.name == 'testStepFFKEventsEvents').first()
        step_ffk_event_history = step_ffk_events_case.events.all()
        self.assertEqual(len(step_ffk_event_history), 6,
                         'Incorrect length of event history. '
                         'Expected {0}, got {1}'.format(6, len(step_ffk_event_history)))
    def test_ffkExecutionEventsCase(self):
        c = Controller(name="testStepFFKEventsController")
        c.load_workflows_from_file(path=config.test_workflows_path +
                                   "basicWorkflowTest.playbook")
        workflow_name = construct_workflow_name_key('basicWorkflowTest',
                                                    'helloWorldWorkflow')
        filter_sub = Subscription(events=['Filter Error'])
        flag_sub = Subscription(events=['Flag Success', 'Flag Error'],
                                subscriptions={'length': filter_sub})
        next_sub = Subscription(
            events=['Next Step Taken', 'Next Step Not Taken'],
            subscriptions={'regMatch': flag_sub})
        step_sub = Subscription(events=[
            'Function Execution Success', 'Input Validated',
            'Conditionals Executed'
        ],
                                subscriptions={'1': next_sub})
        subs = {
            'testStepFFKEventsController':
            Subscription(
                subscriptions={
                    workflow_name: Subscription(
                        subscriptions={'start': step_sub})
                })
        }
        global_subs = case_subscription.GlobalSubscriptions(
            step=[
                'Function Execution Success', 'Input Validated',
                'Conditionals Executed'
            ],
            next_step=['Next Step Taken', 'Next Step Not Taken'],
            flag=['Flag Success', 'Flag Error'],
            filter=['Filter Error'])
        case_subscription.set_subscriptions({
            'testStepFFKEventsEvents':
            case_subscription.CaseSubscriptions(
                subscriptions=subs, global_subscriptions=global_subs)
        })

        c.execute_workflow('basicWorkflowTest', 'helloWorldWorkflow')

        shutdown_pool()

        step_ffk_events_case = case_database.case_db.session.query(case_database.Case) \
            .filter(case_database.Case.name == 'testStepFFKEventsEvents').first()
        step_ffk_event_history = step_ffk_events_case.events.all()
        self.assertEqual(
            len(step_ffk_event_history), 5,
            'Incorrect length of event history. '
            'Expected {0}, got {1}'.format(5, len(step_ffk_event_history)))
        step_json = [
            step.as_json() for step in step_ffk_event_history
            if step.as_json()['message'] == 'STEP'
        ]
        for step in step_json:
            if step['type'] == 'Function executed successfully':
                self.assertDictEqual(step['data'],
                                     {'result': 'REPEATING: Hello World'})
            else:
                self.assertEqual(step['data'], '')
    def test_stepExecutionEvents(self):
        c = controller.Controller(name="testStepExecutionEventsController")
        c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                "basicWorkflowTest.workflow")

        subs = {
            'testStepExecutionEventsController':
            Subscription(
                subscriptions={
                    'helloWorldWorkflow':
                    Subscription(
                        subscriptions={
                            'start':
                            Subscription(events=[
                                "FunctionExecutionSuccess", "InputValidated",
                                "ConditionalsExecuted"
                            ])
                        })
                })
        }

        case_subscription.set_subscriptions({
            'testStepExecutionEvents':
            case_subscription.CaseSubscriptions(subscriptions=subs)
        })

        c.executeWorkflow(name="helloWorldWorkflow")

        step_execution_events_case = case_database.case_db.session.query(case_database.Cases) \
            .filter(case_database.Cases.name == 'testStepExecutionEvents').first()
        step_execution_event_history = step_execution_events_case.events.all()
        self.assertEqual(
            len(step_execution_event_history), 3,
            'Incorrect length of event history. '
            'Expected {0}, got {1}'.format(3,
                                           len(step_execution_event_history)))
Exemple #8
0
    def test_startStopExecutionLoop(self):
        c = controller.Controller(name="startStopController")
        c.loadWorkflowsFromFile(path=config.testWorkflowsPath + "testScheduler.workflow")
        subs = {'startStopController': Subscription(events=[EVENT_SCHEDULER_START, EVENT_SCHEDULER_SHUTDOWN,
                                                            EVENT_SCHEDULER_PAUSED, EVENT_SCHEDULER_RESUMED,
                                                            EVENT_JOB_ADDED, EVENT_JOB_REMOVED,
                                                            EVENT_JOB_EXECUTED, EVENT_JOB_ERROR])}
        case_subscription.set_subscriptions({'startStop': case_subscription.CaseSubscriptions(subscriptions=subs)})
        c.start()
        time.sleep(1)
        c.stop(wait=False)

        start_stop_event_history = case_database.case_db.session.query(case_database.Cases) \
            .filter(case_database.Cases.name == 'startStop').first().events.all()
        self.assertEqual(len(start_stop_event_history), 2,
                         'Incorrect length of event history. '
                         'Expected {0}, got {1}'.format(2, len(start_stop_event_history)))
    def test_ffkExecutionEventsCase(self):
        c = controller.Controller(name="testStepFFKEventsController")
        c.loadWorkflowsFromFile(path=config.testWorkflowsPath +
                                "basicWorkflowTest.workflow")
        filter_sub = Subscription(disabled=['FilterSuccess'])
        flag_sub = Subscription(subscriptions={'length': filter_sub})
        next_sub = Subscription(subscriptions={'regMatch': flag_sub})
        step_sub = Subscription(subscriptions={'1': next_sub})
        subs = {
            'testStepFFKEventsController':
            Subscription(
                subscriptions={
                    'helloWorldWorkflow':
                    Subscription(subscriptions={'start': step_sub})
                })
        }
        global_subs = case_subscription.GlobalSubscriptions(
            step='*',
            next_step=['NextStepTaken', 'NextStepNotTaken'],
            flag=['FlagArgsValid', 'FlagArgsInvalid'],
            filter=['FilterSuccess', 'FilterError'])
        case_subscription.set_subscriptions({
            'testStepFFKEventsEvents':
            case_subscription.CaseSubscriptions(
                subscriptions=subs, global_subscriptions=global_subs)
        })

        c.executeWorkflow(name="helloWorldWorkflow")

        step_ffk_events_case = case_database.case_db.session.query(case_database.Cases) \
            .filter(case_database.Cases.name == 'testStepFFKEventsEvents').first()
        step_ffk_event_history = step_ffk_events_case.events.all()
        self.assertEqual(
            len(step_ffk_event_history), 5,
            'Incorrect length of event history. '
            'Expected {0}, got {1}'.format(5, len(step_ffk_event_history)))
Exemple #10
0
        database.db.session.commit()


# Temporary create controller
workflowManager = controller.Controller()
workflowManager.loadWorkflowsFromFile(
    path="tests/testWorkflows/basicWorkflowTest.workflow")
workflowManager.loadWorkflowsFromFile(
    path="tests/testWorkflows/multiactionWorkflowTest.workflow")

subs = {
    'defaultController':
    Subscription(
        subscriptions={
            'multiactionWorkflow':
            Subscription(events=[
                "InstanceCreated", "StepExecutionSuccess", "NextStepFound",
                "WorkflowShutdown"
            ])
        })
}
set_subscriptions(
    {'testExecutionEvents': CaseSubscriptions(subscriptions=subs)})
"""
    URLS
"""


@app.route("/")
@login_required
def default():
    if current_user.is_authenticated: