xiaosi@yoona:~$ airflow list_tasks example_hello_world_dag[2017-08-0311:41:57,097] {__init__.py:57} INFO - Using executor SequentialExecutor[2017-08-0311:41:57,220] {driver.py:120} INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt[2017-08-0311:41:57,241] {driver.py:120} INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt[2017-08-0311:41:57,490] {models.py:167} INFO - Filling up the DagBag from /home/xiaosi/opt/airflow/dagsdate_taskhello_tasksleep_task
可以看到我们有三个Task:
date_taskhello_tasksleep_task
下面分别测试一下这几个Task:
(1) 测试date_task
xiaosi@yoona:~$ airflow test example_hello_world_dag date_task 20170803...--------------------------------------------------------------------------------Starting attempt 1 of 2--------------------------------------------------------------------------------[2017-08-03 11:44:02,248] {models.py:1342} INFO - Executing <Task(BashOperator): date_task> on 2017-08-03 00:00:00[2017-08-03 11:44:02,258] {bash_operator.py:71} INFO - tmp dir root location:/tmp[2017-08-03 11:44:02,259] {bash_operator.py:80} INFO - Temporary script location :/tmp/airflowtmpxh6da9//tmp/airflowtmpxh6da9/date_tasktQQB0V[2017-08-03 11:44:02,259] {bash_operator.py:81} INFO - Running command: date[2017-08-03 11:44:02,264] {bash_operator.py:90} INFO - Output:[2017-08-03 11:44:02,265] {bash_operator.py:94} INFO - 2017年 08月 03日 星期四 11:44:02 CST[2017-08-03 11:44:02,266] {bash_operator.py:97} INFO - Command exited with return code 0
(2) 测试hello_task
xiaosi@yoona:~$ airflow test example_hello_world_dag hello_task 20170803...--------------------------------------------------------------------------------Starting attempt 1 of 2--------------------------------------------------------------------------------[2017-08-03 11:45:29,546] {models.py:1342} INFO - Executing <Task(PythonOperator): hello_task> on 2017-08-03 00:00:00[2017-08-03 11:45:29,551] {python_operator.py:81} INFO - Done. Returned value was: Hello world!
(3) 测试sleep_task
xiaosi@yoona:~$ airflow test example_hello_world_dag sleep_task 20170803...--------------------------------------------------------------------------------Starting attempt 1 of 2--------------------------------------------------------------------------------[2017-08-03 11:46:23,970] {models.py:1342} INFO - Executing <Task(BashOperator): sleep_task> on 2017-08-03 00:00:00[2017-08-03 11:46:23,981] {bash_operator.py:71} INFO - tmp dir root location:/tmp[2017-08-03 11:46:23,983] {bash_operator.py:80} INFO - Temporary script location :/tmp/airflowtmpsuamQx//tmp/airflowtmpsuamQx/sleep_taskuKYlrh[2017-08-03 11:46:23,983] {bash_operator.py:81} INFO - Running command: sleep 5[2017-08-03 11:46:23,988] {bash_operator.py:90} INFO - Output:[2017-08-03 11:46:28,990] {bash_operator.py:97} INFO - Command exited with return code 0