Commit Graph

49 Commits

Author SHA1 Message Date
Max d05da3e68d Add git-review config
Change-Id: I2359e960eda1f9c941fab22b50ebe56242149c78
2017-11-23 14:46:07 +01:00
Neels Hofmeyr 066a95dec5 cosmetic: cmdline arg doc tweaks, comment
Change-Id: I60dc059879dfe15cd3415ce1ed068ded28ff084e
2017-10-18 03:57:27 +02:00
Neels Hofmeyr 6562c085c4 osmo_verify_*: clarify naming to osmo_interact_*
Have common implementations in one place, and expose distinct command line
argument signatures to obtain the separate tasks as separate scripts.

osmo_interact_common.py implements the parts common to all VTY and CTRL
interactions.

osmo_interact_vty.py and osmo_interact_ctrl.py implement commands I/O but only
expose command line args to directly pipe commands and responses.

osmo_verify_transcript_vty.py and osmo_verify_transcript_ctrl.py act as before,
now implemented by importing osmo_interact_{vty,ctrl}.py, only exposing the
verifification command line arguments.

Change-Id: Ie0cbd5db85ebebc893df638a07f5568632563dc9
2017-10-18 03:54:45 +02:00
Neels Hofmeyr 08d645b01d osmo_verify_transcript: allow running/piping commands directly
To retrieve the VTY reference XML from 'show online-help', which we need for
the osmo-gsm-manuals, it is useful to directly print the output of a single VTY
command.

I have also always wanted to be able to just type CTRL commands and get their
results.

Add --command and --output arguments to run specific commands and pipe to
stdout instead of verifying a transcript file, in a way that works generically
for both VTY and CTRL interface.

The scripts' names are now a bit of a misnomer, to be tweaked separately.

Change-Id: I2c31a87fa255092bcd06da239651cc50174c8faa
2017-10-18 03:43:21 +02:00
Neels Hofmeyr 32cbce1a16 osmo_verify_transcript_vty: automatically obtain the prompt string
If -n is omitted, retrieve the proper prompt name from the initial VTY opening
prompt.

Change-Id: Id5d953156023fcbfc8867c1c3634d787d0b3ac57
2017-10-18 03:42:13 +02:00
Neels Hofmeyr 7b5203f6aa osmo_verify_transcript: add error handling for missing port
Change-Id: I1627c36cfb627e7f3a9b4d9f087bf10875ae0690
2017-10-18 02:09:08 +02:00
Neels Hofmeyr 4e8d6eec5c setup.py: don't install py3 scripts with python2
If one calls 'python2 setup.py install', python replaces the script shebangs
with python2 ones, regardless of the code being mint python3, and vice versa.
In setup.py, name only the scripts that match the current python version.

Change-Id: I84a5c8ec108a99f527b0d2fb5bf4e312df5f7403
2017-10-17 04:06:33 +02:00
Neels Hofmeyr 726b58dcfb add osmo_verify_transcript_{vty,ctrl}.py for easier vty and ctrl testing
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
2017-10-17 02:11:58 +02:00
Neels Hofmeyr 92f310500c add osmo_ipa.py, from originally openbsc.git/contrib/ipa.py
At least now that openbsc.git has been split, the IPA and Ctrl API offered by
this file are used across multiple git repositories for python tests. Instead
of having a separate copy of ipa.py in each, have one here.

Rename to osmo_ipa.py to avoid any confusion between old and new files that
might be lying around in the python path.

Change-Id: Iaef955f04b97e8f266339b37b46d2523d1247cb9
2017-10-15 02:57:10 +02:00
Neels Hofmeyr d2e793a58a osmodumpdoc: print generated path
Change-Id: Ie39316f0b51ee518b9dce8d5f98b53f748db573b
2017-09-18 16:30:33 +02:00
Neels Hofmeyr a784f2407b osmodumpdoc: print called commands and OSError messages
Change-Id: Ib044cbb8a1b8e02cbe6852f785c75b5c7aae6174
2017-09-18 16:30:33 +02:00
Neels Hofmeyr 8e4806c5f2 osmodumpdoc: fix finding cfg when not calling from source tree
When the binary has not been built in the source tree, it was impossible to
call osmodumpdoc.py despite the -p <config-path> option. Look for config files
in that config-path.

Make sure a relative config-path is adjusted when changing to the workdir.

Change-Id: I5427d354c289ec4602411c7059c8d80e2b451f7c
2017-09-18 16:30:31 +02:00
Holger Hans Peter Freyther f41db1e337 vty: Follow links to see what is a file and what is a socket
Change-Id: I3d94cde8523a2ed26a66b8b8b3f651606aa17a9d
2017-09-13 15:42:15 +08:00
Holger Hans Peter Freyther 562bfea593 vty: Print open file descriptors of the VTY test runner
/proc/self/fd refers to the process opening the file. In this case
self will be "ls". Maybe it is better to look at the FDs open in
the test runner itself.

Change-Id: I638e94f16f4019a7b6026d1fae69e677870fb253
2017-09-13 15:38:48 +08:00
Neels Hofmeyr baa6f12260 test_all_apps: actually count nr of errors
Each test run returns 1 on error, so instead of |=, why not count the number of
errors with +=. Also print the final error count.

Change-Id: I690dde3711555a3447e5ad4cc0a04a7a869a8296
2017-03-06 15:31:08 +01:00
Neels Hofmeyr cebe8f5b00 on Exception during test, also print the actual config
When a test run encounters an Exception, the test config file name is printed,
but that may already be gone when done, so also print the complete actual test
config file contents, making it easy to reproduce the failure manually.

Change-Id: I9b00f170fb0cdceb35b9231eb1f2c545ba079d1d
2017-03-06 15:31:08 +01:00
Neels Hofmeyr 9b0a51fb87 osmoutil: end_proc: wait for term in a loop
Recent commit b59b677c9b called proc.terminate()
instead of killing right away, with a .1 second sleep. Reduce this sleep to
a minuscule first wait_time, remaining tolerant for processes that take longer.

Actually all of our current processes are very fast to terminate. This patch
was created while looking for a different problem, now that it's there we might
as well keep it.

Change-Id: I98849e4550116c5666fdf6f5d4cbb576ffa3e14a
2017-03-06 15:31:08 +01:00
Neels Hofmeyr 119bed52fa osmoutil: add pick_test() to pick unittest tests by name
Change-Id: I92f90c334169f31920c63dd5c5ac8dac215065e6
2017-03-06 15:31:08 +01:00
Neels Hofmeyr abd4b7d705 speed up python tests more than 10 fold by sleeping less
The VTYInteract tests gave a constant sleep(1) grace period for the process to
startup. This caused the test to take minutes for no reason at all.

Add code to VTYInteract._connect_socket() to try and connect right away,
retrying up to three seconds in .1 second intervals. This flies through most
tests without any sleep() at all.

When TCP socket debugging is switched on, also print how many connection tries
it took to connect the VTY socket.

Note that the openbsc python tests also add some sleep()s that also need to be
removed to benefit from this.

Change-Id: Icc337f52a93d5fe31fc4ff235ccaf4e0fe75fa39
2017-03-06 15:31:08 +01:00
Neels Hofmeyr 4e64b8821d cosmetic: put socket connection code in separate function
Prepare for upcoming patch that adds connection retries to speed up tests.

Change-Id: I2dddf8794b4241898373178c8a1aa2e98b01095c
2017-03-06 15:31:08 +01:00
Neels Hofmeyr 8e9f30f3e1 tcp_debug: don't abort when socket can't be removed
It appears that during some error conditions, the socket will not be in the tcp
socket debug tracking list, and on top of an exception this barfs as well.
Let's not care about the tcp debug list and avoid confusing error messages.

Change-Id: I8daa317fed8fc7e720dccb70fd5f7fc74fde423f
2017-03-06 15:31:08 +01:00
Neels Hofmeyr e349320992 cosmetic: early exit instead of if-cascade
It appears that during some error conditions, the socket will not be in the tcp
socket debug tracking list, and on top of an exception this barfs as well.
Let's not care about the tcp debug list and avoid confusing error messages.

Change-Id: Ib7b0e45fa1f5551da2fc81b71dcc227eee533f44
2017-03-06 15:31:08 +01:00
Neels Hofmeyr cb320b8ddf debug_tcp_sockets: clearly mark as global var
Change-Id: I56e26590ea380c7deab7ce132d688b37eb2d11a3
2017-03-06 15:31:08 +01:00
Neels Hofmeyr ac0b59d93a debug: also output nr of open file descriptors for 'tcp debug'
Change-Id: I8a583df549f3e2b79068fd8cd32b75473539410d
2017-03-06 15:31:08 +01:00
Neels Hofmeyr 2bdab3d291 tcp debugging: allow switching on TCP debug by env var
Print monitoring info about TCP sockets when the env var
OSMOPY_DEBUG_TCP_SOCKETS is present and not "0".

Makes it easy to enable it on jenkins without blowing up output of normal runs
"at home".

Change-Id: I46212d07a2c1be05672a37766457e6c98b68f90d
2017-03-06 15:31:03 +01:00
Neels Hofmeyr f6ab3d8e9c osmoutil: open /dev/null only once
Change-Id: Ic6da34f6c4c5cd3b0786788f4e38c9c6248fca1b
2017-02-24 20:49:51 +01:00
Neels Hofmeyr b59b677c9b osmoutil: try to terminate process instead of killing
Change-Id: Iaa978467b140e3d6dc5a2a6d8966282e64630ce7
2017-02-24 20:49:39 +01:00
Neels Hofmeyr 8972d06754 osmotestconfig: fix socket leak
Each running test would open up another socket without ever closing unused
ones. Close the sockets after each test is done.

Change-Id: If97944a079e901439139161eae39181f5c800200
2017-02-24 20:49:34 +01:00
Neels Hofmeyr 3ef39e9b9e osmoutil: centrally log process launches
Log Popen in osmoutil.py instead of in each python test. Launch message is
being removed in openbsc's python tests and added here. (change-id
Id8eb70ddfdc1d0d9f90aa5343a4ea522042c34ee)

Change-Id: I7e539abc3aeee91ae3e7635f9e28b9e557eaf969
2017-02-24 20:49:27 +01:00
Neels Hofmeyr 93a808eaba debug: monitor used TCP sockets and running osmo processes
Add global flag debug_tcp_sockets; if true, monitors all open TCP sockets of
the system and running processes by regular 'ss' and 'ps' output, and logs
which VTY sockets are opened and closed.

Change-Id: I0cc7dc049c66f29fe58fee204e74aa9e82c21989
2017-02-24 20:49:21 +01:00
Holger Hans Peter Freyther 99b5c56c04 vty: Close the vty sockets at the end of each test
In the OpenBSC VTY tests it seems no one is calling
the command with close=True. So make sure the socket
is released. Modify _close_socket to be idempotent.

Change-Id: I717537772e89113ef352d32ffba1b7a840f2c6e6
2017-02-13 20:09:01 +07:00
Holger Hans Peter Freyther 0edf0c9995 vty: Check the result of the write command
When running on top of vboxsf the write option doesn't work and we
have a success that should be a failure. Check the success string
we want to see on write.

Change-Id: I460e2da10f049807e4729f53fc69448c9c30f5f9
2016-08-15 12:37:39 +02:00
Max 6c33a15e41 Fix build failure
After copytree the destination directory might end up not being writable
- this causes failure for subsequent writeconfig tests. Force rwx
permissions to fix it.
2016-04-14 08:32:06 -04:00
Max 334d680d28 Recursively copy files before config test
Copy all potentially necessary files (like includable configs) before
running config test.
2016-04-12 10:15:41 -04:00
Max 5f4567b2a2 Extend apps attribute
In addition to binary name it's now possible to provide extra
command-line arguments in osmoappdesc.py for application under
test. This change is fully optional and backward compatible.
2016-03-31 11:59:56 +02:00
Max d401cc13ae Add optional ignore_configs attribute
This attribute in osmoappdesc.py allows to ignore certain configs while
running vty tests. It's handy for hardware-specific or otherwise special
configuration examples.
2016-03-31 11:59:35 +02:00
Max 32d0fd8872 Expand installation instructions 2016-03-31 11:59:10 +02:00
Max 44f5163c50 Add .gitignore
Ignore install leftovers.
2016-03-31 11:59:09 +02:00
Alexander Chemeris 2f48313ed6 obscvty: Implement readlines() generator function. 2015-05-30 17:45:49 +02:00
Holger Hans Peter Freyther b819b57a98 testconfig: Do not fail due wrong numbers
Fix the script and don't fail
2015-01-31 21:15:06 +01:00
Holger Hans Peter Freyther 4e98c266b7 testconfig: Check the result of running the individual tests
Currently the tests might find issues with the documentation but
the exit code is still 0. This attemps to make the test_config
check the result of each test and then return if an error has
occurred. This should propagate all the way into a sys.exit()
call.
2014-07-04 20:43:38 +02:00
Jacob Erlbeck 41b0d30459 obscvty: Added node() method to get the last node string
Extract the node name from the VTY prompt after executing a
command and return it via the new VTYInteract.node() method.
2013-08-30 18:28:05 +02:00
Holger Hans Peter Freyther 99bbea7f19 obscvty: Make the _is_end detection work for entering the config
Make the code work for entering the configuration step. The name
of the configured node will show up. Change the semantic of the
_is_end method to return how many chars make up the end.
2013-06-25 08:20:41 +02:00
Kat cd564fcebc Fixed osmodumpdoc to work with the refactored importing 2013-04-06 11:11:49 +02:00
Kat 0270be43b9 Minor refactoring of importing osmoappdesc 2013-04-05 21:34:52 +02:00
Kat 0248d3b668 Made the scripts work from make distcheck 2013-04-05 20:20:50 +02:00
Kat 0d114c854b Added a verbosity option and banner to osmotestvty 2013-04-05 18:21:39 +02:00
Kat a8ee6bb97b Documentation: added a README, more docstrings; +x'd setup.py 2013-04-05 17:08:28 +02:00
Kat a7185c6c72 This is a set of test scripts for osmocom projects.
Currently, it's tested on openbsc and osmo-pcu.
Scripts: osmotestvty.py osmodumpdoc.py osmotestconfig.py
The scripts are designed to be run from make check,
but can be run independently as well.
As a general rule, run them in the top dir of a project.
2013-04-04 17:31:17 +02:00