Ejemplo n.º 1
0
 def test_bash_task(self):
     with af.job_config('task_1'):
         af.user_define_operation(processor=bash.BashProcessor(
             bash_command='echo "Xiao ming hello world!"'))
     w = af.workflow_operation.submit_workflow(workflow_name='test_bash')
     je = af.workflow_operation.start_job_execution(job_name='task_1',
                                                    execution_id='1')
     je = af.workflow_operation.get_job_execution(job_name='task_1',
                                                  execution_id='1')
     self.assertEqual(Status.FINISHED, je.status)
Ejemplo n.º 2
0
 def run_workflow(client: NotificationClient):
     with af.job_config('task_1'):
         af.user_define_operation(processor=bash.BashProcessor(bash_command='echo "Xiao ming hello world!"'))
     with af.job_config('task_2'):
         af.user_define_operation(processor=bash.BashProcessor(bash_command='echo "Xiao li hello world!"'))
     af.action_on_job_status('task_2', 'task_1', Status.FINISHED, JobAction.START)
     workflow_info = af.workflow_operation.submit_workflow(
         workflow_name=af.current_workflow_config().workflow_name)
     workflow_execution = af.workflow_operation.start_new_workflow_execution(
         workflow_name=af.current_workflow_config().workflow_name)
     while True:
         with create_session() as session:
             ti = session.query(TaskInstance)\
                 .filter(TaskInstance.dag_id ==
                         'test_project.{}'.format(af.current_workflow_config().workflow_name),
                         TaskInstance.task_id == 'task_2')\
                 .first()
             if ti is not None and ti.state == State.SUCCESS:
                 break
             else:
                 time.sleep(1)
Ejemplo n.º 3
0
 def test_stop_bash_task(self):
     time.sleep(1)
     with af.job_config('task_1'):
         af.user_define_operation(processor=bash.BashProcessor(
             bash_command='sleep 10'))
     w = af.workflow_operation.submit_workflow(workflow_name='test_bash')
     je = af.workflow_operation.start_job_execution(job_name='task_1',
                                                    execution_id='1')
     af.workflow_operation.stop_job_execution(job_name='task_1',
                                              execution_id='1')
     je = af.workflow_operation.get_job_execution(job_name='task_1',
                                                  execution_id='1')
     self.assertEqual(Status.FAILED, je.status)
     self.assertTrue('err' in je.properties)
Ejemplo n.º 4
0
 def run_workflow(client: NotificationClient):
     with af.job_config('task_1'):
         af.user_define_operation(processor=bash.BashProcessor(bash_command='echo "Xiao ming hello world!"'))
     workflow_info = af.workflow_operation.submit_workflow(
         workflow_name=af.current_workflow_config().workflow_name)
     wei = af.workflow_operation.start_new_workflow_execution(
         workflow_name=af.current_workflow_config().workflow_name)
     set_workflow_execution_info(wei)
     while True:
         with create_session() as session:
             dag_run = session.query(DagRun)\
                 .filter(DagRun.dag_id == 'test_project.{}'
                         .format(af.current_workflow_config().workflow_name)).first()
             if dag_run is not None and dag_run.state == State.SUCCESS:
                 break
             else:
                 time.sleep(1)
        def run_workflow(client: NotificationClient):
            with af.job_config(task_name):
                af.user_define_operation(processor=bash.BashProcessor(bash_command='echo "Xiao ming hello world!"'))

            workflow_info = af.workflow_operation.submit_workflow(
                workflow_name=af.current_workflow_config().workflow_name)
            workflow_execution = af.workflow_operation.start_new_workflow_execution(
                workflow_name=af.current_workflow_config().workflow_name)
            while True:
                with create_session() as session:
                    tes = session.query(TaskExecution)\
                        .filter(TaskExecution.dag_id == 'test_project.{}'
                                .format(af.current_workflow_config().workflow_name),
                                TaskExecution.task_id == task_name).all()
                    if len(tes) == 2:
                        break
                    else:
                        time.sleep(1)