8 Testing
This chapter covers:
- Testing in an Airflow CI/CD system
- Running tasks with and without task instance context
- Mocking in the context of Airflow
- Various options for integration testing
In all previous chapters, we’ve focussed various parts of developing Airflow. So how do you ensure the code you’ve written is valid before deploying it into a production system? Testing is an integral part of software development, and nobody wants to write code, take it through a deployment process, and keep their fingers crossed for all to be okay. Such a way of developing is obviously inefficient and provides no guarantees on the correct functioning of the software, both in valid and invalid situations.
This chapter will dive into the gray area of testing Airflow, which is often regarded as a tricky subject. This is because of Airflow’s nature of communicating with many external systems and the fact it’s an orchestration system, which starts and stops tasks performing logic, while Airflow itself (often) does not perform any logic.