This lesson is part of the Network Testing with Pytest course.
In this lesson, you will learn:
- What is Batfish?
- The use-case that this integration can be applied to.
- A code walkthrough of the integration.
You can find the scripts and code for this lesson within the Pytest repo under the directory: 005_integrations/003_batfish.
We will now cover integrating Pytest with Batfish. First of all:
What is Batfish?
Batfish is an open-source multi-vendor network analysis tool that allows you to validate your configuration data, query control plane state, verify ACL rule sets, analyse routing/flow paths, as well as simulating network failure.
The way that Batfish works is that you provide it with your device configurations. Batfish then builds a model of your network, which you then query to perform the necessary validation and analysis.
Our Batfish integration will be based on the following (diagram below):
- Our tests will be based on validating the MTU of our interfaces, along with testing for a range of routing issues such as:
- duplicate router IDs
- forwarding loops
- unestablished BGP sessions
- OSPF and BGP configuration issues.
- Where possible Batfish assertions will be used. Batfish assertions take some of the heavy lifting out of building Batfish queries and also expose the DataFrame details clearly at the point of a failed assertion.
- For any tests not using Batfish assertions,
AssertErrorwill be raised to clearly expose the Batfish DataFrame details within the Pytest traceback output. Further details on this point are below.