Tests for the Meraki API

thoenedj
Just browsing

Tests for the Meraki API

I am needing some way to automatically verify that my network automation script, which leverages Python to interact with the Meraki API, actually configures what I need it to and nothing else.  In other words, what do I need to do to make sure that the API calls are actually working correctly, without having to manually check the dashboard? 

4 REPLIES 4
ww
Kind of a big deal
Kind of a big deal

Use the get after you used the put/post

mlefebvre
Building a reputation

Validation logic is entirely up to you and how much work you want to put into it.

 

-You could compare the JSON you PUT to a GET right afterwards

 

-You could use a diff-style library like difflib or diff itself

 

-If there are multiple steps you could also use Action Batches to make sure the entire change goes through or it gets reverted

 

etc.

PhilipDAth
Kind of a big deal
Kind of a big deal

Wait for end users to ring and complain that "it's broken".

AutomationDude
Building a reputation

There are several things you can do such as:

 

- Error catching

-> If no errors are caught then its safe to assume things worked out 

- Read API calls afterwards

-> This will allow you to check the read data against certain conditions 

Generally speaking though, the logic you're trying to do doesn't make much sense. The API touches only what its meant to and nothing else. There's no way to ensure that the correct configurations were made because it is not possible to define "correct" in terms of code, especially since the whole point of the script is to change the configurations and thus the definition of "correct" changes as well. If the script is meant to change configurations, that's exactly what it will do. Nothing else.

Get notified when there are additional replies to this discussion.