|Age||Commit message (Collapse)||Author||Files||Lines|
Let's move code related to coping stuff to remote hosts and managing
remote processes under a class where relevant information is stored.
This simplifies parameters being passed all over and allows to reuse
First of all, it was found that vty allocation must be forced (-t -t)
during ssh session creation to make sure SIGHUP is forwarded when
session is closed.
Second, since osmo-trx ignores SIGHUP (osmo_init_ignore_signals()), we
must add a wrapper script which converts received SIGHUP into a SIGINT
to stop osmo-trx.
It can later on be used by other classes that need to run binaries in
After bug described in OS#3456 and fixed in last commit, let's
categorize and place variables in its correct plac to avoid similar
issus. We leave under the class keyword (class scoped variables) the
attributes which are to be used as static class attributes. All other
ones are initialized during __init__(). This way w avoid scenarios in
which while using an object from an instance attribute we end up reading
a class scoped variable which is shared among all instances.
Some tests may want to reproduce some scenarios in which it is expected
that a BTS process is stopped, for instance if the BSC link is dropped.
Provide a keepalive parameter to start() for bts and pcu objects to
inform suite that failures are expected and that it should keep them
alive in case that ocurrs by respawning the BTS process.
It will be needed later at construction time when resolving the num of
Move duplicated code into a method in the superclass.
A lot of code can be shared by all osmocom related BTS we currently use
(sysmo, octphy, trx). This commits moves all this easily shareable code
to an abstract class OsmoBts which all (osmocom) BTS use.
Some bits of code do not apply for osmo-bts-sysmo but it's still shared
by BTS running in the main unit (octphy, trx), for instance the pcu
socket handling. Those are put together in OsmoBtsMainUnit.
This way we have:
Also take the chance to categorize the different APIs in the new
abstract class based on their use and scope.
Some code changes while moving which were required:
- A new protected abstract API "create_pcu", which returns an object of
"pcu" interface. Subclasses implement this API returning either a
PcySysmo or a PcuOsmo object. This is needed to abstract the pcu()
getter into the base class.
- For BTS running in the main unit, pcu_sk_tmp_dir object is allocated
when first used (API pcu_socket_path()) instead of doing it in the
constructor. This is moved into OsmoBtsMainUnit
This is required to start osmo-pcu after osmo-bts is already setup and
activated. Otherwise osmo-pcu ends after connecting to socket with:
"pcu_l1_if.cpp:416 BTS not available"
In commit 329b6f4 pcu-socket path was moved to run inside the test run
dir to avoid issues between different tests creating a socket in the
However, it seems unix sockets paths are limited to 108 bytes (with Null
char included). In some cases, the run dir for a test can be quite long,
as it contains suite name, test name, etc. and the path can be longer
that the limit defined above.
In order to fix this issue, create a tmp dir using mkdtemp to ensure the
path to be used for the pcu-socket doesn't collide between different
instances of osmo-bts-trx.
Clean up of tmp dir and pcu socket is done inside the cleanup() method
called by suite.py.
method pcu_socket_path() is added to help with new implementation, and
it will be used as well as a public API later soon to be used by OsmoPcu
Otherwise osmo-bts stores the socket file in /tmp. If an earlier
instance doesn't finish cleanly, the file is left there and a new
instance will fail to start because it cannot create a new socket file
in the same place.
Processes created have the scope of the test, so we should store
everything in a per-suite_run/per-test directory, otherwise everything
is stored in the same trial run_dir directory and it's really messy.
With the recent fix of the junit report related issues, another issue arose:
the 'with log.Origin' was changed to disallow __enter__ing an object twice to
fix problems, now still code would fail because it tries to do 'with' on the
same object twice. The only reason is to ensure that logging is associated with
a given object. Instead of complicating even more, implement differently.
Refactor logging to simplify use: drop the 'with Origin' style completely, and
instead use the python stack to determine which objects are created by which,
and which object to associate a log statement with.
The new way: we rely on the convention that each class instance has a local
'self' referencing the object instance. If we need to find an origin as a new
object's parent, or to associate a log message with, we traverse each stack
frame, fetching the first local 'self' object that is a log.Origin class
How to use:
Simply call log.log() anywhere, and it finds an Origin object to log for, from
the stack. Alternatively call self.log() for any Origin() object to skip the
Create classes as child class of log.Origin and make sure to call
super().__init__(category, name). This constructor will magically find a parent
Origin on the stack.
When an exception happens, we first escalate the exception up through call
scopes to where ever it is handled by log.log_exn(). This then finds an Origin
object in the traceback's stack frames, no need to nest in 'with' scopes.
Hence the 'with log.Origin' now "happens implicitly", we can write pure natural
python code, no more hassles with scope ordering.
Furthermore, any frame can place additional logging information in a frame by
calling log.ctx(). This is automatically inserted in the ancestry associated
with a log statement / exception.
The "Affero" nature makes sense for the Osmocom network components like
BSC, SGSN, etc. as they are typically operated to provide a network
For testing, this doesn't make so much sense as it is difficult to
imagine people creating a business out of offering to run test cases on
an end-to-end Osmocom GSM network. So let's drop the 'Affero' here.
All code is so far developed by sysmocom staff, so as Managing Director
of sysmocom I can effect such a license change unilaterally.
To start an MGCPGW, we so far need the BTS address in advance (should get fixed
at some point, but so far we do).
The sysmoBTS has a fixed IP address configured. The osmo-bts-trx so far always
uses 127.0.0.1 (should also be fixed at some point). Both now return this
address with the remote_addr() function.
This also replaces a SysmoBts.remote_addr member variable (which is not
sufficient because it is only populated during configure()).
A NITB is a BSC + MSC, and if a BTS talks to a NITB, it talks to the BSC part
of the NITB. Hence it makes more sense to name certain things 'bsc' instead of
'nitb', to prepare for a separate BSC process appearing soon.
Use it to set root user for SysmoBTS, otherwise if osmo-gsm-tester is
run by another user it will fail to connect
Clearly separate the kinds of BTS hardware the GSM tester knows ('type') from
the NITB's bts/type config item ('osmobsc_bts_type' -- not 'osmonitb_...' to
stay in tune with future developments: it is the libbsc that needs this).
For BTS hardware kinds, use the full name of the binary for osmo driven models:
osmo-bts-sysmo, osmo-bts-trx, osmo-bts-octphy.
I know that these commit messages aren't very good, but the code is not stable
yet, so I'm not bothering with details.
code bomb implementing the bulk of the osmo-gsm-tester