Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing - Containerlab and Mocking / Stubbing #57

Open
tardoe opened this issue Aug 26, 2024 · 4 comments
Open

Testing - Containerlab and Mocking / Stubbing #57

tardoe opened this issue Aug 26, 2024 · 4 comments
Assignees

Comments

@tardoe
Copy link
Collaborator

tardoe commented Aug 26, 2024

Opening this issue to begin discussion on how we should handle testing with v2. Currently the unit tests return mocked data and integration tests require containerlab to be spun up.

I propose the following:

  • A GitHub action that conditionally spins up a 2-3 node Containerlab network when an srlinux_versions.txt file is update. This file contains supported SRLinux versions and (sequentially) spins up a network, captures the JSON RPC output for each set of paths used in the driver and commits the output to the test/<version>/rpc_<paths_name>.json or the like. These fixtures can then be used "offline" by committers and during regular GH Action runs to unit test against supported SRL versions.
  • Using the above captured output, we can stub all _jsonrpc* methods under text fixtures and enable per-getter tests without needing an online network.
  • Configuration testing can be performed against a mock JSONRPC endpoint (https://colin-b.github.io/pytest_httpx/) with derived input and output to test load / merge / commit / rollback use-cases.

@hellt thoughts / ideas / comments / discussion?

@tardoe tardoe self-assigned this Aug 26, 2024
@jbemmel
Copy link
Collaborator

jbemmel commented Aug 26, 2024

I've always considered the live integration testing with Containerlab an important differentiator for the plugin. After having Containerlab installed and downloading the Docker image, the tests can be performed "offline" and are entirely optional. CI/CD workflows on GitHub spin up Containerlab instances internally

Having a 'snapshot' of JSONRPC output isn't as comprehensive as being able to spin up any release you want, with any node configuration / topology, and then running regression testing against that. I'd expect more bugs to be found in the area of specific (combinations of) config options and/or race conditions.

In short, I'm not sure what problem you'd be solving?

@tardoe
Copy link
Collaborator Author

tardoe commented Aug 26, 2024

@jbemmel there would still be the option of running the tests locally, but having the option to run tests easily (e.g. for small fixes) without needing a full lab lowers the barrier of entry.

@hellt
Copy link
Collaborator

hellt commented Aug 26, 2024

@tardoe I'd say on a high level I'd split the testing into the following parts:

  1. Raw input extraction. This is what you proposed in the first bullet point. The goal is to get the raw json responses per each getter that would be used in unit testing of getters
  2. local/remote unit testing of getters based on the previous step. This is where we a) take the raw json input extracted before, apply the getters logic, compare the result with a golden file.
  3. unit testing of cfg workflows (merge replace, replace, etc). I think this is where we might always require a real system, granted it is easy to spin up one locally or in actions.
  4. gh actions would use all of the above by also introducing a matrix of py versions to the mix. If we extract the raw json responses per each getter we support, there is no real need to perform the proper e2e test for all getters, although it is not a problem to add those, to ensure the real life scenario is working.
    The cfg opertaions though should always run in actions by spinning up a real device, I think.

@jbemmel
Copy link
Collaborator

jbemmel commented Aug 26, 2024

@tardoe there is no barrier thanks to Containerlab and SR Linux. Unlike most other platforms that developers may be familiar with, SR Linux makes an easy-to-obtain free container image available. This makes it trivial to construct CI/CD pipelines such as the one illustrated in this repo - without the user having to lift a finger!

Consequently, there is no need to jump through hoops like you are suggesting. This is the best other platforms can do - but ours (yours) is better than that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants