726b58dcfb
While adding VTY and CTRL tests to new programs like OsmoHLR, I wanted to have a simple way to translate a VTY interaction transcript to a VTY python test. It is fairly trivial to simply read in a transcript, extract both the commands to send as well as the expected results, and to verify these without having to write one line of application-specific code. From there it was just a little step to allow the same for CTRL interaction. With osmo_verify_transcript_vty.py and osmo_verify_transcript_ctrl.py, it is possible to have a simple text file of a telnet VTY or CTRL interface interaction and run it against a given application. With the --update option, the scripts run the given command and rewrite the transcript file to whatever the application currently produces as response. Backed by version control, it is super easy to tweak commands, --update the test results and verify that only the desired bits changed. A '...' wildcard can skip any number of lines in the expected result and is usually preserved during --update. This python3 implementation is independent from the previous obscvty implementations. Take the opportunity to clarify/fix a few aspects: for example, it is now possible to verify the hints that the interactive VTY displays when the user enters '?' in various places, and to evaluate the prompt character '>'/'#'. Unitl now, code is duplicated/scattered across various vty_test_runner.py scripts in different git repositories. Now, a VTY or CTRL transcript is enough to put a complete test in place. The simplest invocation is directly from the Makefile, feeding an application commandline, the proper port number to contact it and e.g. a VTY prompt name. This new code is also usable as python modules, to be able to build more complex tests that require specialized intermediate actions, possibly coordinating launch of applications or data manipulation. The first repository to employ this is osmo-hlr.git. See change-ids I42b3b70a0439a8f2e4964d7cc31e593c1f0d7537 for VTY and Iff93abe370b8f3ecf42082d1d0eaa1fbeca5b122 for CTRL. Change-Id: Id47331009910e651372b9c9c76e12f2e8964cc2c |
||
---|---|---|
osmopy | ||
.gitignore | ||
README | ||
setup.py |
README
Building/installation: sudo python setup.py install If you prefer to have it cleanly removable, install checkinstall and run sudo checkinstall python setup.py install Alternatively, just run 'pip install --user -e ./' Use There are currently 3 scripts in this package: osmodumpdoc.py - dump documentation (the VTY's "show online-help"). osmotestconfig.py - test that apps start/write with example configs osmotestvty.py - test vty operations (currently, tests very few) Each of these scripts imports a project-specific osmoappdesc.py, which provides information about the available apps, configs, vty ports, etc. Run the scripts with osmoappdesc.py in the current directory (preferred) or with -p <the directory containing osmoappdesc.py>. Remember that osmoappdesc.py may contain relative paths. Example: After install osmodumpdoc for openbsc's apps can be run by: cd <your_source_dir>/openbsc/openbsc && osmodumpdoc.py Libraries: osmopy/obscvty.py - connect to a vty, run commands on it, see the result osmopy/osmoutil.py - code that's shared between the scripts obscvty.py may be of general use. osmoutil.py probably isn't.