Validation, Error Handling and Unit Tests
From Building Network Automation Solutions
At a Glance
- High-intensity interactive online course;
- Jump-start your network automation career;
- Hands-on experience working on a solution to your own problem;
- 6 week course spread across ~2 months;
- Live discussion and guest speaker sessions;
- Design and coding assignments and group work;
- Final course completion certificate.
GIGO (Garbage-In-Garbage-Out) is one of the major sources of automation failures. A good automation solution should always validate the input data before starting automation tasks. It should also check the actual device state before making changes to the device configuration unless you’ve fully automated the configuration deployments.
This section will describe various approaches to data validation and error handling. We’ll also focus on unit tests - simple tests that verify the correctness of your code, and stress-test it using as many invalid inputs as possible - and figure out how to automate them as part of your deployment process.
In the hands-on part of this section you’ll add data validation and error handling to the configuration-generation playbook you created during Week 4, and create unit tests to test your new code with a variety of invalid inputs.
Pete Lumbis will explain how you can use the software concept of automated testing to bring a faster rate of change with a greater degree of success. He'll describe the tools required to make automated testing a reality, and how automated testing can be easily folded into a team-wide change management system.
Recording of the January 2017 session
- Network CI-CD (PDF)
- Change Management Today and Tomorrow
- Continuous Integration with GitLab
- NetDevOps Toolbox
- Debugging, Testing and Input Data Validation (PDF)
- Writing Fail-Safe Playbooks
- Debugging, Logging and Testing
- Input Data Validation
You'll find the Ansible actions you need to check data validity, assert conditions, or fail playbooks in the Ansible Playbooks and Advanced Ansible Topics parts of the Ansible for Networking Engineers webinar.
More to explore
If you haven't read the Validating deployments with NAPALM blog post, please do it now.
You should also listen to these Software Gone Wild episodes (each one is ~1 hour long):
- Test-Driven Network Development with Michael Kashin
- Distributed On-Demand Network Testing with Matt Oswalt
Finally, here's a list of interesting blog posts and other resources: