You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: scrapli-apps/README.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ This directory contains examples of using different libraries in scrapli family.
16
16
* type hints which allow IDEs to do better autocompletion magic
17
17
* easy to add support for another platform
18
18
19
-
The only complaint I have seen towards `scrapli` was that it "supports" a low number of network operating systems and e.g. `netmiko` supports more. And I personally think it is not a bad thing. There are so many different network operating systems and once an author adds support for them to the core of the library, they are ultimate responsible for maintaining it and it is miserable experience - github issues become populated with bugs related to platforms, instead bugs/feature requests for the core itself, they would be spending time stressing out how to get that platform image and how to test it. It is not sustainable.
19
+
The only complaint I have seen towards `scrapli` was that it "supports" a low number of network operating systems and e.g. `netmiko` supports more. And I personally think it is not a bad thing. There are so many different network operating systems and once an author adds support for them to the core of the library, they are ultimate responsible for maintaining it and it is hard - github issues become populated with bugs related to platforms, instead bugs/feature requests related to the core itself, maintainers would be spending time stressing out how to get that platform image and how to test it. I think it is not sustainable. It is quite similar to `nornir 3` dropping plugins from the core - it is just too hard to maintain.
20
20
Instead `scrapli` offers several ways to deal with this scenario, check out these sections in the docs:
Have you ever tried testing your network automation application in CI/CD? You probably don't have or don't want to have CI/CD pipeline do changes on your devices. So instead of actually connecting to network devices in your tests, you could use something like `monkeypatch` / `mock`, but it requires a decent amount of effort and looks ugly. This problem was first addressed for testing external HTTP APIs - by [vcrpy](https://github.com/kevin1024/vcrpy) project. The idea is that on tests marked with a specific marker, whenever that test invokes HTTP request(s), the library would save "cassettes" - YAML files containing request/response chain. Then, for subsequent calls to your test, the library would look up the response for a specific request in a YAML file, instead of doing a real HTTP request. By saving those cassettes to the repo, anyone or anything, including CI/CD, could test your app easily without actually talking to an external service.
56
-
Now imagine this, but for SSH. This is exactly what `scrapli-replay`is. It saves SSH interactions to YAML cassettes and replays them later on subsequent calls.
57
-
Personally, I think it is a big help in the world of network automation applications, as this greatly simplifies the testing of network automation applications. It really has no competitor, so here is an [example test](https://github.com/dmfigol/netwarden/blob/master/backend/tests/routers/test_devices.py) from my other project - [Network controller NetWarden](https://github.com/dmfigol/netwarden), where my network automation is powered by a web framework:
55
+
Have you ever tried testing your network automation application in CI/CD? You probably don't have or don't want to have CI/CD pipeline do changes on your devices. So instead of actually connecting to network devices in your tests, you could use something like `monkeypatch` / `mock`, but it requires a decent amount of effort and looks ugly. One elegant solution to this problem for testing external HTTP APIs was proposed by [vcrpy](https://github.com/kevin1024/vcrpy) project. The idea is that on tests marked with a specific marker, whenever that test invokes HTTP request(s), the library would save "cassettes" - YAML files containing request/response chain. Then, for subsequent test runs, the library would look up the response for a specific request in a YAML file, instead of doing a real HTTP request. By saving those cassettes to the repo, anyone or anything, including CI/CD, could test your app easily without actually talking to an external service.
56
+
Now imagine this, but for SSH. This is exactly what `scrapli-replay`does. It saves SSH interactions to YAML cassettes and replays them later on subsequent calls.
57
+
Personally, I think it is a big deal, as it greatly simplifies the testing of network automation applications. Here is an [example test](https://github.com/dmfigol/netwarden/blob/master/backend/tests/routers/test_devices.py) from my other project - [Network controller NetWarden](https://github.com/dmfigol/netwarden), where my network automation is powered by a web framework:
58
58
```python
59
59
@pytest.mark.asyncio
60
-
@pytest.mark.scrapli_replay
60
+
@pytest.mark.scrapli_replay# this will save output from show commands to a cassette
61
61
asyncdeftest_get_devices():
62
62
asyncwith AsyncClient(app=app, base_url="http://test") as client:
63
63
response =await client.get("/api/devices")
64
-
# /api/devices collect a show command from 10 network devices using scrapli
64
+
# /api/devices collects a show command from 10 network devices using scrapli
0 commit comments