Re-apply reverted commit Iabda95073faa2191fd117e9637e0858c589e9d9e
("Drop python2 support"), but with additional changes to make the
scripts actually work with python3 and to make it build without python2.
I have verified, that the contrib/jenkins.sh scripts of all Osmocom
repositories (with their python3 patches on top) are working with this
patch and that all Osmocom repositories with the python3 patches build
in OBS (tested in own namespace).
All related patches for changing from python2 to 3 in other repositories
must be merged shortly after this one, as soon as the build slaves were
(automatically) updated to have the new osmo-python-tests installed:
https://gerrit.osmocom.org/q/topic:drop-py2
New fixes:
* osmopy/obscvty.py: verify: fix compare
Comparing maps in python3 does not work the same as in python2. Convert
them to lists first, so the compare works as intended again.
Fix error:
File "/home/user/code/osmo-dev/src/osmo-python-tests/scripts/osmotestvty.py", line 57, in test_history
assert(self.vty.w_verify(test_str, [t1]))
AssertionError
* osmopy/obscvty.py: use enc/dec with send/recv
Fix error:
self.socket.send("%s\r" % request)
TypeError: a bytes-like object is required, not 'str'
* scripts/osmotestconfig.py: use encode() before writing to file
Fix error:
File "/home/user/code/osmo-dev/src/osmo-python-tests/scripts/osmotestconfig.py", line 91, in copy_config
tmpfile.write(open(config).read())
File "/usr/lib/python3.5/tempfile.py", line 622, in func_wrapper
return func(*args, **kwargs)
TypeError: a bytes-like object is required, not 'str'
* debian/control: add --buildsystem=pybuild. Otherwise "--with python3"
is ignored and the build fails if python2 is not installed, with:
Can't exec "pyversions": No such file or directory at /usr/[...]/python_distutils.pm line 120.
Related: OS#2819
Change-Id: I3ffc3519bf6c22536a49dad7a966188ddad351a7
This reverts commit fb1dc7c405.
I was under the impression, that all previous scripts were already
working with python 3. But as it turns out, this isn't true. Reverting,
so I can properly post follow-up patches, that fix the issues before we
apply this "drop python2" patch again.
Related: OS#2819
Change-Id: Ic1559d1a9f7839fa86a841d62a04b22e1caed466
Remove all compatibility code for python2.
All scripts are already python 3 compatible since
I80e5850a8978d78cda793e2192ef4bd3fd54a121 and
I1b4a629f12863c498a8681b555f57b4e255cebfb.
dpkg-buildpackage shows that it is still invoking setup.py with python
in addition to python3, on debian stretch. But after spending quite some
time on trying to convince it to not care about python2 without success
(trying different variables, overrides, --without python2 flags etc.),
I'm leaving it as is. The resulting package is the python3 package, which
is what we want.
Related: OS#2819
Change-Id: Iabda95073faa2191fd117e9637e0858c589e9d9e
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
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
This simple tool dump all the rate counters available via ctrl interface
to cvs file (or stdout).
Change-Id: I12b369434e4ee9b38f92872f297e1f3d4f0698c2
Fixes: OS#2550
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
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
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
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
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
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
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
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
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
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
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
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
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.