Commit Graph

20 Commits

Author SHA1 Message Date
Oliver Smith d8666ad3c8 Drop python2 support / make it work with python3
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).

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
2019-12-11 11:28:06 +01:00
Oliver Smith b0ba927e33 Revert "Drop python2 support"
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
2019-12-06 16:06:38 +01:00
Oliver Smith fb1dc7c405 Drop python2 support
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
2019-12-05 13:41:38 +01:00
Max 6ccd0785d8 Fix python3 compatibility
Use print() function with proper import.

Change-Id: Ib10dfbec18202245031a634fc3f19677fc952e60
2017-12-18 13:12:48 +01: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 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 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
Alexander Chemeris 2f48313ed6 obscvty: Implement readlines() generator function. 2015-05-30 17:45:49 +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 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