Commit Graph

18 Commits

Author SHA1 Message Date
Pau Espin 10fbb40b24 Introduce script ctrl2cgi.py
This scripts implements a similar proxy to the one already available in
soapy.py, but aiming at converting CTRl into a regular HTTP POST Request
to be handled by a CGI script in the HTTP server.

Furthermore, it includes several improvements over the soapy.py script,
such as using a token to authenticate users and capability to read some
parameters from a cfg file.

Change-Id: I7a83ecb379835e295c8cb4c27c39883783746544
2018-07-11 22:47:54 +02:00
Pau Espin 8739f9c4fc Move twisted_ipa.py to osmopy lib
twisted_ipa is a module expected to be used by other python scripts, so
move it to osmopy dir to be installed as a lib (in python path) so it
can be later used.

twisted_ipa has some features to use it standalone for testing purposes.
This feature can still be used from new installation path.

Change-Id: I33a0c4263297abd9e111bf43e6e9967c06474318
2018-07-11 14:05:28 +02:00
Max 34d2ca5bc8 Add rate counter dumper
This simple tool dump all the rate counters available via ctrl interface
to cvs file (or stdout).

Change-Id: I12b369434e4ee9b38f92872f297e1f3d4f0698c2
Fixes: OS#2550
2018-01-12 16:43:37 +01:00
Neels Hofmeyr 58bd53c87b cosmetic: setup.py: move osmo_interact_* next to osmo_verify_*
Those scripts are semantically closely related, so place them next to each
other.

Change-Id: Id7380f9d536c83ee1d612457af423dde9b96f5ad
2018-01-09 12:56:20 +01:00
Neels Hofmeyr 56d08ae735 cosmetic: setup.py: tweak indenting, add vim comment
We usually do only space indenting in our py code, replace tabs with spaces.

Change to one script path per line for easier patch reading in the future.

Add a vim expandtab comment.

Change-Id: I8a501715127c2583a630b1efb0d5316574eea173
2018-01-09 12:54:43 +01:00
Neels Hofmeyr f949f8a5a0 remove osmodumpdoc.py and osmotestconfig.py from py3 install
Install these scripts as py2 only.

These scripts were added to py3 in error by commit "Improve python3
compatibility", I80e5850a8978d78cda793e2192ef4bd3fd54a121, which only addresses
print() compatibility but not encoding.

Recent patch Ief11b75acc973dc7aeaac9c2298a21dc5390efe4 removes osmotestvty.py
from py3 installation. osmodumpdoc.py and osmotestconfig.py are still py2 for
the same reasons and are also likely to fail when run as python3.

Related: OS#2821
Change-Id: Ibf8fc488ae2c022f75f0ca63483d80ed701e8c40
2018-01-09 12:43:44 +01:00
Max 99f1c4714c Remove osmotestvty.py from python 3 installation
This script is actually not python 3 compatible yet despite passing
current tests. Let's not install it for python 3 until we can figure out
a way to catch this incompatibility with test code.

Change-Id: Ief11b75acc973dc7aeaac9c2298a21dc5390efe4
Related: OS#2821
2018-01-08 12:15:55 +01:00
Max 2f266e0cec Improve python3 compatibility
Use proper print() function to make scripts compatible with both python
2 and 3. This paves the way to deprecating python 2 support altogether.

Change-Id: I80e5850a8978d78cda793e2192ef4bd3fd54a121
2018-01-05 10:15:47 +00:00
Max 8a02e36575 Use python3 for osmo_ctrl.py
It's a standalone script illustrating the use of ctrl protocol from
python. Since it's not used as a library and nothing depends on it, we
can safely switch to python3.

Change-Id: I2461dd9af67771beed5306116e8a1b0ee2285aa8
2017-12-21 14:37:23 +01:00
Max 120075a6a5 Move scripts to appropriate directory
Having the scripts in the same directory with library code means that
it'll be installed unconditionally regardless of version check in
setup.py which makes it impossible to write separate tests for python 2
and 3. Fix this by moving the scripts into separate directory and
adjusting init and setup files accordingly.

This is necessary for implementing proper CI tests in follow-up patches.

Change-Id: I30cdf0f85b2a60a235960911c9827f4129da40db
2017-12-18 13:12:08 +01:00
Max 7f7c4b4410 Use setuptools for packaging
According to https://docs.python.org/3/library/distutils.html the
setuptools are used in place of distutils anyway. Using it directly
allows us to make packaging more flexible: specify dependencies,
automatically find package name etc.

Change-Id: I39ee53f352001e47c6df055cbec52d638480253d
2017-12-15 20:40:41 +01:00
Max 751491cdf9 Add osmo_ipa.py to setup's install
When running jenkins job, osmo_ipa is not available despite latest
osmo-python-tests being installed on the build slave. Let's try to fix
it by explicitly adding it to setup.py

Change-Id: Ic3e160c220ca6d2b55df0dfcdcdcb56e4e240bb3
2017-11-27 15:21:17 +01:00
Max e732c2ca3b Add *.py from OsmoBSC
Those are generic enough and can be used as advanced example of uzing
CTRL interface from python on top of osmo_ipa.

Change-Id: Ic4e1155d3bd546feaabab34a46e354c69058056e
2017-11-27 14:07:07 +00: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 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
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