我想为我们的DAG添加一些单元测试,但找不到。有没有DAG的单元测试框架?有一种端到端的测试框架已经存在,但我猜它已经死了:https://issues.apache.org/jira/browse/AIRFLOW-79。请多提建议,谢谢!
发布于 2017-12-23 14:49:24
像这样测试你的运算符:
class TestMyOperator(TestCase):
def test_execute(self):
with DAG(dag_id="foo", start_date=datetime.now()):
task = MyOperator(task_id="foo")
ti = TaskInstance(task=task, execution_date=datetime.now())
result = task.execute(ti.get_template_context())
self.assertEqual(result, "foo")
发布于 2017-08-29 15:10:13
目前,我找不到比简单地使用BashOperator
更好的方法
with DAG('platform-test', start_date=datetime(2017, 8, 29)) as dag:
test_command = "python3 -m unittest --verbose {}".format(platform_test_fname)
op = BashOperator(
task_id="platform-test",
bash_command=test_command,
)
https://stackoverflow.com/questions/45418285
复制相似问题