Lab 3: Test your network with NUTS
Part 1. Introduction to NUTS
let’s setup our Inventory and Tests so we can run them from the CLI
1. Open the VSCode instance that we started Nautobot from (should have yellow borders).
2. Click “Terminal” in the top navbar, then “New Terminal”.
3. Type docker ps | grep clab
and press Enter to validate that your containerlab hosts are running
4. Right-click the “inventory” folder and Click “New File”. Name it hosts.yaml
. Add our clab hosts to the file.
---
clab-onug-nyc01-rtr1:
hostname: clab-onug-nyc01-rtr1
groups:
- eos
clab-onug-nyc01-rtr2:
hostname: clab-onug-nyc01-rtr2
groups:
- eos
clab-onug-nyc01-sw1:
hostname: clab-onug-nyc01-sw1
groups:
- eos
clab-onug-nyc01-sw2:
hostname: clab-onug-nyc01-sw2
groups:
- eos
5. Make sure it matches your actual running hosts and save the file!
6. Right click on the “tests” folder
7. Create a new file named test_lldp.yaml
8. Define your LLDP test to run for the whole “eos” group. Don’t forget to save!
---
- test_class: TestNapalmLldpNeighborsCount
test_data:
- groups: eos
neighbor_count: 3
9. Let’s go back to the terminal and run poetry shell
to create a virtual env with our dependencies installed so we can run our tests
10. Type pytest tests/test_lldp.yaml
to execute your test. If everything has gone according to the plan, you should see all of your LLDP tests passing
11. Now, let’s create our ping tests. Right click again on the “tests” folder
12. Create a new file named test_ping.yaml
13. Define your ping test. This time, we’re using hosts instead of groups as the arguments are different for each one
---
- test_class: TestNapalmPing
test_data:
- host: clab-onug-nyc01-rtr1
destination: 172.18.0.9
expected: SUCCESS
max_drop: 1
14. Navigate back to the terminal and run both tests with pytest tests/*
.
You should see that a total of 5
tests PASSED. The LLDP test is ran on all 4 hosts and the Ping test is only ran on rtr1
Where are TestNapalmLldpNeighborsCount
and TestNapalmPing
defined? Check out the Test Bundles Docs.
⬅️ Previous | 🏠 Home | Next ➡️ |