Skip to content

Engine Tests

jfuruness edited this page Sep 16, 2024 · 12 revisions

Home

Tutorial

Engine Tests

There is also the ability to produce system tests that result in diagrams that can be easily viewed, such as the one below. These are essential for debugging routing policies on a small scale.

Image

To do this, we use the pytest framework. You can see an example of how to run this on a single config object in bgpy/scripts/tutorial/tests.

First you must copy over the conftest.py. This will ensure that the tests can be run during multiprocessing and still succeed. It also ensures that if the tests are being run for the first time, you can pass in --overwrite (as in pytest --overwrite).This will cause the YAML in the diagrams to be written to both the ground truth and to the guess (and the tests will automatically pass). Afterwards, you can verify the diagrams visually and confirm that this is correct. Doing it this way is vastly faster and simpler than writing out all the YAML by hand.

Second you can pass in --view (as in pytest --view) so that the PDF that is output will be opened, and you can view both the ground truth and the guesses for each diagram.

Lastly, you can also use --dpi to set the DPI (default is 96)

If you look into the engine_tests folder, we can see the test_engine.py file. This is the test that actually runs everything. You don't need to know how the source code for the engine tester works, you just need to know that it takes as input an engine config. It takes this engine config, creates a graph, runs the simulation engine over that graph, and then dumps it to YAML so that it can later be graphed. To see an example of this EngineConfig in use, you can look no further than the engine_test_configs folder. Here we can see an example of the config that generates the diagrams for this tutorial's testing. The folder engine_test_outputs contains the ground truth and guess outputs from testing. Ideally you should never have to modify files here and they should all be autogenerated. You're also going to want to make sure that your repo has a .gitignore (such as in bgpy/.gitignore) that will ignore all of the guess files, there's no need to commit any of those.

If you want to see examples of all the attacks, policies, etc, a great way to do that is to view our tests. You can run them on BGPy with pypy3 -m pytest bgpy --view.

In this section I have not copy pasted the code into here since it really requires the entire tree, so please view the code at bgpy/scripts/tutorial/main_tutorial/tests, and if you'd like any clarification please email me at jfuruness@gmail.com

Next: Explanation of Graphs Directory Structure

Clone this wiki locally