Commit Graph

573 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther 574e62f0f9 ms: Begin to refactor and be able to share functionality
Change-Id: I840af0396f08744ce8ee6a2967f880d5cb7f815f
2018-07-05 20:30:42 +00:00
Holger Hans Peter Freyther 94da045c20 ms: Attempt to stop all mobile/virtphy instances on exit
We leave mobile/virtphy running after the test. Attempt to gracefully
exit and kill all of them. I experimented with both os.setpgrp and the
prctl(PR_SET_DEATH_SIG) but that didn't improve the situation.

Change-Id: I6cec050db7d4c355fb6678b2d84309fbbe5587b3
2018-07-04 20:26:13 +00:00
Holger Hans Peter Freyther 0f0ebd85db ms: Make the outer variables configurable
Do the easy part for making these variables configurable.

Change-Id: If8bbedcf672f6481a12c30d3669564704063626c
2018-07-04 20:24:41 +00:00
Holger Hans Peter Freyther 89dbf6db21 ms: Remove debug left over for the test
Change-Id: I17aa97a99cb1b1f9205b3a951370fe5ad49ae3dc
2018-07-04 20:24:30 +00:00
Pau Espin c81e26504d hlr: Get hlr.sql from new path
As of osmo-hlr edca4f88a653cc688bc1c46611a9f0bc880637e2, hlr.sql file
has been moved to an sql subdir.

Change-Id: I1cbbe46edc6121476cd2422074a9f3cfc2d8e5ef
2018-07-03 11:56:07 +02:00
Holger Hans Peter Freyther 05895a912d ms: Use the new API to pass credentials to the event server
We are using the "autobind" feature of Linux to get a special
socket address. This allows us to have roughly 2^20 clients on
the system.

Change-Id: Ie9b9ac6267f40345baf7dbb3becaecf264a5df5f
2018-06-25 20:27:41 +00:00
Pau Espin 99efe820e4 ggsn: Bind VTY and CTRL ifaces to assigned ip addr
Change-Id: I26735a21cd53183dfe0a75e5bd24954d583c354f
2018-06-22 12:13:52 +02:00
Holger Hans Peter Freyther 5eb4f0e6a2 osmo_ms_driver: Use the two new config options for the mobile
Avoid being stuck in c7 state and use the c7-any-timeout with a low
value. Do not attempt to store SMS in the home directory (if they
are received).

Change-Id: I4bb59130a04852bc43af9ef3602b129f40e9e170
2018-06-06 19:19:54 +01:00
Pau Espin e523665e9c event_loop: Log parameters during wait timeout exception
Change-Id: I1cf104392bfd11ad263264738eb4d8fa60550a5d
2018-05-28 14:01:12 +02:00
Pau Espin 7f4807a4bc powersupply_sispm: Add port number to log name
This way it can easily be spotted which port is being triggered in case
someone wants to manually test it.

Change-Id: Ibd2c70170d97a786e37b6838b1ed6d4eb637ad8b
2018-05-28 13:04:42 +02:00
Pau Espin e974944496 osmo-bsc.cfg.tmpl: Remove unused nd recently removed option dest
This VTY cmd has been removed in osmo-bsc.git
68e4be9c845e25f53aea511b1c57340a9da5825c.

Change-Id: I48c0b8a7b2a0088887f1309efc40bcf1da0f1626
2018-05-28 13:04:42 +02:00
Pau Espin b1526b9979 Add option to expect bts/pcu failures and respawn its processes
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.

Change-Id: Ia2a7539f9fad457125ac9b60a52a52999e885ba8
2018-05-25 12:31:20 +02:00
Pau Espin 06ada458cf process: Move cleanup log inside cleanup method
Change-Id: I72ad453e9dc8340946d7e7d041643fe8ef97439f
2018-05-25 12:31:20 +02:00
Pau Espin 63f2d47b3e bsc: Add API to mock BSC RSL IP addr
Change-Id: I9ca67964e656943b50967a27a88054fd3e484672
2018-05-25 12:31:20 +02:00
Pau Espin 58cd83c3ec templates: osmo-bts: Use BTS assigned IP addr to bind CTRL and VTY iface
Change-Id: Ib1c3022a6c531ef8c6a5ba31927762806abc37ac
2018-05-25 12:31:20 +02:00
Pau Espin 878b2c6619 testenv: Provide tests with access to process module
Some tests may want to start/stop/manages processes themselves. By using
the process module from osmo-gsm-tester, we make that possible easily,
providing with useful features such as requesting a suite to stop it on
cleanup.

Change-Id: I8e018107cbec81299ec2228bfff933fb3b0bb6cd
2018-05-18 15:59:06 +02:00
Pau Espin f32c41519e util: Fix unloading of suite lib import path
Change-Id: Iac81151f5baec092a3d15bbe6541b5bc007e6a03
2018-05-14 15:34:40 +02:00
Pau Espin 155a355e01 Unload suite local modules after suite exit to avoid collisions
Since sys.path is modified idynamically to load modules from "lib" subdir of each suite, from python env point of view all those modules share a namespace. As a result, there can be name collisions.

If a name collision appears (eg test1 loads "testlib.py" and test2
afterwards also loads its own "testlib.py"), then python interpreter
thinks the testlib.py module is already loaded, so test2 ends up using
"testlib.py" from test1.

The way to solve this is to make suite local
modules to live only through the scope of the suite, and unload the
modules once the suite is finished.

Change-Id: I4efe815f85bc4ec2ca91aa9c2d3a369048f21571
2018-05-09 11:24:25 +02:00
Pau Espin 7e02d20b46 suite: Set suite subdir lib part of syspath so tests can import their own modules
Change-Id: I3307c3ab314bb7a88d3c22c7c270c9f05fe6e03e
2018-05-08 15:28:48 +02:00
Pau Espin 39df7f4668 bts: Allow setting amount of TRX and timeslot in cfg and from test at runtime
The num_trx attribute for a given BTS states the number of TRX to be
used by that BTS. If more than num_trx are configured in trx_list in the
cfg file, then only up to num_trx are taken into account. If a num_trx
value higher than max_trx is specified throuygh config file or at
runtime by the test, an exception is raised explaining the issue.

The num/max_trx attributes are overlayed along the config levels
(generic -> bsc_bts -> specific bts-type -> specific resource object).
This way we can specify a long list of trx+timeslot config in the
generic config (bsc_bts), and tune for each model and specific BTS which
is the desired default number of TRX, as well as the maximum supported
per type.

Change-Id: I7f46eaf7a16f03268653299c93600c0443f691ac
2018-05-08 14:55:12 +02:00
Pau Espin e699912a23 bts: Move conf_for_bsc_prepare from bts_osmo to bts
nanobts inherits directly from bts.Bts, so we need to move
conf_for_bsc_prepare there to make nanobts work again.

Fixes: 530681fd86
Change-Id: I4305eefb4056ed7614118532e271efe780f4a87f
2018-05-08 14:50:32 +02:00
Pau Espin e519462d60 bts: Pass defaults config name at construct time
It will be needed later at construction time when resolving the num of
trx.

Change-Id: I2c6a46ead14010f714897ea178917327215823e7
2018-05-07 13:37:02 +02:00
Pau Espin 530681fd86 bts: Refactor conf_for_bsc_osmo
Move duplicated code into a method in the superclass.

Change-Id: Ie27932f94142f667c3fb8c054b77e04afa0d5cbb
2018-05-07 11:20:23 +02:00
Pau Espin c9b6376796 Check physical channel configs
Change-Id: I5894678e0d6f306173cc550dd6806a7d6f8a4c11
2018-05-07 11:20:22 +02:00
Pau Espin 7d4bdf2daf bts_osmotrx: Don't use binary name as inst name
Change-Id: Iee20738f2aa750aa9035a9e54ad667d8753ea12e
2018-05-07 11:00:30 +02:00
Pau Espin 553eda638c osmo-trx binary is now called osmo-trx-uhd
Change-Id: Ibf111ba89b24964127b9c1db7102953e1dba3181
2018-05-07 00:47:40 +02:00
Pau Espin ccb1bc686d modem: Catch exception: call removed while waiting to become active
This can happen while in a test we use:
wait(ms_mo.call_is_active, mo_cid)

And then answer fails for whatever reason, after a timeout ofono will
remove the call object:
/sierra_2: DBG: 'org.ofono.VoiceCallManager'.CallRemoved() -> /sierra_2/voicecall01

As a result, during next call o call_is_active() will try to get the
call object, but it doesn't exist anymore and an exception will be
created in method call_state during call to systembus_get().

Change-Id: I02b7e76425754372756493761819f18f1e3106c1
2018-04-22 14:35:33 +02:00
Pau Espin b6ab1da0af event_loop: Avoid leaking active timeouts on poll exception
It was spotted that when an error ocurred during poll generating an
exception to finish the test (osmo-msc ended prematurely), then the
active wait() condition was kept being checked for later tests, making
all followup tests fail.

That's because in case of exception we were not making sure the timeout
is removed and it kept firing forever.

Change-Id: I5c93cd67b2b83c0ecee96fbc6c4200b419bdf73f
2018-04-07 17:27:54 +02:00
Holger Hans Peter Freyther c490cdeebd ms: Add a main function to start all of it
Add a main file to start everything. All parameters need to
be made configurable. Composition of testcase and IMSI ranges
need to be configurable as well. This is left for future
commits. Right now it can execute a single UL test.

Start with:
export PATH=../osmocom-bb/src/host/layer23/src/mobile:$PATH
export PATH=../osmocom-bb/src/host/virt_phy/src/:$PATH
export PYTHONPATH=$PWD/src

python3 -mosmo_ms_driver

Change-Id: I58c938500a067eebb213750e56d8bf4d8af43df2
2018-04-04 15:35:12 +01:00
Holger Hans Peter Freyther 30cc021af5 ms: Add a first test to use all parts of the system
This is an interim solution but is bringing all parts together.
We will need to:

 * Abstract this into a base class
 * Be able to mix different tests without interfering with each
   other (e.g. 10k LU tests, 2k SMS sending)
 * The event loop will need to handle multiple timers/timeouts
 * Stats printing should print more information and test pass/fail
 * The test should quit early if everything has already passed

Change-Id: Id3277ed0f0f9ee734569bedd4752564eb68c9cfd
2018-04-04 15:35:12 +01:00
Holger Hans Peter Freyther ff19a5e7c2 ms: Create a starter for virtphy and mobile application
In the long run we might not want to start the virtphy but
for now virtphy+mobile belong together. Start virtphy first
as mobile will not handle a missing socket gracefully.

Change-Id: I5c6d742842d7f3e0a1858436ef3f8634d8c0582d
2018-04-04 15:35:12 +01:00
Holger Hans Peter Freyther 6af1c18b17 ms: Create template for the osmocom-bb mobile application
Change-Id: I9296f42edfab57762f8dd317d63231298cda5430
2018-04-04 15:35:12 +01:00
Holger Hans Peter Freyther 28bcaf0f2c ms: Lua part of location update testing
The lua part to start the MS and then signal the first
successful Location Update.

Change-Id: Ica5aa0c2f86d0e5d8a2bc4dc0652de18762dd156
2018-04-04 15:35:12 +01:00
Holger Hans Peter Freyther 4a62bb0086 ms: Add lua script support utilities
Add a JSON encoder and a small module to sent registration and
other events per unix datagram socket.

json.lua fetched using:
$ wget -O src/osmo_ms_driver/lua/json.lua \
https://raw.githubusercontent.com/rxi/json.lua/master/json.lua

Change-Id: I43ae84a944c7f33e41d5de0880d4aaab3378809b
2018-04-04 15:35:12 +01:00
Holger Hans Peter Freyther e7ae51fcaa ms: Create an event server to handle Unix datagram messages
Create an EventServer that will create a unix domain socket and
dispatch incoming datagram messages. The lua remotes are not
passing credentials so this is a one way communication channel
for now. Tests can register to handle the message.

Change-Id: Ida97c570e8e741410f2dba4a231a8058ca96da25
2018-04-04 15:35:11 +01:00
Holger Hans Peter Freyther b7749a72b4 ms: Create a simple epoll (or kqueue) based event loop
Create a C-like single process event loop. It could be powered by
select/epoll or kqueue. It should scale to many open fds but we
will not have that many.

Change-Id: Iea06f33870cab9f21e9a1a1feb9758467343dd29
2018-04-04 15:35:11 +01:00
Holger Hans Peter Freyther 38adaa96bf ms: Create a cumulative distribution function class
We are using the CDF to decide which percentage of the jobs should
be running at a given point. The x-axis is time and the y-axis the
percentage of how many jobs should be running.

There are three functions to do this. The first one is a constant
which would result in everything being started right now, one to
start them linearly and the last (formula from Qt/3rdparty) to first
accelerate and decelerate slowly.

Change-Id: I9e3064f4c3c4c7af5d3491f850090516e541f4d3
2018-04-04 15:34:09 +01:00
Pau Espin 48fce86b3e nanobts: Attempt at fixing race condition using ipaccess-config after power up
It seems there's a period of time in between the nanoBTS starts
announcing itself and it can actually be managed by the BSC
(ipaccess-config in this case). If ipaccess-config is called quickly
after nanoBTS it first announced, its TCP conn will be rejected with a
TCO RST, and ipaccess-config will fail. Let's see if waiting a few
seconds is enough to have this working more reliably.

Change-Id: Iec8adb2cd13d808a6ca1843dc95b81bd1a97d1c0
2018-04-04 12:48:26 +02:00
Pau Espin 9a4631c789 Drop event_loop global functions and import MainLoop
Take the chance to identify and drop modules importing event_loop but
not using it.

Change-Id: Ifa1940cd00138ebc72fbcfd45a0e28246f7a5ed9
2018-04-04 12:38:09 +02:00
Pau Espin bf176e420e event_loop: Use glib as mainloop impl and move modem to use event_loop
Several benefits:
- We can add APIs to poll on fds in the future (for smpp socket for
  instance) instead of using busy polling.
- During wait(), we now block in the glib mainloop instead of sleeping
  0.1 secs and not handling events during that time.
- We remove glib mainloop specific bits from modem.py

Change-Id: I8c3bc44bbe443703077110cdc67207e9cbb43767
2018-04-04 12:38:08 +02:00
Pau Espin 2c0ae6288d templates: osmo-bsc: Remove no longer available cfgs
osmo-bsc c74a5616bf1c77ac40ddd92f4927dca7a1b45bc8 removed these cfg
options as they are dead code.

Change-Id: I2fb63d31d5d7424b48ed2cfc694d09db072db485
2018-04-03 00:38:18 +02:00
Pau Espin fef9c1c5cf nanobts: Add support to run nanobts on the 900 band
Change-Id: I13b494630ea835f4bed38ccc77f6a4d5e18326af
2018-03-27 19:20:47 +02:00
Pau Espin 05a838e259 schema: Accept band GSM-900
Change-Id: I274c3010f33776b2967ee01de027c44b794cc5d4
2018-03-27 19:15:41 +02:00
Pau Espin a238ed9931 nanobts: Bind to specific addr instead of specific iface
This way root access is not required.

Change-Id: I02f6fc9e1cb1ea1e1d950eafe22c231a18100f98
2018-03-27 14:51:51 +02:00
Pau Espin 1b28a584ed Introduce ip.access nanobts support
Change-Id: Ibaea025b3a503dfe897d36701234445de6d49f82
2018-03-15 19:54:42 +01:00
Pau Espin 19c508c304 Introduce PowerSupply interface and PowerSupplySispm
File powersupply.py defines the interface to be used by child classes
implementing it. It also provides helpers to allocate a child class
based on configuration provided ('type' field).

File powersupply_sispm.py is an implementation using pysispm [1], as it's
the one used to control the programmable power socket we have right now.

This kind of class will be used in later commits by Nanobts class, as we
want to poweroff the Nanobts completelly when not in use.

Using it requires the following extra dependencies:
$ apt-get install python3-usb
$ pip3 install pysispm

Related: OS#3040

[1] https://github.com/xypron/pysispm

Change-Id: I981c260eca1a61657147e6d83b4226618088223c
2018-03-15 19:54:36 +01:00
Pau Espin 651cdc9b0f pcu.py: Introduce PcuDummy class
It will be used in later commits by BTS without proper PCU control such
as NanoBts.

Change-Id: I37ba38f7d81134e5f0ca28fa684fdb09c753bb04
2018-03-15 11:29:35 +01:00
Pau Espin 52ad3a66d2 Create Bts abstract class and make OsmoBts inherit from it
This base class will be used to describe the required accessors for all
BTS objects, be it an osmocom BTS or not.

It is introduced in this commit and will be further used in the future
when adding a NanoBts object.

Change-Id: Ic13133e61abda73a8b507c1a1bd7b98c677460f9
2018-03-15 11:29:35 +01:00
Pau Espin 4fbdc35e95 bts_osmo.py: ready_for_pcu is of public access from tests, move it accordingly
Change-Id: Ie8978854404897ae5de7e3100d55d86c7a5c1df1
2018-03-15 11:29:34 +01:00
Pau Espin 150abb48d0 Create Pcu abstract class and make OsmoPcu inherit from it
This base class will be used to describe the required accessors for all
PCU objects.

It is introduced in this commit and will be further used in the future
when adding a Dummy PCU object which will be used by NanoBts object.

Change-Id: Ia3fd4551d1f2932362f99f7d44d65f8ae4fd1979
2018-03-15 11:29:34 +01:00
Pau Espin f8d12196f0 modem: workaround ofono crash
Since commit bfd0b2310c, the IMSI is
retreived from ofono. To get the IMSI, the modme must be powered ON
previously. The imsi() method is called before calling connect() in
order to set up the IMSI in the HLR. As a result, the following
behaviour occurs:
- Powered=true (in imsi())
- SimManager.GetProperties() (several of them)
- Powered=false (power_cycle() in connect()

It seems powering off the modem immediately after using the SIM service
makes ofono crash. Proof of it is that crashes were seen mainly on tests
using only 1 MS, in which we don't spend that much time between
SimManager.GetProperties() and Powered=false for the same modem.

Let's workaround the crash for now increasing the time between using the
SIM services and powering the modem off.

Related: OS#3064

Change-Id: Ief052cac5a862d6ef9391d40c294ba017387506c
2018-03-14 19:20:07 +01:00
Pau Espin bfd0b2310c modem: get IMSI from ofono
There's no need to specify the IMSI manually in resource config
and it's also prone to errors. Let's take it from ofono.
Add a 'sim' feature to allow modem to auto-discover it,
otherwise if not supported leave that feature out of the config for that
modem and an imsi can still be manually providen.

Change-Id: I20f9e8d97775293925205e4ea576d814214bf1a8
2018-03-13 18:32:59 +01:00
Pau Espin edcc8d2624 osmo-trx: Add cfg template
Since commit 3da1f8352e337fb032bf7a58c2909d3ba918e237, osmo-trx requires
a cfg file to start successfully.

Change-Id: I8f0e0d0a9fa849f41c3cccc4059431f62f956eac
2018-03-04 20:17:26 +01:00
Pau Espin 86ea02f305 osmo-msc: Use osmo-mgw instead of osmo-bsc_mgcp
osmo-msc now requires osmo-mgw and it's not expected to work properly
anymore with old mgcp code.

Change-Id: I93033f7b6133a4914f12f37511ad870b3dea3201
2018-02-26 12:14:48 +01:00
Pau Espin 2c48c34998 pcap_recorder: log printing pcap file name as dbg
The log message is quite long and makes it difficult to read the log
even with debug disabled.

Change-Id: I593c0ce02bf7a3a9d26cf1fcc7d523a313cb72eb
2018-02-23 17:25:41 +01:00
Pau Espin e25cf04aeb modem: Identify modems by sysfs path instead of ofono dbus path
ofono dbus paths are non-deterministic and can change over time for a
given modem. For instance when ofono is restartd or if a modem crashes
and the object is destroyed and re-announced by udev.

Requires at least ofono 1df92289d4e09a1e2db0b189b5153a4c238f98f1, which
implemented the feature to export the sysfs path to modem properties.

Related: OS#2509

Change-Id: Ibc45a196abadded2706dc9d57b6a3a796b43a201
2018-02-23 17:14:37 +01:00
Pau Espin cdac297b89 modem: Remove ctx after deactivating it
Change-Id: Ib0e2a8ae8d9885fa44c9cc1f7dc7c7948abd683c
2018-02-16 15:14:32 +01:00
Pau Espin b05aa3cea2 modem: deactive_context: Log when context is successfully deactivated
Change-Id: Ibe40a954aa4548e54b48c444014d7dbd2da9d956
2018-02-16 15:03:50 +01:00
Pau Espin b17295bb21 templates: osmo-msc: Remove unused option auth policy
Commit osmo-msc 098aa71e83a86200a18088927b4753909f5ed518 removes this
option from default configuration as it is really not used in osmo-msc,
it comes from osmo-nitb times.

Change-Id: I928379ebabfc776f33b9f345d92a7a4a533fe25f
2018-02-14 11:26:43 +01:00
Pau Espin 342694150e templates: osmo-msc: Remove unused option reject cause
Commit osmo-msc 27b40c601c41fde70446ad553629494234c07662 removes this
option from default configuration as it is really not used in osmo-msc,
it comes from osmo-nitb times.

Change-Id: Iac1948113514414e7573f3bbfb3ce82e6c49adb6
2018-02-14 11:26:11 +01:00
Pau Espin 263dd3b600 modem: deactivate_context: Fix dbg message
Change-Id: Ib3cb72ebcbfbf53693a2d76ca1592ef7d394dd87
2018-02-13 22:27:46 +01:00
Holger Hans Peter Freyther 257ee10967 log: Use sys._getframe() to avoid stat(2) calls
The Osmo MS driver is launching many many processes and I would
like to use the logging framework for the code as well.
Unfortunately the inspect/traceback code will use a linecache which
will execute stat(2) on one or more python files.

Related: OS#2927
Change-Id: I8f6bacadcf74d3aa25db1e1f41644f64aa19cf92
2018-02-13 10:49:00 +00:00
Harald Welte ab4a1f7074 osmo-bsc.cfg.tmpl: Remove bogus VTY commands
There are plenty of VTY commands that were inherited from OsmoNITB,
but which make no sense in a BSC.  Upstream OsmoBSC has removed them in
change-ids Ib626f43a3a3ca69dfc127afe5832eb58f7fb6a38,
c499e5c62e9bef0db219e4658ffeb3292d6e6a5b and
8311a81bae85618302273c3f769275893161a7d7

Change-Id: I79ff48983d9cb7b875c1859870d5e3bce2c0ef22
2017-12-19 18:55:26 +01:00
Neels Hofmeyr 0af893c79d osmo_hlr.py: fix auth algo mapping, properly indicate COMP128v1
So far the resources.conf says we're using XOR, but we wrongly map 'xor' to 1,
which is actually comp128v1 in enum osmo_auth_algo from libosmocore (which
osmo-hlr uses to interpret the numbers from the hlr.db).

This explains why our "xor" tests are succeeding even though libosmocore
doesn't support XOR at all: we were using comp128v1 all the while.

Fix the auth algo mapping:
- define correct mappings, copying enum osmo_auth_algo, in util.py
- add a function to get the enum value from name, in util.py
- use this in osmo_hlr.py

Change subscriber_add() API to take the algorithm string instead of a number.
The number is libosmocore internal and we should not expose it within our API
beyond above dict. There are no callers using this parameter yet anyway.

Adjust resources.conf to indicate COMP128v1 which we are actually using and
which means we're still using algorithm number 1 after this change.

BTW, osmo-nitb uses the ctrl interface which interprets the names, so is not
vulnerable to mapping wrong numbers and needs no fix. (If osmo-hlr featured
similar CTRL, which it doesn't yet, this code could be more robust.)

Related: OS#2758
Change-Id: I7a6ce92468a6ae46136ad4f62381da261fd196c8
2017-12-18 02:28:58 +00:00
Pau Espin b05e36aa38 modem: activate_context: print protocol too in dbg log
Change-Id: I5c2df196b924bb0cf74aadabb4544ca1fecc1eba
2017-12-15 12:40:18 +01:00
Pau Espin 6641994d8d Set osmo-ggsn ipv6 link-local addr and enable ipv6 ctx activate test
osmo-ggsn requires a link-local IPv6 address to be added to the
tun interface, otherwise the apn will not be configured correctly and it
won't be able to allocate addresses from the ipv6 pool later on.
Some OS don't support autoconfiguring link-local IPv6 addresses when the
interface is brought up (some linux versions are known to fail at it).
This is the case for our Prod osmo-gsm-tester setup (running debian8
with kernel 3.16.51).

Make sure we configure correctly the interface by forcing osmo-ggsn to
set on the interface and use a specific IPv6 link-local address. This is
done by using the "ipv6 link-local" vty cmd in osmo-ggsn.

After this modification, we can re-enable ipv6 gprs context creation as
it will work in Prod setup.

Related: OS#2746

Change-Id: Ib291c02a3c57a4189f9c4b1b856109be97ad2a34
2017-12-15 12:08:47 +01:00
Pau Espin c1b3278af8 bts_osmo: Use correct parameters for create_pcu
Commit c9817a50ff moved code from
different BTS into a shared base class, and create_pcu method was
created to be implemented by subclasses to get a new pcu object.
However, parameters where wrongly copied over from pcu() method during
refactoring. create_pcu() has no parameters.

Change-Id: I1e95f2e658a870f86dd9d9d25f446b8efa4107a4
2017-12-15 11:49:04 +01:00
Pau Espin 81aaeefb7b cosmetic: bts_sysmo: Sort members according to scope
Change-Id: Ifc19b34660cc8d20b8db2dcf245eeb2173cd7a6a
2017-12-14 19:18:58 +01:00
Pau Espin 2e54295bbf cosmetic: bts_osmotrx: Sort members according to scope
Change-Id: I2a0771331a98b377a79aa0770c753d04a1e88db1
2017-12-14 19:18:58 +01:00
Pau Espin 4b475be9d8 cosmetic: bts_octphy: Sort members according to scope
Change-Id: I42c19bf6f5a2f9d13d60e6ce8f1bbc1cad159b4b
2017-12-14 19:18:57 +01:00
Pau Espin c9817a50ff Create bts abstract classes to avoid code duplication and ease development
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:
log.Origin<-OsmoBts<-OsmoBtsMainUnit<-OsmoBtsOctphy
log.Origin<-OsmoBts<-OsmoBtsMainUnit<-OsmoBtsTrx
log.Origin<-OsmoBts<-OsmoBtsSysmo

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

Change-Id: I86db35a7f2497d37360b2c56affa8bf6bf704ee2
2017-12-14 19:18:50 +01:00
Pau Espin f0b8e37f32 osmo-ggsn: set cap CAP_NET_ADMIN to be able to set up tun devices
This is a temporary workaround to be able to test gprs signalling until
we set up all required bits to run osmo-ggsn in its own namespace.

Change-Id: I0a3ce16218f0274e0be09bbf2881bc21636acdf9
2017-12-13 16:08:38 +01:00
Pau Espin 7bd7103736 OsmoBsc: Introduce bts_is_connected API
This can be used by tests to wait until bts is successfully connected to
BSC.

Change-Id: I2dc2be7fd802e0e77a5e6bf23c9ca03d4c4b28f2
2017-12-13 14:09:19 +00:00
Pau Espin c859eb37ad OsmoNitb: Introduce bts_is_connected API
This can be used by tests to wait until bts is successfully connected to
NITB.

Change-Id: Idb9b7087e38f638d8b8acbad6dd8ab4218746832
2017-12-13 14:09:19 +00:00
Pau Espin 7a4c17b661 bts_octphy: Use OsmoPcu instead of OsmoPcuSysmo
Change-Id: I81751d774ec1f61b01ccef6c21c9d38807d5d1fc
2017-12-05 17:05:27 +01:00
Pau Espin de899619cf modem: Add minimal GPRS support
Up to this point we can test signalling plane: attaching to GPRS network and activating a
context.

Data plane (sending IP packets through the network) is still not
implemented as it requires setting up the network interface provided by
ofono as well as routing, and most probably move osmo-ggsn to its own
network namespace.

Change-Id: I605ba1bb1103a045a9b5d0e7215c05dfc1fe575f
2017-12-05 15:06:52 +01:00
Pau Espin 8a3a7b5146 bts_*: Add incrementing bvci and rac values
Change-Id: Ie65d7d33322c775a1040b5c81f367d882a7c2c5b
2017-12-05 15:06:52 +01:00
Pau Espin 05314b4633 OsmoBtsOctphy: Integrate with OsmoPcu and OsmoSgsn
Change-Id: I54780971d711d47b23976dd044a4a53134dd4299
2017-12-05 15:06:52 +01:00
Pau Espin 5936d8f4b1 OsmoBtsTrx: Integrate with OsmoPcu and OsmoSgsn
Change-Id: I777835345355538a945599fb088630af63dc9140
2017-12-05 15:06:51 +01:00
Pau Espin ce35d91592 OsmoPcuSysmo: Integrate with Sysmobts and OsmoSgsn
Change-Id: I01485c5d74e5fe62d0ffea9eb1fad29041426eef
2017-12-05 13:36:46 +00:00
Pau Espin e85f5c9009 Add OsmoPcu class
Change-Id: I04d8ed5e02b090d07e91669df44ce354bc6ee749
2017-12-05 12:16:31 +01:00
Pau Espin 99f79294d3 Add class OsmoPcuSysmo
Change-Id: I6fbb71df1ad36e5d7eb02f3fdd7987a178d523d3
2017-12-05 12:12:59 +01:00
Pau Espin d0a01117df bts_*: Add ready_for_pcu API
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"

Change-Id: I7209589f60bda63094336e417638906be5e273c4
2017-12-05 11:09:10 +00:00
Pau Espin 4796b359bd Add OsmoSgsn class
Change-Id: Iec370a444998c632b3615ad1a6d6f67e64e2bfeb
2017-12-05 11:09:10 +00:00
Pau Espin 30ceb5c9a2 Add OsmoGgsn class
Change-Id: I0eed70838e4e8656c4bc1337df70e631a10d69c7
2017-12-05 11:09:10 +00:00
Pau Espin f7f0636f4d resource: next_lac: Avoid using LAC 0
Change-Id: I6c1bef81040e2c6210177f04743e7acf3eb9ad8f
2017-12-05 11:09:10 +00:00
Pau Espin 0b9d0918cf osmo-bsc: Remove token cmd from config
In 3b18044859df15ffd2ad4c3e5c3d2c94a2923eb9 this command
has been dropped and is no longer recognized.

Change-Id: I98546e36f8c809e8066fe0cc0d80d0ae3276473f
2017-11-30 11:58:25 +01:00
Pau Espin b87c6bd0e7 osmo-bsc: Remove authentication cmd from config
authentication is firmly VLR land and must go away from bsc. That option
is a leftover from nitb. It will be removed at some point.

Change-Id: I3bb4189b33173245116018e437e113c6c1226639
2017-11-29 14:31:32 +01:00
Pau Espin e7ec9089ab osmo-bsc: Remove 'auth policy' cmd from config
As of osmo-bsc ad47f7108aff5438bd2c6f7c0e898f4aa3b66fbe, this command
has been dropped and is no longer recognized.

Change-Id: Id97074195f045e6872a1a7030671a06259c9ec31
2017-11-29 14:28:38 +01:00
Pau Espin 7aef3861f4 modem: Move power off sequence to separate method
Also make sure we power off the modem during cleanup, to make sure we
set it offline (and in the future, we also detach GPRS).

Change-Id: I47845f36864d494be474fdd447a4e9e0cbed1abd
2017-11-23 14:07:50 +01:00
Pau Espin e0f498627c modem: Abstract the list of required ofono interfaces
* We want to add more interfaces to this list when we add more features
(such as waiting for ConnectionManager if we want to use GPRS).

* We want to require some ifaces only if we are planning to use those
features in osmo-gsm-tester (driven by config features attribute set to
the modem in resources.conf).

* Previous usage during shutdown was wrong, as it was waiting for any of
them to be down to continue instead of waiting for all of them to be
down.

Change-Id: I56a289360018aa56fe25b3dd328ffe9194b65f6b
2017-11-23 12:45:05 +01:00
Pau Espin 5bbb3003cb hlr: Rename conf_for API
The HLR has more clients than the MSC, for instance the SGSN.

Change-Id: Idd5de7a828f0a627f69876a990f2ac1af0b578aa
2017-11-23 11:09:38 +01:00
Pau Espin 9cc1d082ea Configure PcapRecorder to record on any iface
Before this commit, tcpdump was instructed to listen only on the
interface which had the IP assigned. However, local processes connecting
to that IP are actually sending packets through the loopback interface.
As we are not listening on it, all those packets are not being recorded.
Let's record on all interfaces instead and rely on the ip filtering to
record only the interesting packets.

Change-Id: I205786d5168acd66cf3427154d8bf307c5c58da5
2017-11-20 17:40:27 +01:00
Pau Espin 1e1d381a59 Configure bsc and msc to connect to the specific stp provided in test
Change-Id: I89deaa71956131766fec8fcc3bc7381ebb0e187f
2017-11-20 16:05:43 +00:00
Pau Espin fd5de3d2ca Move Test class to its own test.py module
Make the code more reachable for newcomers, as well as more organized
for people who work a lot with it.

SuiteRun in suite.py is already quite big, and having the Test class in
there make it unnecessarily more big, and makes it difficult to find
stuff.

At the same time, having a test.py which does actually not contain the
Test class but other stuff, makes it even more confusing.

Change-Id: I9c8d67f598466ba52a4827ff77027b9eae85929a
2017-11-17 17:12:15 +01:00
Pau Espin dfe38ad239 Rename test module to testenv and update references
Preparation to move current Test class into its own module test from
suite module.

Change-Id: I520bd046cb09042b5567d967f951f050e4e02e85
2017-11-17 17:07:51 +01:00
Pau Espin 24c5de89c9 modem, process: Remove unneeded test import
Change-Id: Icd8cbb753aafdef49bde56bc5b0294f82133887c
2017-11-12 13:19:24 +00:00
Pau Espin a02952a441 suite: Remove unneeded import copy
Change-Id: I7a7231439ce42d51e1b2ab413f64e217aaa8d145
2017-11-12 13:19:24 +00:00
Pau Espin ccc1ebc052 event_loop: Remove unneeded commented import line and explanation
Those lines come most probably from copy+paste using test.py header when
creating the file.

Change-Id: I7854d96de00124324bfbac8960e18ec30aa21296
2017-11-12 13:19:23 +00:00
Pau Espin 41dabb3627 suite: Separate better internal imports and the ones aimed at tests
Change-Id: Ib6f6fa561fbc4ed0d0f255ad54fdfdd823de1a8a
2017-11-12 13:19:23 +00:00
Pau Espin 99b0e0e609 Remove unused file bts_model.py
Change-Id: If24b7dafb659d45bc13f4d624212d6c266c1b522
2017-11-10 21:28:17 +00:00
Pau Espin 386b78d8b0 Require OsmoMgw in OsmoBsc and update tests
Since Change-Id Ia2882b7ca31a3219c676986e85045fa08a425d7a, osmo-bsc
uses osmo-mgw and utilizes libosmo-mgcp-client to talk to it.

This commit fixes latest constant failures in voice suite.

Change-Id: I1dadd781a357fce33e7bde55e4bcbdaeb4633359
2017-11-09 13:06:03 +01:00
Pau Espin e9d4af8903 Introduce OsmoMgw class (osmo-mgw)
Change-Id: I6081ceaddcde748ada8b124a29432d498a9cbdac
2017-11-09 13:01:00 +01:00
Pau Espin 9f59b82598 modem: Fallback to automatic registration if manual one is not supported by modem
Some modems such as the gobi 2000 doesn't support the Register() method
in /operator path. If the method returns a NotSupported error, fallback
to automatic registration.

Change-Id: Ibc322317db634a5380573de88a56eb53fd92e67b
2017-11-08 10:12:07 +00:00
Pau Espin 9b67021b98 modem: Improve handling of errors in dbus_call_dismiss_error
Change-Id: I25d08c74608c3ec5c6e46c36c161e777b2ed337a
2017-11-08 10:12:07 +00:00
Pau Espin 6cdd2fdf61 Rename module ofono_client as modem
Change-Id: I43b51ae937d87d6d4e18caea59f9366e2e28c9f2
2017-11-08 10:12:07 +00:00
Pau Espin 0bcc074caf test.py: Remove unused parameter ofono_client in setup()
Change-Id: Ib8983421a7ca5f94fe1363768a12fff63c1fc64a
2017-11-08 10:12:07 +00:00
Pau Espin 1f5ae7d3b0 osmo-msc: Use mgw instead of mgcpgw in cfg
As of osmo-mgw 87203f2a3746d708f85ee75d978e2821bda58e6d, mgcpw commands
are deprectated.

Change-Id: Ib0220c9f7f6262234712c3195dda0e076c7dd390
2017-11-08 10:11:28 +00:00
Pau Espin 4ccce7c963 Use unique incrementing value for BTS CellId
Change-Id: If4559b945a3e71f3a36fd7ac760cb094278f6b39
2017-11-08 10:05:41 +00:00
Pau Espin 5e0c251c6c Use unique incrementing value for BTS LAC
Change-Id: I9f864bac05e39ec2fc305f774194799c3d8fe1b0
2017-11-08 10:05:41 +00:00
Pau Espin 96d6b6ce22 resource: Refactor next_msisdn to be more generic
The logic in next_msisdn can be later re-used for other purposes, such
as getting different location area codes for BTS.

Change-Id: Ib04a34892aacd7e71f8f5961e7339add583f73f2
2017-11-08 10:05:40 +00:00
Pau Espin daed4471ba Add support for osmo-bts-octphy
Specific parts for this class:
- Runs osmo-bts-octphy binary, that requires CAP_NET_RAW capability
because it uses an AF_PACKET socket.
- As a consequence, it must use the previously added APIs to set the
capability and modify the RPATH of the binary before launching it. These
APIs require extra host setup and installed dependencies that will be
documented soon in osmo-gsm-tester manual.
- A num_trx() helper method is added because the binary requires that
parameter.
- A allocate_phy_instances() is added to help build/fill the conf
dictionary to be used in the tmpl to be able to easily set up trx, phy
and insances.

A config to use a osmo-bts-octphy at full power is used (4 trx) is added
in this commit to show how can it be configured. However our
current license only has support to use 1 TRX, and so next commit drops
most configurations to simplify the setup to use only 1 TRX.

Change-Id: Ia350964fa539083bb68d439cad0caa8fdf85d297
2017-11-06 17:43:01 +00:00
Pau Espin ed6d4457e1 util: Add change_elf_rpath API
Linux dynamic loader avoids loading shared libraries from env vars such
as LD_LIBRALY_PATH for ELF binaries which have capabilitiy flags enabled
for security reasons. For these binaries, we modify the RPATH of the ELF
header to tell the loader where to find the libraries.

Process class from process module is imported inside the method after
module initialization in order to avoid circular dependency of relative
imports, which is only available since python 3.5.

Change-Id: Ibc356957fb3dbcf9947bfe96b671ec8c7ede33ff
2017-11-06 17:43:01 +00:00
Pau Espin 33c154bf32 util: Add setcap_net_raw API
Some binaries such as osmo-bts-ocpty require specific capabilities, and
we need to provide them in case osmo-gsm-tester is not run as root.

Process class from process module is imported inside the method after
module initialization in order to avoid circular dependency of relative
imports, which is only available since python 3.5.

Change-Id: If3eb24461c02173dc80837a4cc83f9f2420c7816
2017-11-06 17:43:01 +00:00
Pau Espin 2753204d3b config: Fix crash in overlay()
if len(src) > len(dest), then we hit an out-of-bounds crash accessing dest[i].

It is totally valid to have src and dest with different lens, as you may
want to override only part of the list.

Change-Id: I4f8a191810e89a4081199edcb390fb3bb27ed42f
2017-11-06 17:43:01 +00:00
Pau Espin 03983aace2 Add minimal USSD support to test extension number
Change-Id: Ib19331f9c6476ac01bf729790dfd63c56de86a89
2017-11-06 17:44:41 +01:00
Pau Espin d71edd16c5 modem: Implement voice calls in modem and add voice suite
Change-Id: Ib402effc830db293f27a877658894e454a93a606
2017-10-17 12:13:25 +00:00
Pau Espin e685c62f90 modem: reset cancellable after cancelling dbus methods
I first wanted to use "reset" method, but according to [1]:
"The recommended practice is to drop the reference to a
cancellable after cancelling it, and let it die with the outstanding
async operations. You should create a fresh cancellable for further
async operations."

Pretty weird that in other parts of documentation it still says that it
can be used for concurrent events.

[1] https://developer.gnome.org/gio/2.54/GCancellable.html#g-cancellable-reset

Change-Id: I7392275620576fd0037be5b9d9f360a46a4f8312
2017-10-06 10:07:59 +00:00
Neels Hofmeyr 7fde99a544 fix osmo-stp.cfg: accept-asp-connections must be a child of listen m3ua
Change-Id: I266b129788b2caaec0f345f80a2c5eab0172bf97
2017-09-20 14:41:04 +02:00
Neels Hofmeyr f0635030c5 re-fix osmo-bts-trx config: 'osmotrx ip' must *not* be indented
The previous commit wrongly placed all of 'osmotrx' below 'instance 0', put the
'osmotrx ip' ones back in the parent (I3a48cda44b932b46f34f027ca88e3703b6f04bad
-- I should have known, the change Id ends in "bad").

The correct structure is:

	phy 0
	 osmotrx ip ...
	 instance 0
	  osmotrx rx-gain ...
	  osmotrx tx-attenuation ...

i.e. the 'osmotrx' command name exists on both the 'phy' parent level as well
as the 'instance' child level. (Argh, can this be more confusing? I assume we
will be seeing a continuous flow of users hitting this now.)

Change-Id: I7ef7ab3048266c1b2a4f6f33951f1305ec5f0ad6
2017-09-20 03:40:24 +02:00
Neels Hofmeyr 14089765c8 fix osmo-bts-trx config: 'osmotrx' must be indented in 'instance 0'
We hit this now because libosmocore has started strictly enforcing correct
indenting of child nodes. See I24cbb3f6de111f2d31110c3c484c066f1153aac9.

Change-Id: I3a48cda44b932b46f34f027ca88e3703b6f04bad
2017-09-20 03:03:36 +02:00
Pau Espin 4676cbd782 resource: Allow passing keyword args to NoResourceExn
Same code is already being used by log.Error exception.

This way we can use:
raise resource.NoResourceExn("No free arfcns in any of bands", bands=supported_bands)

And get:
osmo_gsm_tester.resource.NoResourceExn: No free arfcns in any of bands {bands=['GSM-850', 'GSM-900', 'GSM-1800', 'GSM-1900']}

Change-Id: Ic960ae8db5372b0a4640356f0b4820ed42477b46
2017-09-16 21:59:44 +02:00
Pau Espin ac18fd31e7 Add features attribute to modems
The idea behind this attribute is similar to the Features one in ofono:
To provide an easy-to-use list of features that a modem supports.

In osmo-gsm-tester this feature list can be used to create scenarios to
act as a filter for modems. For instance, if an sms related feature must
be tested, then a modem supporting sms features is required. This way
only modems supporting that feature are going to be selected for that
test when that scenario is used.

We provide our own list instead of dynamically using it for two reasons:
- Accessing the list from ofono means powering on + online the modem,
which requires using the modem before resource resolution is done.
- ofono may state that it has support for feature X, but it still
doesn't have all features required by osmo-gsm-tester or there is a bug
in some part of the feature which prevents it from being used for a
specific test.

Change-Id: I1634049f01859ae0310174892a96e204bb670bc1
2017-09-16 21:59:44 +02:00
Pau Espin 57497a6be9 Add cipher cfg param for modem and bts
This parameter is contains a list of supported encryption ciphers by the
modem or bts setting it. It is so far not directly/automatically used
inside osmo-gsm-tester code, but can be useful to create scenarios for
tests that require specific ciphering modes.
For instance, aoip_encryption suite contains tests that require a BTS and
a modem that supports a5 0 and a5 1, otherwise tests will fail.

Change-Id: Ic0e368843a6e58bd3eeef36d2c0a7501296f0f3e
2017-09-16 21:59:44 +02:00
Pau Espin abd556ab3d Use own format to specify encryption algorithm
... instead of using the one from from osmo vty directly.

This way we avoid having multiple word attribute value and we can skip
using quotes in the conf files.

Change-Id: I5265cc9990dd5e99dba1f6262b3a8c597a3e958d
2017-09-16 21:59:44 +02:00
Pau Espin 5847551640 resource: Handle lists correctly in item_matches
We want to handle lists in the same way as we handle them in combine().
Without this commit, reserve()->find() failed to match objects
containing dictionaries inside lists correctly (such as trx configs).

A few attributes are added to trx_list of some resources in
suite_test/resources.conf to show a case in which resource reservation
would fail without this patch. It failed because before this patch,
dictionaries inside lists are compared to be equal instead of being
compared element by element to see if one dictionary is a subset of the
other one (for each element in the lists).

Change-Id: I8588d5b788b9f74a9cc84b8bdcb049921788bb48
2017-09-16 19:51:33 +00:00
Pau Espin 43737dab90 config: Fix combination of lists
This commit fixes combination of resources containing lists.

For lists containing complex types, it has been decided to handle them
as sorted list, where position in list matters. In this case, combine is
called recursively for each element in dest and src sharing position in
the list, and assumes that if one list is shorter than the other, then
it has to be combined against empty set for that tye.
For instance this is useful when defining trx_list properties, where a
BTS can have a different amount of TRX but we may be interested in
restricting the first TRX and don't care about extra TRX.

For lists containing simple types (eg. integers or strings), we just want
to merge both lists and we only need to check if the value is already there,
ie. handle them as unsortered sets. This case won't work if we call combine
for each element of the list because for a simple case it will just end up
checking if a[i] == b[i].
This kind of operation for simple types is needed in later commits where
cipher attribute is introduced. Without this patch, having following 2
scenarios and trying them to use together "-s foosuite:cipher-a50+ciphera51"
will fail:

cipher_a50.conf:
  bts:
  - ciphers:
    - 'a5 0'

cipher_a51.conf
  bts:
  - ciphers:
    - 'a5 1'

ValueError: cannot combine dicts, conflicting items (values 'a5 0' and 'a5 1')

Change-Id: Ib7a38f10eb9de338a77bf1fa3afceb9df1532015
2017-09-16 19:51:33 +00:00
Pau Espin 0b30279c2f Replicate resources based on times attr before combine time
As suite.conf and scenarios need to match 1-to-1 in lists, it's important to
extend the dictionaries by replicating the objects with a 'times' values
higher than 1 in order to match the objects correctly.

Since dictionanries are expanded at combine time, there's no need to
expand them during reserve() time because they are already expanded.
As a result, this commit reworks the kind of schema applied in each
place (and takes the change to start validating scenario files, which
were neglected previously).

Two unit tests are added as a show case. Unfortunately output showing
scenario dictionaries needs to be ignored while verifying because it was
encountered that different versions of python print dictionary elements
in different order.

Change-Id: I25eb639c7e3cf3b4c67a205422808bffbdd791e6
2017-09-16 19:51:33 +00:00
Pau Espin b26f32a955 nominal_power and max_power_red attrs can now be set per resource
Before this commit, only max_power_red was specified and it could only
be used as a defaults and could not be set per object. Together with
nominal_power, it can be useful to be able to set them to different
values for different objects, as for example different osmo-bts-trx
objects can require different values.

Change-Id: I472742e98052cc39686d38c945be76d7f50eeebd
2017-09-16 19:51:32 +00:00
Pau Espin ebced95081 config: Fix variable reference before assigment
Change-Id: I1a1acd7b3e5ff96b09a9a8e2825fb864ead9e54b
2017-09-16 19:51:31 +00:00
Pau Espin 26050340e6 config: replicate_times: insert replicates in place
In the following suite.conf, position matters when matching against scenarios:

[suite.conf]
resources:
  bts:
  - type: sysmo
    times: 2
  - type: osmo-bts-trx
    times: 1

[scenario]
resources:
  bts:
  -
  - ip_addr: 1.2.3.4

In this case, for instance, we make it clear that we want the second
sysmo bts which has IP 1.2.3.4. With old behaviour, the replicated sysmo
would have been created at the end (3rd position), and the ip_addr would
match against the osmo-bts-trx BTS.

Change-Id: Id78e2326db964d5efb6648854b57d8addce4deb0
2017-09-16 19:51:30 +00:00
Pau Espin 802dfe5743 Move code to replicate dicts based on times attr to its own function
Change-Id: I26ddae2124813bfb63a7c97c466e056cd2ef991a
2017-09-16 19:51:30 +00:00
Pau Espin ead79ac97c resource: times is expected to be a non-zero positive integer
Change-Id: Ie9e313727053a411cec2f698c3bd654d27e8013f
2017-09-16 19:51:30 +00:00
Pau Espin fa9a6d39ab resource: ipa_unit_id is expected to be a positive integer
Change-Id: I26d7a4351089b73716d193496d7161bf3d9988bb
2017-09-16 19:51:29 +00:00
Pau Espin cfac993bf2 contrib: Build octphy osmo-bts variant and make it generic
This is a first step to add support for osmo-bts-octpy to
osmo-gsm-tester.
There's no point in building separate insts for different osmo-bts
variants which run on the main unit and which come from the same git
repository, this we make the osmo-bts-trx one generic to handle all
variants which fall into the description above.

Tested locally on my laptop that it builds susccessfully.

Once this patch is applied, jenkins jobs need to be adjusted:
- RnD: osmo-gsm-tester_manual-build-all
- Prod: osmo-gsm-tester_build-osmo-bts-trx (and rename it)

Change-Id: Ib8814e4ce49596b586990f20d7d625a719852e90
2017-09-15 09:59:00 +00:00
Pau Espin 6680ef2c3d modem: Fix race condition when connect() is called more than once
An issue was spotted recently in tests run in production which call
modem.connect() twice, first time to check that we are unable to connect
with a wrong KI, then that we can connect with the correct KI.

As there's no current easy way to wait for "rejected" signal, we
basically wait for some time before checking if we were unable to
connect. It seems that sometimes waiting for 30 seconds is not enough,
and then a scan() async method is still in progress when we decide to
call connect() again, which will powercycle the modem. If the scan()
method returns at that time, then we try to access interfaces of the
modem which are no longer available because the modem is powered off at
that time. This triggers an exception and test fails.

To correct way to fix this is to make sure we disable pending Scan()
dbus method before powercycling the modem and starting a new Scan()
method.

The sleep time is also increased to make sure we let enough time to
register. It seems it can take about 15 seconds to do a full scan, and
sometimes during first scan iteration the BTS is still not found,
probably because it's still starting.

Related: OS#2510

Change-Id: Ic4bb1c6b72c23cd860c33bee7851bca3d0ac0e1b
2017-09-14 09:33:28 +00:00
Neels Hofmeyr 936a81ec1a fix util.py/FileLock and lock_test
Do not pass os.O_TRUNC to open(), that immediately empties out the lock file.

Fix lock_test to be able to catch this error. So far things were happening too
fast to notice it.

Caught by running 'make check' on a main unit APU that has different timing
behavior.

Change-Id: I872a3d2548ac84097ac7acf13cb12c36822e076e
2017-09-14 01:52:32 +02:00
Pau Espin 32cab3f5c7 bts_osmotrx: Fix mkdtemp use in python < 3.5
We are currently seeing this issues in prod setup, which uses python
3.4:

  File "/home/jenkins/workspace/osmo-gsm-tester_run/osmo-gsm-tester/src/osmo_gsm_tester/bts_osmotrx.py", line 44, in __init__
    self.pcu_sk_tmp_dir = tempfile.mkdtemp(None, 'ogtpcusk', None)
  File "/usr/lib/python3.4/tempfile.py", line 432, in mkdtemp
    file = _os.path.join(dir, prefix + name + suffix)
TypeError: Can't convert 'NoneType' object to str implicitly

Acording to mkdtemp man in python3:
"Changed in version 3.5: suffix, prefix, and dir may now be supplied in
bytes in order to obtain a bytes return value. Prior to this, only str
was allowed. suffix and prefix now accept and default to None to cause
an appropriate default value to be used."

This issue went unnoticed because the RnD env is running debian 9, which
probably has python version >= 3.5.

Change-Id: If3226183fe21b4820149b1d03207193dc6f139e2
2017-09-13 22:21:10 +00:00
Pau Espin 15aae98cf0 Use tmpdir to create bts pcu-socket
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
same place.

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
classes.

Related: OS#2507

Change-Id: I0c53a0a3ccc5eb2823265fe14c0f7b8f4adb1038
2017-09-12 14:42:09 +00:00
Pau Espin 4e36f7c0c7 resource: Fix list comparison in item_matches
In following commits, cipher attribute containing a list of supported
ciphers is introdued in osmo-gsm-tester. While developing the feature,
it was found that resources containing lists are not being handled
correctly.

Previous implementation regarding lists in several ways:
- In the list coe path, both item and wanted_item are expected to be
lists. Python doesn't support to check for sublists using the "in"
operand.
- want_item basically contains the scenario dic, and item is each of the
items available as resource of a given type. Thus, we want to check that
item supports the subset of features requested by the scenario, ie. that
the list in the scenario is a subset of the ones in the3 item and not
the opposite.

The following failing scenario is going to be checked during "make check"
when the cipher attribute is added: BTS supporting cipher a50 and a51,
and scenario requesting a50 succeeds. If this commit is remove, the test
no longer passes, and it fails with:
osmo_gsm_tester.resource.NoResourceExn: No matching resource available for
bts = {'type': 'osmo-bts-sysmo', 'ciphers': ['a5 1']}

Change-Id: I27b372aa5906feac2843f24f5cdd0d9578d44b4d
2017-09-10 12:30:35 +00:00
Pau Espin 77631215f7 modem: log property changes from Modem interface
The purpose of this patch is to make sure we output to the extended log
some information regarding the firwmare version of the modem being used,
even if the test being run doesn't call print(modem.info) explicitly.

Printing self.info() just after waiting for Powered==true doesn't always
work, because the properties are not populated after a while after.
Calling Modem.GetProperties() immediately after receiving Powered==true,
will provide with empty strings on properties such as Revision.

18:59:55.747412 bus /sierra_1: Setting Powered True
18:59:55.938889 bus /sierra_1: DBG: 'org.ofono.Modem'.PropertyChanged() -> Powered=True
18:59:55.964694 bus /sierra_1: DBG: Powered == True
18:59:55.987777 bus /sierra_1: DBG: interface enabled: org.ofono.VoiceCallManager
18:59:56.006278 bus /sierra_1: DBG: 'org.ofono.Modem'.PropertyChanged() -> Features=[]
18:59:56.027366 bus /sierra_1: Setting Online True
18:59:56.189991 bus /sierra_1: DBG: 'org.ofono.Modem'.PropertyChanged() -> Manufacturer=Sierra Wireless, Incorporated
18:59:56.210935 bus /sierra_1: DBG: interface enabled: org.ofono.LocationReporting
18:59:56.233217 bus /sierra_1: DBG: 'org.ofono.Modem'.PropertyChanged() -> Features=['gps']
18:59:56.255807 bus /sierra_1: DBG: 'org.ofono.Modem'.PropertyChanged() -> Model=MC7304
18:59:56.279374 bus /sierra_1: DBG: 'org.ofono.Modem'.PropertyChanged() -> Online=True
18:59:56.315008 bus /sierra_1: DBG: Online == True
18:59:56.338779 bus /sierra_1: DBG: interface enabled: org.ofono.SimManager
18:59:56.357744 bus /sierra_1: DBG: 'org.ofono.Modem'.PropertyChanged() -> Features=['sim', 'gps']
18:59:56.379532 bus /sierra_1: DBG: 'org.ofono.Modem'.PropertyChanged() -> Revision=SWI9X15C_06.03.32.04 r28324 CNSHZ-AR-BUILD 2015/05/25 01:09:15
18:59:56.401241 bus /sierra_1: DBG: 'org.ofono.Modem'.PropertyChanged() -> Serial=356853054230919

Change-Id: If215c7d63ce1b86314ed25f8e76413b15676b7f5
2017-09-09 18:36:49 +00:00
Pau Espin ee6e4912a4 modem: Include serial attribute in info()
Change-Id: Ifd490942ecc8ecfd0f799ed241a53d45f5870b30
2017-09-09 18:36:48 +00:00
Neels Hofmeyr 36e0404f45 jenkins: build from new osmo-{msc,bsc,mgw,sgsn} repositories
The idea is to build each binary separately: even though osmo-msc requires
libosmo-sccp, which already includes the osmo-stp binary, we still want
osmo-stp to be built from a separate script. The reason: to track down
regressions, we can change the versions each binary is built from separately.
The additional build effort and jenkins script multitude is acceptable.

Change-Id: I194ad5169dbe013c8e1cf9d631033cb2576744dd
2017-09-07 00:59:46 +02:00
Pau Espin 7423d2e584 modem: Attempt fixing crash from Register() dbus method
Register() method returned today this error which is expected acording
to ofono documentation API. In this case it probably happens because the
modem internally starts registering at some point between the time
Scan() is finished and we call Register(). In this case it is fine for
us and we should just ignore the error.

A helper method is added to check for this as so far it seems tricky to
check error information coming from pydbus. I could not reproduce this
issue locally so I could not test that the helper function is going to
handle it correctly when it is triggered. That's why I added extra debug
information to be able to fix it next time it is triggered.

  File "/home/jenkins/workspace/osmo-gsm-tester_run/osmo-gsm-tester/src/osmo_gsm_tester/ofono_client.py", line 489, in scan_cb_register
    dbus_op.Register()
  File "/usr/local/lib/python3.4/dist-packages/pydbus/proxy_method.py", line 75, in __call__
    0, timeout_to_glib(timeout), None).unpack()
GLib.Error: g-io-error-quark: GDBus.Error:org.ofono.Error.InProgress: Operation already in progress (36)

Change-Id: I58dda09416ee7328812431220fd3d239c5c2980a
2017-08-25 13:07:46 +02:00
Pau Espin 3fa6e12b78 schema: Remove uneeded TRX_REMOTE_IP validate type
Attribute trx_remote_ip is actually using IPv4 validate type, thus this
validate type is not needed.

Change-Id: Ia8e154ac5fe33932935ba049f08eb5af15195d99
2017-08-24 17:09:12 +02:00
Pau Espin 713ce2cf86 Introduce auth_algo modem config attribute
Algorithm to use to generate response for the challenge during
authentication time is hardcoded in the sim card and cannot be easily
changed. Thus specify in the config of each modem the algorithm used by
the SIM Card. This attribute is used add subscriber_add() time, when the
IMSI, KI and algorithm to use in the MSC to authenticate a given
subscriber is stored in the database. This way we can easily set up
a specific algorithm for each SimCard/Modem, in case different SimCards
are configured with different algorithms.

This can be used to specificially test different algorithms too. For
instance, let's imagine we have 2 simcards, one configured to use comp128v1
and another one with xor, and we create a test which ckecks that XOR is
algo is working fine. We don't want to accidentally select the modem
with comp128v1 in this case. Thus we can use this attribute to create a
scenario file matching 'auth_algo: xor' to ensure always the correct
modem is picked.

Change-Id: Ifdf74630afeb05452994bbc9eb62a745a1d745ce
2017-08-24 17:09:11 +02:00
Pau Espin 387526aa99 bsc: Allow tests to select network encryption
Nowadays encryption parameter in bsc needs to be set to the same cipher as
the one specified in msc, otherwise the cipher negotation will fail.

See OS#2461 for more information on the matter.

Change-Id: I857b3860fb771b36fb3d587d4e92b320f0685a19
2017-08-24 15:16:03 +02:00
Pau Espin b5a8614933 Add support for authentication VTY param in msc and bsc
Change-Id: Ie1eb76149d4b006631050f8a1e532fbdbdad6a7f
2017-08-23 17:40:29 +02:00
Pau Espin 0755cdb138 hlr: Implement subscriber_delete API
Change-Id: Iefb30ad552929386743d936bf629fe7a760a4713
2017-08-23 17:03:48 +02:00
Pau Espin 6610dfe0f5 hlr: Use python module instead of cmdline to modify sqlite db
Change-Id: I94a294c37f361a666064094455c9a1e1399fdfc7
2017-08-23 17:02:38 +02:00
Pau Espin e1a26224e7 nitb: Introduce subscriber_delete API
Change-Id: I62829ed243857681bcc40a4a1861c5c583907f4b
2017-08-23 15:52:14 +02:00
Pau Espin 132e9fe6d3 nitb: ctrl: Remove unused return statement in subscriber_add
In case of failure an exception is raised. If everything goes well no
need to return True.

Change-Id: I5194eeb9208f973da12f2fa710f2b3e7acd78fb5
2017-08-23 15:50:50 +02:00
Pau Espin abc8fa5da1 hlr: fill auc_2g table when registering a subscriber
Change-Id: I491d093934c129a01baa1c5d7ada4acf370bf37d
2017-08-23 15:21:57 +02:00
Pau Espin 404e150c69 bts_osmotrx: Support configuring bts addr, trx_remote_ip and launch_trx
We may want to support running a device which runs its own TRX
(osmo-trx or different implementation). Furthermore, this TRX may be
available in some specific hwardare rather than on the main unit.

This makes it easy to configure OsmoBtsTrx to launch it's own
osmo-trx or not. In case it is launched, all IPs are configured correctly
to ensure connection can be established.

Before this commit, osmo-trx was binding to 127.0.0.1. Now we can
support multiple osmo-trx being launched on the main unit.

Change-Id: I825ed1fc0c3fe75d196db90c1508283fbd04acf8
2017-08-23 12:56:40 +00:00
Pau Espin cd6ad9d519 modem: Allow tests to change KI
This is useful for tests that wants to fake a bad KI to test if auth and
encryption are working correctly.

Change-Id: I40cfed6f6b9239eea2b97ffa010b98c78f0cb9cb
2017-08-23 12:55:43 +00:00
Pau Espin ca126b1d82 Allow tests to select network encryption
Change-Id: I273eee44c095690d0c2e3994befa97edc42496ac
2017-08-23 12:55:30 +00:00
Pau Espin 66c96c3c8e ctrl: Add dbg log to print received data
This is useful to see for instance the returned values from NITB when
asked for active subscribers.

Change-Id: I5c616646da360457930888b54d9019b76f05fe2f
2017-08-23 10:48:07 +02:00
Pau Espin 8d7a2e343b Increase log verbosity for osmo-bts-trx
The log levels changed are useful to understand clock failures we see
from time to time in osmo-gsm-tester. See OS-2325.

Change-Id: Id74af3ccb2f3db3c1793c7ff7b7a60a534e78e81
2017-08-21 19:32:00 +02:00
Pau Espin 80a5c77821 bts_osmotrx: Allow LD_LIBRARY_PATH when loading osmo-trx
When splitting osmo-trx to its own class the env injection part was
removed because it seemed not needed as it has no dependencies included
by default in the trial.

However, it may still be required by the osmo-gsm-tester main unit to
launch osmo-gsm-tester with LD_PRELOAD_PATH to point to specific
versions of libuhd, so let's add the env injection back in there.

Change-Id: I069ba69f4207665c8c575fed0fc8ff164c571e36
2017-08-21 19:03:10 +02:00
Pau Espin 3169ffbaef esme: Remove temporary workaround for non-implemented deliver_sm
Openbsc has SMS Delivery Reports since recently, which means we are now
receiving deliver_sm messages and this workaround introduced in commit
db0d8ab4fc is not required anymore.

Closes OS-#2353.

Change-Id: Iecf3983bfc24fec8023ba5d589c2d7620ec5d921
2017-08-18 19:19:16 +00:00
Pau Espin 4773853cb0 Split osmo-trx from osmo-bts-trx
In the future, some environments/products may come with a trx interface
pre-installed. Start work to easily disable launching it.

Change-Id: I556c3e2ba16753393c7e70800c533a18122daeaa
2017-08-18 07:58:52 +00:00
Pau Espin 5adb5c7405 esme: user_message_referece values should be smaller than 256
SMPP specs say message reference is 16 bits field.
However, message reference field in GSM03.40 spec is only 8 bits.

Change-Id: I52968a10089d14e0e3b0f9be678c261e3f92939c
2017-08-17 17:58:02 +02:00
Pau Espin 69373b3201 esme: smpp pdu field is a string and needs conversion
I take the chance to also swap the two log parameters, because they are
included into a dictionary and shown in swapped order in the log anyway,
which distracts me every time I look at the values.

Change-Id: I6e6ec5b9980958de82ade40e4cd898dc6f1b889f
2017-08-17 17:05:08 +02:00
Pau Espin 74a7676eb1 util: ip_to_iface: Return secondary iface if present
In the following example setup, if osmo-nitb is listening
on 10.42.42.2, we want to return eth1:0 instead of eth1.

ip addr show eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0d:b9:35:3a:41 brd ff:ff:ff:ff:ff:ff
    inet 10.42.42.1/24 brd 10.42.42.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet 10.42.42.2/24 brd 10.42.42.255 scope global secondary eth1:0
       valid_lft forever preferred_lft forever
    inet 10.42.42.3/24 brd 10.42.42.255 scope global secondary eth1:1
       valid_lft forever preferred_lft forever

Change-Id: Ia66e6fd8138fc11a70437a573128aacf6a01b8ff
2017-08-10 12:12:07 +02:00
Pau Espin ac9c1bb32f esme: Add cleanup function to avoid cascade failure of tests
In commit 6100b629e5 I assumed esme
already had a cleanup function, which doesn't seem to be the case. This
means if a test calls esme.connect() and fails afterwards without
calling esme.disconnect(), the connection will be kept but as the test
will finish and the NITB is closed, then the connection will be kept
forever in an erroneous state. With the cleanup function we ensure we
will close the connection after the test.

Change-Id: Ia3a23bb8bbccfe7ac5c544521b5566164609f0a5
2017-08-10 10:59:43 +02:00
Neels Hofmeyr a10aeaea4b osmo-bts-trx config: remove settsc
In osmo-bts change I51aeb17661dfd63ff347f7b2c0d7ffa383ec814c the settsc config
item is being removed. To be able to test it, drop the settsc option from the
config.

Change-Id: I58002a84b6b0104de4fb5c7cade27b263e375c1f
2017-08-10 10:25:48 +02:00
Pau Espin 329b6f446c Set osmo-bts pcu-socket config to point to run dir
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.

Change-Id: I5a1da23c45a4ac496fe765e0d78c52dae3e7808b
2017-08-09 11:01:52 +00:00
Neels Hofmeyr 4008b69bbe cosmetic: osmo-msc.cfg.tmpl: fix indent
Change-Id: Iefc3b06338cff4f5e51b7b03d9a5f92de18ca86a
2017-08-07 14:18:09 +02:00
Neels Hofmeyr a64ab702aa aoip: add newly needed osmo-msc point-code config
OsmoMSC no longer has a hard-coded point-code of 0.0.1. Configure it.

Change-Id: I54be984415445e695c583f35c419aed559ac5c84
2017-08-07 14:17:13 +02:00
Alexander Couzens 2ec075dede osmo-bsc.cfg.tmpl: add point code addresses
osmo-bsc requires atm to have point code addresses given for msc + bsc

Change-Id: I94f8a6892ad7e10001322cbc5a46687c0d532cb2
2017-08-07 13:45:08 +02:00
Pau Espin 6100b629e5 suite: Don't stop cleanup of objects on cleanup exception
Let's accept that during cleanup time some stuff may not be in a good
state, specially in case of a failure, but let's keep harder to clean
up everything as much as possible.

This should fix an issue in which after a test failure using an esme object,
an smpp connection is kept in a buggy state and never removed/cleaned up, and
makes all tests after it fail too because the conn is triggered at
poll() time:

   File "/home/jenkins/workspace/osmo-gsm-tester_run/osmo-gsm-tester/src/osmo_gsm_tester/suite.py", line 260, in run_tests
    self.objects_cleanup()
   File "/home/jenkins/workspace/osmo-gsm-tester_run/osmo-gsm-tester/src/osmo_gsm_tester/suite.py", line 199, in objects_cleanup
    obj.cleanup()
   File "/home/jenkins/workspace/osmo-gsm-tester_run/osmo-gsm-tester/src/osmo_gsm_tester/ofono_client.py", line 345, in cleanup
    self.dbus.cleanup()
   File "/home/jenkins/workspace/osmo-gsm-tester_run/osmo-gsm-tester/src/osmo_gsm_tester/ofono_client.py", line 170, in cleanup
    self.set_powered(False)
   File "/home/jenkins/workspace/osmo-gsm-tester_run/osmo-gsm-tester/src/osmo_gsm_tester/ofono_client.py", line 304, in set_powered
    self.set_bool('Powered', powered)
   File "/home/jenkins/workspace/osmo-gsm-tester_run/osmo-gsm-tester/src/osmo_gsm_tester/ofono_client.py", line 295, in set_bool
    event_loop.poll()
   File "/home/jenkins/workspace/osmo-gsm-tester_run/osmo-gsm-tester/src/osmo_gsm_tester/event_loop.py", line 39, in poll
    func()
   File "/home/jenkins/workspace/osmo-gsm-tester_run/osmo-gsm-tester/src/osmo_gsm_tester/esme.py", line 78, in poll
    self.client.poll()
   File "/usr/local/lib/python3.4/dist-packages/smpplib/client.py", line 321, in poll
    self.read_once(ignore_error_codes)
   File "/usr/local/lib/python3.4/dist-packages/smpplib/client.py", line 279, in read_once
    p = self.read_pdu()
   File "/usr/local/lib/python3.4/dist-packages/smpplib/client.py", line 206, in read_pdu
    raise exceptions.ConnectionError()
 smpplib.exceptions.ConnectionError

Change-Id: Ie7ef9284490f12f5cfd76c35b33b57eefab20eb6
2017-07-31 18:19:08 +02:00
Pau Espin 522ae68b08 esme: Log connection parameters of the SMSC
Change-Id: Ie4d3019503a68b02ace849defe618bdc74eacbd9
2017-07-31 17:25:15 +02:00
Pau Espin 91c75b38f1 esme: Fix race condition waiting for message response
Sometimes in test esme_ms_sms_transaction.py we get the following error:
esme_ms_sms_transaction.py:54: ERR: ValueError: list.remove(x): x not in list

This appears due to a race condition because sms_send is used several times,
which means we don't wait or sync until we receive the response before calling
sms_send_wait_resp. That means when we wait for response of message with
seqnum X, we may receive response from message seqnum X-1 which was
initiated by sms_send and thus was not stored in the self.pdus_pending
array. As it's not there, trying to remove it triggers an exception.

Change-Id: Idf49f40eb46be1448b328a5c338ddbc4547148ff
2017-07-20 22:51:52 +02:00
Pau Espin db0d8ab4fc Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
  a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
  message_received_handler maintains state of the delivery receipts we
  asked for and were still not received. However, the check needs to be
  disabled for now because OsmoNITB doens't seem to be sending stuff
  properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
  to show that there's actually a bug in OsmoNITB, see #2352.

Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.

Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.

Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-20 16:56:08 +00:00
Harald Welte ddf78124f8 remove timer section from osmo-{bts,bsc}.cfg.tmpl
As described in https://osmocom.org/issues/2380 and related gerrit
patch https://gerrit.osmocom.org/#/c/3306 the config files currently
contain timers with a 'zero' value, leading to issues.

The config file templates used in osmo-gsm-tester suffer actually
from exactly the same issue: They basically contain values that were
written back to the file based on the default initialization in libbsc,
which unfortunately was zero in some cases.

Let's remove those values, they are the (bad) default anyway.

libbsc patches in the pipeline will introduce reasonable defaults
and forbid the use of zero for timers.

Change-Id: I8cde29a597a17c2659b3b87268be4b12975f4bef
2017-07-20 11:54:49 +02:00
Pau Espin 800a697297 suite: Print process ending prematurely
Change-Id: Icec476ccc536611f771dcc7872f5190bbd0572e7
2017-07-03 18:34:09 +02:00
Pau Espin 90c23cc991 suite: Use event_loop.poll in interactive poll
This way we also poll dbus events from ofono_client

Change-Id: I06fe9a78d702ebb05c4ece78e14fcae9e2e74ee2
2017-07-03 13:12:41 +02:00
Pau Espin 0d8deec6ae Add microsecond accuracy to log timestamps
This is useful while debugging and trying to check events across other
outputs such as pcap files, process logs, etc.

Change-Id: I43bb5c6e9977189251802bc2b078c52eb046bab8
2017-07-03 10:39:56 +00:00
Pau Espin 58ff38d456 ofono_client: Power off modem during cleanup()
Change-Id: Ic0c509e77ababf385beb8b1d26659ca4d18f9331
2017-07-03 10:39:46 +00:00
Neels Hofmeyr 109ebca44c Revert "osmo-bts-trx config: remove settsc"
According to pespin, this makes all osmo-bts-trx test runs fail.
We will still figure out the details, but for the time being
let's go with the known working config.

This reverts commit 72ded64705.

Change-Id: I57a3db0d060203ad6540c9a3cc7735e273ee0048
2017-06-27 14:19:40 +00:00
Neels Hofmeyr 72ded64705 osmo-bts-trx config: remove settsc
In osmo-bts change I51aeb17661dfd63ff347f7b2c0d7ffa383ec814c the settsc config
item is being removed. To be able to test it, drop the settsc option from the
config.

Change-Id: I89b35fc587bbac6810511b2317eed24368858f37
2017-06-26 16:58:14 +02:00
Neels Hofmeyr 42bebface8 add cmdline option -R to add src file log to stdout
Change-Id: I5b21ec30453dceb53e7d4cc972607971935ef10f
2017-06-22 06:43:04 +00:00
Neels Hofmeyr 3ce18fcac7 Revert "osmo-bts-trx: wait some longer before starting osmo-bts-trx"
With this patch, the same errors are still happening.
This is not a solution, so drop this again.

This reverts commit 6c8d9497f2.

Change-Id: I324e965fdf40a369e1bcebfa4b32d0a3a7b86eb3
2017-06-18 16:50:13 +00:00
Pau Espin 2d16f6fd2c Add support for SMPP testing
As defined in [1], the different related actors are implemented in this
commit: ESME and SMSC.

SMSC: In Osmocom, the SMSC is currently implemented inside the NITB or
the MSC. A new Smsc abstract class is created to shared code between the
NITB and the MSC, and also makes it easier for later when the SMSC is
splitted. ESMEs can be dynamically added to its configuration in a
similar way to how the BTSs are added.

ESME: A new class Esme is created which can be used by tests to control
an ESME to interact with the SMSC. The ESME functionalities are
implemented using python-smpplib. Required version of this library is at
least 43cc6f819ec76b2c0a9d36d1d439308634716227, which contains support
for python 3 and some required features to poll the socket.

This commit already contains a few tests which checks different
features and tests the API. Extending tested features or scenarios can be
later done quite easily.

The tests are not enabled by default right now, because there are several
of them in a suite and the ip_address resources are not freed after every
tests which ends up in the suite failing due to missing reserved
resources. All the tests run alone work though. When the issue is fixed
they can then be added to the default list of tests to be run.

[1] http://opensmpp.org/specs/SMPP_v3_4_Issue1_2.pdf

Change-Id: I14ca3cb009d6d646a449ca99b0200da12085c0da
2017-06-18 08:48:09 +00:00
Pau Espin 1dd2955cb1 Unuse resources after every test
Fix bug in put_all(). That method was unused before this commit.

Clean the process list after the processes are stopped,
otherwise the suite eventually fails with a 'process terminated
prematurely' error. Before it was not necessary because it was not
reused (a new suite run was created).

Change-Id: Iee12866045145544076c6c18786e1a54f18fc293
2017-06-17 17:01:20 +00:00
Pau Espin d091233934 Use a subdir of run_dir for each test
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.

Change-Id: I06be2dd21710e14c1337d13b1fe6c2f68f037957
2017-06-17 16:10:04 +00:00
Neels Hofmeyr 6c8d9497f2 osmo-bts-trx: wait some longer before starting osmo-bts-trx
We get sporadic clock skews when running osmo-bts-trx, causing the process to
end and the test to fail. Try to give some seconds for the osmo-trx process to
sort itself out, in the hope to avoid the clock skews.

Related: OS#2325

Change-Id: I82d29358498e7ad9fef28d409808168926e2f876
2017-06-17 17:44:06 +02:00
Pau Espin fbecf41f01 ofono_client: Cancel pending async dbus methods at cleanup time
This commit should fix issue described #2326, in which a test started
scanning and quickly afterwards failed, leaving the async Scan() method
running and the response arriving when we were already in another
suite/test.

Change-Id: If5e9bcac8e4114718243d178ff50d1ed8b30c95d
2017-06-14 12:27:42 +02:00
Neels Hofmeyr 59f8dfe16b osmo-bts-trx: set l1c logging level to notice
We have sporadic osmo-bts-trx shutdowns with "No clock from osmo-trx" error
messages. Around it are L1C logs on level 'notice', so let's log those as well.

Related: OS#2325
Change-Id: Ic306d2dd8670550d84e9c446098bccaba147e13b
2017-06-14 03:00:24 +02:00
Neels Hofmeyr d28d1a789e cosmetic: dbg log fix in suite.py
Change-Id: I0ff92bc1aa05bf5020bbb3b6965cbb22f1ca4d61
2017-06-14 02:59:55 +02:00
Neels Hofmeyr 02a28e54a5 cosmetic: osmo-stp.cfg: fix indent
Change-Id: I239fe6da004b840fb805c51e46967c8ba3b0d3f5
2017-06-13 17:31:36 +02:00
Neels Hofmeyr 38b051c6da aoip: add osmo-stp, now required for aoip runs
Change-Id: I35d4cb0d173eec240bccc1f3a5965a774b7b3506
2017-06-13 15:28:31 +00:00
Pau Espin 910f3a1107 ofono_client: Improve log around Scan() failure
Change-Id: I8558d7fe41c155db2a9710e1eccf15b6499f24ef
2017-06-13 17:08:24 +02:00
Pau Espin cc5b5a2987 ofono_client: fix use of raise_exn
method raise_exn was removed in
1a7a3f0e43, but due to merge process it
remaine dbeing used in some places.

Change-Id: I89f4abe3d69aa4e7bc1fd6c6fd7e9fdea2cd8d19
2017-06-13 16:56:04 +02:00
Pau Espin 4d63d92033 ofono_client: gracefully handle Scan() failure
ofono's NetworkRegistration.Scan() method fails sporadically. On failure,
check if we are now registered to the desired network, and schedule another
scan otherwise.

For instance it fails with org.ofono.Error.Failed if the modem starts to
register internally after we started Scan() and the registering succeeds
while we are still waiting for Scan() to finsih.

Change-Id: I4a2265ee39a94daa00f525b1c7037a6775509425
2017-06-13 14:37:57 +00:00
Neels Hofmeyr 1a7a3f0e43 fix and refactor logging: drop 'with', simplify
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
instance.

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
lookup.

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.

Change-Id: I5f9b53150f2bb6fa9d63ce27f0806f0ca6a45e90
2017-06-13 13:32:01 +02:00
Pau Espin 0e57aadd28 ofono_client: Implement network registration during connect()
A new mcc_mnc parameter is now optionally passed to connect() in order
to manually register to a specific network with a given MCC+MNC pair.
If no parameter is passed (or None), then the modem will be instructed
to attempt an automatic registration with any available network which
permits it.

We get the MCC+MNC parameter from the MSC/NITB and we pass it to the
modem object at connect time as shown in the modified tests. Two new
simple tests to check network registration is working are added in this
commit.

Ofono modems seem to be automatically registering at some point after
they are set Online=true, and we were actually using that 'feature'
before this patch. Thus, it is possible that a modem quickly becomes
registered, and we then check so before starting the scan+registration
process, which can take a few seconds.

The scanning method can take a few seconds to complete. To avoid
blocking in the dbus ofono Scan() method, this commit adds some code to
make use of glib/gdbus async methods, which are not yet supported
directly by pydbus. This way, we can continue polling while waiting for
the scan process to complete and we can register several modems in
parallel. When scan completes, a callback is run which attempts to
register. If no MCC+MNC was passed, as we just finished scanning the
modem should have enough fresh operator information to take good and
quick decisions on where to connect. If we have an MCC+MNC, then we check
the operator list received by Scan() method. If operator with desired
MCC+MNC is there, we register with it. If it's not there, we start
scanning() again asynchronously hoping the operator will show up in next
scan.

As scanning() and registration is done in the background, tests are
expected to call connect(), and then later on wait for the modem to
register by waiting/polling the method "modem.is_connected()". Tests
first check for the modem being connected and after with MSC
subscriber_attached(). The order is intentional because the later has to
poll through network and adds unneeded garbage to the pcap files bein
recorded.

Change-Id: I8d9eb47eac1044550d3885adb55105c304b0c15c
2017-06-12 15:34:21 +02:00
Pau Espin 56bf31c82a ofono_client: Print debug information about network registration changes
Change-Id: I61414c49544b7553058d2979b152fde95e0a3b58
2017-06-12 15:33:17 +02:00
Neels Hofmeyr f8e6186406 junit result: also write for aborted runs
Even if aborted due to signal, write a JUnit report XML, and make sure to
indicate the runs as erratic.

Change-Id: I7a334ef3463896c543c0fe592d3903c15e67d4c4
2017-06-12 11:34:44 +00:00
Pau Espin daf96e449e test: Remove unused variable Failure
Commit 6ccda11a98 removed its use but forgot to
remove it on this line.

Change-Id: I90375ce1e4b8e0b7e140df908323bc269e0baf40
2017-06-12 12:07:46 +02:00
Neels Hofmeyr 6ccda11a98 refactor: fix error handling; fix log.Origin; only one trial
A bit of refactoring to fix logging and error reporting, and simplify the code.
This transmogrifies some of the things committed in
0ffb414406 "Add JUnit XML reports; refactor test
reporting", which did not fully match the code structuring ideas used in
osmo-gsm-tester. Also solve some problems present from the start of the code
base.

Though this is a bit of a code bomb, it would take a lot of time to separate
this into smaller bits: these changes are closely related and resulted
incrementally from testing error handling and logging details. I hope it's ok.

Things changed / problems fixed:

Allow only a single trial to be run per cmdline invocation: unbloat trial and
suite invocation in osmo-gsm-tester.py.

There is a SuiteDefinition, intended to be immutable, and a mutable SuiteRun.
SuiteDefinition had a list of tests, which was modified by the SuiteRun to
record test results. Instead, have only the test basenames in the
SuiteDefinition and create a new set of Test() instances for each SuiteRun, to
ensure that no state leaks between separate suite runs.

State leaking across runs can be seen in
http://jenkins.osmocom.org/jenkins/view/osmo-gsm-tester/job/osmo-gsm-tester_run/453/
where an earlier sms test for sysmo succeeds, but its state gets overwritten by
the later sms test for trx that fails. The end result is that both tests
failed, although the first run was successful.

Fix a problem with Origin: log.Origin allowed to be __enter__ed more than once,
skipping the second entry. The problem there is that we'd still __exit__ twice
or more, popping the Origin off the stack even though it should still remain.
We could count __enter__ recurrences, but instead, completely disallow entering
a second time.

A code path should have one 'with' statement per object, at pivotal points like
run_suites or run_tests. Individual utility functions should not do 'with' on a
central object. The structure needed is, in pseudo code:

  try:
    with trial:
      try:
        with suite_run:
	  try:
	    with test:
	      test_actions()

The 'with' needs to be inside the 'try', so that the exception can be handled
in __exit__ before it reaches the exception logging.

To clarify this, like test exceptions caught in Test.run(), also move suite
exception handling from Trial into SuiteRun.run_tests(). There are 'with self'
in Test.run() and SuiteRun.run_tests(), which are well placed, because these
are pivotal points in the main code path.

Log output: clearly separate logging of distinct suites and test scripts, by
adding more large_separator() calls at the start of each test. Place these
separator calls in more logical places. Add separator size and spacing args.

Log output: print tracebacks only once, for the test script where they happen.

Have less state that duplicates other state: drop SuiteRun.test_failed_ctr and
suite.test_skipped_ctr, instead add SuiteRun.count_test_results().

For test failure reporting, store the traceback text in a separate member var.

In the text report, apply above changes and unclutter to achieve a brief and
easy to read result overview: print less filler characters, drop the starting
times, drop the tracebacks. This can be found in the individual test logs.
Because the tracebacks are no longer in the text report, the suite_test.py can
just print the reports and expect that output instead of asserting individual
contents.

In the text report, print duration in precision of .1 seconds.

Add origin information and a traceback text to the junit XML result to give
more context when browsing the result XML. For 'AssertionError', add the source
line of where the assertion hit.

Drop the explicit Failure exception. We don't need one specific exception to
mark a failure, instead any arbitrary exception is treated as a failure. Use
the exception's class name as fail_type.

Though my original idea was to use raising exceptions as the only way to cause
a test failure, I'm keeping the set_fail() function as an alternative way,
because it allows test specific cleanup and may come in handy later. To have
both ways integrate seamlessly, shift some result setting into 'finally'
clauses and make sure higher levels (suite, trial) count the contained items'
stati.

Minor tweak: write the 'pass' and 'skip' reports in lower case so that the
'FAIL' stands out.

Minor tweak: pass the return code that the program exit should return further
outward, so that the exit(1) call does not cause a SystemExit exception to be
logged.

The aims of this patch are:
- Logs are readable so that it is clear which logging belongs to which test and
  suite.
- The logging origins are correct (vs. parents gone missing as previously)
- A single test error does not cause following tests or suites to be skipped.
- An exception "above" Exception, i.e. SystemExit and the like, *does*
  immediately abort all tests and suites, and the results for tests that were
  not run are reported as "unknown" (rather than skipped on purpose):
  - Raising a SystemExit aborts all.
  - Hitting ctrl-c aborts all.
- The resulting summary in the log is brief and readable.

Change-Id: Ibf0846d457cab26f54c25e6906a8bb304724e2d8
2017-06-09 00:35:20 +02:00
Neels Hofmeyr f9e86935a3 error log: clarify for using more resources than reserved
Figure out how many resources were reserved, how many of those match the
requirements, and how many are used, and log one of three matching error
messages for that situation.

For that purpose, allow find()ing reserved resources without logging anything,
using a log_label=None arg.

Change-Id: I1c67600ba69351859e46b8b2f368ee8106db0993
2017-06-09 00:11:56 +02:00
Neels Hofmeyr 7b02ed0f4b osmo-msc: configure HLR address
In db59bcf9fc we added a configured GSUP server
address for the osmo-hlr, but the osmo-msc is still trying to connect to
127.0.0.1.

In the same way as for mgcpgw, add conf_for_msc() to OsmoHLR, and use that to
configure the HLR's address in osmo-msc.cfg.

Related: OS#2320
Change-Id: I005aa160c679fc92b248abd762888959bd5b2c55
2017-06-08 23:26:51 +02:00
Neels Hofmeyr b902b29912 test API: allow passing resource requirements
For all those API functions that directly use reserved_resources.get(), add a
'specifics' argument to be able to pick specific resources. For example, this
allows to pick a suite.bts(specifics={'type': 'osmo-bts-sysmo'})

I needed this to test error reporting for over-using resources, but will most
probably make sense in the future.

Change-Id: If6f175f4bb53dec5306fb3c6479202a7bf1c7116
2017-06-07 18:04:13 +00:00
Neels Hofmeyr a8a05a2e23 error log: clarify for reserving more resources than available
When trying to reserve more resources than available in the resources.conf,
actually print an intelligible error message: catch the nameless error from
solve() and fill in what was requested for solution.

Change-Id: Iba3707f1aaeb40a58c616c33af52a60c9a2e7e1f
2017-06-07 19:53:28 +02:00
Neels Hofmeyr 31e83200b2 fix problem in origin ancestry: don't add self twice
Also add various comments to illustrate what is going on during origin
resolution.

In the regression tests' expectations, some duplicate entries in the origins
are removed, and hence no list of deeper origin ancestry is printed anymore.

Change-Id: I42c3b8635b54c31c27699140e200c1f75a6ada29
2017-06-07 19:53:24 +02:00
Neels Hofmeyr d3a33e393e cosmetic: whitespace in log.py
Change-Id: I356725ba7d874d3d41afb5e4c89dac188c8d7dcc
2017-06-06 22:42:44 +00:00
Neels Hofmeyr f15eaf95de add cmdline arg to set conf dir
Add -c cmdline option to do the same as / in addition to the
OSMO_GSM_TESTER_CONF var, because setting the var is cumbersome in daily
development.

Change-Id: I4c3b482f31f638047ab3f3d785d294b28d244b80
2017-06-06 20:00:43 +02:00
Harald Welte 2720534f27 Re-License under GPLv3-or-later instead of AGPLv3-or-later
The "Affero" nature makes sense for the Osmocom network components like
BSC, SGSN, etc. as they are typically operated to provide a network
service.

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.

Change-Id: I8959c2d605854ffdc21cb29c0fe0e715685c4c05
2017-06-03 14:23:51 +00:00
Pau Espin db59bcf9fc Use reserved ip address for osmo-hlr GSUP interface
Otherwise 0.0.0.0 was being used and we want all interfaces for a
specific osmo-hlr instance to use the same IP

Requires osmo-hlr change id I79f7a300480f308b21116dd14d1698be38725afd
otherwise osmo-hlr won't be able to parse the configuration file.

Change-Id: I4e0063abc8de3d739ebd81942b692cc2e75792f1
2017-06-03 14:21:09 +00:00
Pau Espin fa00b0f843 Use reserved ip address for osmo-mgcpgw VTY interface
Otherwise 127.0.0.1 was being used and we want all interfaces for a
specific osmo-mgcpgw instance to use the same IP

Change-Id: I60dbfbb66458cd333fe07139ee175c94fa1672a7
2017-05-31 19:00:16 +00:00
Pau Espin ea3549f844 Use reserved ip address for osmo-bsc ctrl interface
Otherwise 127.0.0.1 was being used and we want all interfaces for a
specific osmo-bsc instance to use the same IP

Change-Id: I38dccac6707bf55f0abcf96e3a9d7d8ec765a156
2017-05-31 18:58:58 +00:00
Neels Hofmeyr b3b3104b6a fix: Sms.__eq__ bug due to typo
Add test of this to sms_test.py

Change-Id: Ib0b420a81c1b211a9f03a2521d244b3a427d5e5b
2017-05-31 20:39:42 +02:00
Pau Espin 996651a3a3 Move Sms class to a separate module
Preparation for following commits to add smpp support, as we will have a
class SmppClient with a method accepting an Sms object to send it.

Change-Id: I1f28e14e963abb64df687b69d54975be2aeb0d0d
2017-05-31 16:14:08 +02:00
Neels Hofmeyr b8011695b8 cosmetic: review mo_mt_sms.py's logging
Implement the Modem.log_info() function, use that instead of logging all modem
properties.

Tweak mo_mt_sms.py print() statements.

Pass modem object to SMS generation to inlcude the modem name as SMS token.

Change-Id: I2b17fce0b3b05594fd9038b54e5b65f5127bd0a4
2017-05-30 15:38:52 +00:00
Pau Espin 0993bf6f98 ofono_client: Fix race condition when checking for required features
I got a backtrace in which the modem was lacking feature 'net'. That
happens for 2 reasons:
1- net feature is not shown unless the modem is Online (at least for
sierra modems)
2- Even after it has been set online, a lapse of time can pass before
the feature gets shown.

This was added in 896f08f6ab
"fix: refresh dbus object when interfaces have changed"
with the expectation that the 'Features' list would be available in all
modem states. Since it depends on being powered and online, the same
functionality is already provided by checking the Interfaces list, hence
this code can be dropped entirely.

Change-Id: Iedd62235d1a3a8b917ad4ac0b61b9c5dbf0fe43c
2017-05-30 15:26:00 +00:00
Neels Hofmeyr 8c7477f5d8 cosmetic: SMS tokens: add modem name to SMS message
Change-Id: I66b8f30303e21ad781d16f3aa9fe30067d6a0e20
2017-05-29 20:30:06 +00:00
Neels Hofmeyr 0cc53ef4bc log.Origin: return self on __enter__
Allows using 'with some_origin() as foo:' constructs.
Not used actively, but is sometimes useful during debugging sessions.

Change-Id: I7a6463ee39761775305dd2272c24f248552db4ad
2017-05-29 20:29:09 +00:00
Neels Hofmeyr 206803d59a fix osmo-bts-trx: missing patch to use new event_loop
Change-Id: I640258d8451aff1633cba7390df5430da50d0b0b
2017-05-29 04:32:32 +02:00
Neels Hofmeyr 908faf8d1b fix log: print suite-run separator in proper place
error was introduced by 0ffb414406
'Add JUnit XML reports; refactor test reporting'

Change-Id: I9acf1a840277979a19a2019c69e4562ff7fe2ca0
2017-05-29 04:32:26 +02:00
Neels Hofmeyr 4d688c2faf fix multi-suite runs: implement modem cleanup
After a suite was done, the modem object would linger. If two suites were run
consecutively, the first suite's modem objects would still log incoming SMS.

Add an object cleanup mechanism in the SuiteRun class. Start by adding a
cleanup() to the Modem object and subscribing created modems there.

Move the modem_obj() function into SuiteRun, there is no use of it being
separate, and it makes for better logging.

Change-Id: I0048d33e661d683a263c98128cd5c38b8d897dab
2017-05-29 04:32:13 +02:00
Neels Hofmeyr 896f08f6ab fix: refresh dbus object when interfaces have changed
This solves the KeyError problems when we attempt to use new Interfaces that
have come up. The solution is to get a fresh pydbus object when interfaces have
been added.

Another key solution is to not completely discard and unregister all signals
every time. This is racy and may cause signals getting lost. If an interface
was not removed, it is not harmful to have it subscribed using an older pydbus
object. These older objects may linger until the specific signal subscriptions
are disconnected. It is important to fetch a new dbus object for subscribing to
signals on interfaces that have just been added.

Put signal subscription and property watching in a separate class
ModemDbusInteraction. This class may also be used without signals or a modem
config, in anticipation of the IMSI discovery patch that's coming up.

Related: OS#2233
Change-Id: Ia36b881c25976d7e69dbb587317dd139169ce3d9
2017-05-29 04:30:34 +02:00
Neels Hofmeyr ed4e528693 fix: free resources when a suite run is done
Add missing code to free resources, not upon program exit, but when a suite is
done.

This allows running more than one suite in a row.

Also add a check to not attempt to free if there is nothing to be freed, to
avoid a regression test failure triggered when a suite exits without reserving
anything.

Change-Id: Ic017a1cf07052f5e48812c8553fba6f972d280f0
Related: OS#2301
2017-05-29 03:03:39 +02:00
Neels Hofmeyr 2a1a1fa8f9 fix: None error on unavailable resources
If not a single resource of a wanted item was left, we ran into a None. Report
unavailability instead.

Change-Id: Ie1849a74cb227964e7c3ac06852582baa2333697
2017-05-29 02:54:41 +02:00
Neels Hofmeyr 48055ed0aa fix osmo-bts-trx: add config: 'osmotrx tx-attenuation oml'
Before this, the network opened up by osmo-bts-trx would be invisible through
the attenuation of the osmo-gsm-tester hardware, because tx-attenuation would
apparently default to 50, meaning maximum attenuation.

Change-Id: I1c026b5691033127eef766d82566c39cc070e14a
2017-05-29 00:29:50 +02:00
Neels Hofmeyr 9576f5f9a5 log: change 'log_all_origins' from bool to a list of levels to apply to
The idea is to see the full origin list for log level ERR, while the rest
of the logging can be kept less verbose.

Change-Id: I0277782652548fa321f767da79b207d70678fad1
2017-05-28 22:26:23 +00:00
Neels Hofmeyr 798e592fd6 MSC+BSC: add test api to run OsmoMSC and OsmoBSC with AoIP
Change-Id: I5842e8f1cba8e8e6bedfc08540efcafe207159cb
2017-05-29 00:19:45 +02:00
Neels Hofmeyr d41dae9820 bts: add remote_addr() function
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()).

Change-Id: I7af9275914f34808cb60ae16b65ecd3688fd6b5b
2017-05-29 00:18:43 +02:00
Neels Hofmeyr 4f59ba6e68 config: nitb template: move ip_address to nitb.ip_address
It's the NITB's address, so it should go in the nitb.* scope.

Change-Id: I71a5ef153b7156b0644253f5aa8a0c848f42ab3b
2017-05-29 00:18:43 +02:00
Neels Hofmeyr c4ba4a6866 rename more items from nitb to bsc
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.

Change-Id: I6a0343b9243b166d4053cc44f523543f1245d772
2017-05-29 00:18:43 +02:00
Neels Hofmeyr 76d8103bfb rename resource nitb_iface to ip_address
I would like to use the IP addresses also for OsmoBSC processes, so it is more
than clear now that 'nitb_iface' was the wrong naming choice.

The only distinction we may need in the future is public versus loopback
interface. To add that, we may add a trait to the 'ip_address' resource
like:

  ip_address:
  - addr: 10.42.42.1
    type: public
  - addr: 127.0.0.1
    type: loopback

This way we can substitute public vs loopback addresses flexibly (e.g. using
scenarios).

Change-Id: I3ad583ae7a33f7a7bb56fe78a125f73c56a0e860
2017-05-29 00:18:43 +02:00
Neels Hofmeyr 943c81d878 debug: config logging before templates: use pprint and an all-caps label
Change-Id: I0e1c1d3ce8163d5b40c17b7d0fb0847a068ced76
2017-05-29 00:18:43 +02:00
Neels Hofmeyr 6d8e485a2b nitb config: set: logging color 1, category 1
Change-Id: Icd9022f5732caac65d16fc49f2ed7833199523de
2017-05-29 00:18:43 +02:00
Neels Hofmeyr 2d1d561eeb resource error logging that is easier to understand
Log what a suite requested, what it has reserved and the complete resource
state.

Change-Id: Ic6887bbe5fe74a73f0e344cd4078dd7ed989cc15
2017-05-29 00:18:42 +02:00
Pau Espin 927344b4dc event_loop: Create a global event loop to poll and wait for events
Tweaked-by: nhofmeyr
Change-Id: Iaa78bae0f053496377609b24a11ebaef3fd77598
2017-05-25 17:25:09 +00:00
Neels Hofmeyr 391afe3b13 remove bts_ocpthy.py
We're not currently paying attention to the octphy in osmo-gsm-tester. So
instead of maintaining dead code, remove the bts_octphy.py; we can re-add when
the octphy is implemented properly.

Change-Id: Ia5d5750d440ae7019634b51fa1efe7bbb2a1d1e2
2017-05-25 04:09:20 +02:00
Neels Hofmeyr 8b915073ae osmo_nitb.py: remove unused imports
Change-Id: I55c118c6b277a2c8cddc251e3d36571b12504266
2017-05-25 04:09:20 +02:00
Pau Espin 5bf66c57d6 trial.py: Remove accidental double creation of file
This file is already created in run_suites().
Creating it in here too makes a new file name()_2.xml created and
populated instead of the original name().xml one.

Change-Id: Ibec14a1ef5fd029aa37ce666d00236bb872d636e
2017-05-24 12:02:43 +00:00
Pau Espin 98df394fc6 Exit with failure if not enough resources are found
Change-Id: I9e38435ff71416585a259c823053bd07c670d495
2017-05-24 12:01:07 +00:00
Pau Espin d1f8fe689e osmo_nitb.py: Remove unused var
Change-Id: Ifb0c274aac9f8fda177992f19146807387485627
2017-05-22 22:00:14 +00:00
Pau Espin 374e8a0b26 suite.py: Fix typo in variable name used during exception
Fixes a possible double exception introduced in 0ffb4144

Change-Id: I44a30f51c23e6a57ccae3483c806c0ed25d2ecf9
2017-05-22 17:52:09 +02:00
Pau Espin 469316fae0 Handle termination signals to exit gracefully and prevent resource leak
Make sure we free the reserved resources and kill launched subprocesses
before stopping. Before this patch it was not the case for instance if we
received a SIGTREM signal from kill.

Change-Id: I039e4d1908a04bf606b101ddc6a186ba67e6178e
2017-05-19 14:40:18 +02:00
Pau Espin 0ffb414406 Add JUnit XML reports; refactor test reporting
* Add Junit output file support
* Differentiate between an expected failure test and an error in the
test, as described in JUnit.
* In case of an error/exception during test, record and attach it to the
Test object and continue running the tests, and show it at the end
during the trial report.

Change-Id: Iedf6d912b3cce3333a187a4ac6d5c6b70fe9d5c5
2017-05-19 14:22:39 +02:00
Pau Espin 023fd2c748 pcap_recorder: use self.filters instead of gen_filter
Change-Id: I53779d521fbeed7c37bcaeb12be2531e4dbc005c
2017-05-15 15:01:15 +02:00
Pau Espin 6ab98983bd Enable GSMTAP on BTS and record it on the main unit NITB
Change-Id: I057a83bc20c5e664ac1778812452f189166919ba
2017-05-15 14:57:42 +02:00
Pau Espin 8cd347b2c5 nitb: Filter ssh packets in pcap
Change-Id: I62a6ae7bd3a84baceb684c26727d2269c86ed023
2017-05-15 14:49:22 +02:00
Neels Hofmeyr 95fd67374c pcap: pass complete filter string to PcapRecorder
Composing the filter in gen_filter() is more complex than we need. We pass the
address and potentially further filter elements separately, and then
gen_filter() has to guess how to combine these. Instead, have just a filter
string to use right from the start, so that the caller has full control (and
full responsibility).

Remove the addr argument, which was only used for filtering.

This is my conclusion of looking at the patches with change Ids
I62a6ae7bd3a84baceb684c26727d2269c86ed023 (PS 1) and
Icbb0f8d2058fa7ebb7f0f731645f9266cacdb120

I62... PS 2 will add the SSH filtering.

The name 'filter' is a python built-in, which is why I chose the argument
name 'filters' instead. It works with 'filter' as well, but let's try to
avoid naming conflicts like that.

Change-Id: Iff7ddf51d3bf0189ce07b488a3dcdcfce6907aba
2017-05-15 14:49:22 +02:00
Neels Hofmeyr e44a0cb0d9 trial: always use abspath
No actual failure known, but using the abspath will prevent further problems
when running a binary in its own run dir and passing trial paths to it.

Adjust test expectations.

Change-Id: Ia2ba876a42eef9122a92645edd1f28ddb56e6be3
2017-05-15 14:25:24 +02:00
Neels Hofmeyr e60df6961c fix name of local var, to not shadow 'suite' module
This caused "UnboundLocalError: local variable 'suite' referenced before
assignment".

Change-Id: Ic9aa383f5cdc9818c5a21b101fb6ddea4132d9fb
2017-05-15 12:23:57 +00:00
Neels Hofmeyr 2123541574 fix: exception outside of trial run should be logged and cause nonzero rc
From an earlier stage of the code, there was still an exception catcher that
makes no sense. Remove it.

Change-Id: I8085318c91b06a3e8f7d3f8cfdd15a99650666e2
2017-05-15 12:23:57 +00:00
Neels Hofmeyr 143ab81aac pcap recorder: include vim indenting rules as comment
Change-Id: Idbc4521053610d55c9c32eff950ed8fa68dda171
2017-05-15 12:23:36 +00:00
Neels Hofmeyr 39b0b89caf log the location of the detailed log file
The idea is that if someone reads the short log and scratches her head, she can
notice that there is a more detailed log available.

Change-Id: Id5f443f1af0dc774d4d4c588a238b786a83e44d3
2017-05-15 12:22:35 +00:00
Neels Hofmeyr 2296883fc3 log: tweak osmo-gsm-tester.py stdout: all_origins=False, src=False
Change-Id: I24a600f67f7a9f3d1235abfceb86f311ffa97746
2017-05-15 12:22:35 +00:00
Neels Hofmeyr 7e2e8f1d65 log state dir
On the log output, clearly show which state dir is used. Since all runs should
use the same state dir, this is important and/or reassuring to see.

Change-Id: Ie92f1879a35d8bb399ee916b7ef72f9ee7d47409
2017-05-15 12:22:35 +00:00
Neels Hofmeyr 1fe012e6a8 cosmetic: rather have an underscore in pcap_recorder.py
Change-Id: Ib4886cb3fe0cb9c66d170097b98b4d1eb67cab81
2017-05-15 12:43:35 +02:00
Neels Hofmeyr cf0304ff26 cosmetic: cmdline help: add line breaks, fix typo
Fix typo 'patch' -> 'match'

Argparse has a peculiar way of treating the cmdline help strings. Include
explicit newlines in cmdline help, and place a comment explaining the details.

Change-Id: I34a2333c55719986b729b07386bc47314635ee04
2017-05-12 14:34:41 +02:00
Neels Hofmeyr 47de6b0a24 ofono/dbus: detach from signals as appropriate
In the dbus_connect() code path, return the subscription token.

In the Modem class, use this token to disconnect signal callbacks when an
interface is removed.

Generalize the signal connect/disconnect handling: have one tuple defining all
signals and their handler functions, add generalized loop to attach them. Store
all subscription tokens in a dict of lists, any number of signal callbacks per
general interface name. When an interface is announced to be removed from
ofono, detach all signals for that interface implicitly.

So far this only handles the MessageManager interface's IncomingMessage signal,
but others will likely follow soon.

Fixes: OS#2242
Change-Id: I0939ef414bc599ee8742df48da04d8d9569d00ba
2017-05-11 12:33:00 +02:00
Neels Hofmeyr 803d87c2e8 util: simplify listdict
listdict came into the code base from some other python code of mine, for no
apparent reason: it is actually not used here at all. However, an upcoming
patch will use a dict of lists.

Also, the listdict implementation is convoluted/complex (to allow accessing
keys as direct object members, which we don't need). Simplify the
implementation to be used by I0939ef414bc599ee8742df48da04d8d9569d00ba.

Change-Id: I09adfd128a19c6c5ba36aae1d4cab83dbd07e0fb
2017-05-11 12:33:00 +02:00
Neels Hofmeyr 4f33dcc4df run dir: add a second log file containing a non-debug log
Change-Id: Ic51b8f87abc52cc4af3672ee70045ba08334f62e
2017-05-10 13:08:52 +00:00
Pau Espin 13143bc4df Log network activity using tcpdump for nitb interface
Change-Id: I4c5d0e2d9857160f905e743517e744f1a06368af
2017-05-10 13:48:31 +02:00
Pau Espin ecf107983b suite: Terminate processes in LIFO order
Usually the first process we started is the one we want to stay until
the end.

Change-Id: I08ea01a42af68191a659fdf8173e3fec9b1e1cfd
2017-05-08 16:57:53 +02:00
Pau Espin e39c6f1a52 Prepend LD_LIBRARY_PATH instead of overwritting it
My current distribution ships a newer libcrypto and libssl which are not
ABI compatible with the ones generated by Jenkins. I had to copy those
libraries locally and use LD_LIBRARY_PATH to be able to run binaries
compiled coming from the jenkins slave. Without this patch I am not
able to run it because it is overwriting the previous variable.

Change-Id: Id9b16d13d343616cbf87b9da8a99e3fae48da6bd
2017-05-08 16:34:30 +02:00
Neels Hofmeyr a88b0c7424 propagate Timeout class to test scope, use in debug suite
Change-Id: Idad34fe799bc8b8e03d773898473773656b005bd
2017-05-08 13:06:58 +02:00
Neels Hofmeyr 1ffc3fed6b on timeout, raise dedicated Timeout exception
Change-Id: I085a52194dde0f5e6dd845ffde1197f7dc83b306
2017-05-08 13:06:58 +02:00
Neels Hofmeyr cccbe5987d improve logging for resource allocation
Log on level 'log', more clearly show whether it's for reservation or actual
use, show the origin that is asking for them.

Change-Id: I3b78c7bdcaec90943900343c878099160f8d2f64
2017-05-08 12:50:42 +02:00
Neels Hofmeyr f31c545f48 log.py: add a log target option to omit the list of deeper origins
Change-Id: I8a0a508ee4aeffe940be906de0e431740653a08c
2017-05-08 10:12:25 +00:00
Neels Hofmeyr fd7b9d040d run dir: write detailed log file
For each run on a trial, create a log target that logs to a file in the run
dir. Set all levels to DBG in that log target.

Related: OS#2206
Change-Id: Ie7279aeaf32950f85d4145abdc917024003d1d99
2017-05-08 10:12:25 +00:00
Neels Hofmeyr 532126a725 log: make 32 the default origin_width.
Change-Id: I1159395251332f3b1af3b3a322e7191559105faa
2017-05-08 10:12:25 +00:00
Neels Hofmeyr 8f4f17437d log.py: add FileLogTarget
Will be used in a subsequent commit.

Change-Id: Id3dfdeea236eb8ade5e6c80e64d5c3ce4de96b81
2017-05-08 10:12:25 +00:00
Neels Hofmeyr 1a2177cd1b log.py: LogTarget: return self for chaining modifiers
For example this allows
  tgt = LogTarget(foo).set_all_levels(bar).style_change(baz)

Change-Id: If168cc06f644bde6183f3bc51e394c7705386b3e
2017-05-08 10:12:25 +00:00
Neels Hofmeyr f816688279 log.py: tweak LogTarget list, require explicit LogTarget
Rename log_sink to log_write_func to make it more clear.

Remember the list of log targets as static member LogTarget.all_targets.

Make each LogTarget instance register with the list of targets implicitly.

No longer create a default log target, rather create one explicitly in
osmo-gsm-tester.py.

Change-Id: I5844485eaed536cb34b44bfe23dc635fe1982dcd
2017-05-08 10:12:25 +00:00
Neels Hofmeyr f9de78fc58 improve doc and usability of osmo-gsm-tester.py -t option
Allow exact matches by prepending a '='.
Properly document the -t option.

Change-Id: I61bed7e05f0c1f08cf3de72f62d9ba6609d44aee
2017-05-08 10:12:10 +00:00
Neels Hofmeyr f49c7daa81 sms: log info as dbg
Change-Id: Ia9ae0fa63a96a541e7d66cf0d8a9032b135760e6
2017-05-08 10:12:00 +00:00
Neels Hofmeyr 2e41defdd4 sms: don't log info
Change-Id: Ie9c4757de1eedcbcc85b7b99b94d164cc6ae3c59
2017-05-08 10:12:00 +00:00
Neels Hofmeyr 9b90770716 Resource.find: allow returning empty instead of raising
Add flag raise_if_missing, and if False, instead of raising an exception,
return an empty list for that kind of resource. This makes sense for a caller
that requests a single resource.

When finding a single resource to use in ReservedResources.get(), use this to
raise a more adequate exception message if none was found.

Change-Id: Ia296ea68a787bede037a6cea38563b570fb0766e
2017-05-08 10:11:52 +00:00
Neels Hofmeyr 2fade33e49 doc: Resources.find: add API doc + inline comments
Change-Id: Ib6376794e28f8faff82517af99dfb38ab4689ac8
2017-05-08 10:11:51 +00:00
Neels Hofmeyr acf0c937e7 fix prompt()
The prompt() is useful for supervisor (user) interaction during tests.

However it had numerous problems:
- closed stdin, so second prompt() didn't work
- no editing
- no utf-8 multichar
- unflexible poll interval (poll often to stay responsive to input)
and unrelated:
- stdin was hijacked by subprocess.Popen

Firstly pass stdin=PIPE to all subprocesses to leave the tester's stdin
untouched.

Secondly use python input() to read the user entry (instead of mucking about
with the stdin fd), and import readline for history and editing features.

The old approach was put in place to allow polling DBus and processes
regularly. Instead, allow this by running input() in a separate thread while
polling regularly and slowly in the main thread.

The prompt code is now simpler, cleaner and works better.
Will be used in the upcoming 'debug' suite.

Change-Id: I580aca52cd038b59418055259d0d09e9aab49124
2017-05-08 10:10:03 +00:00
Neels Hofmeyr f2d279c621 suite.py: add function to get several modems in a list
Will be used in the upcoming 'debug' suite.

Change-Id: Ia1156f523cff18196c88604ce3079b9532187427
2017-05-08 10:10:03 +00:00
Neels Hofmeyr 5a602b752b less verbose origins on interface enable/disable
Change-Id: Ia59b3e6a9617f1b9e8dc0c488846a9fb0ec8f566
2017-05-07 01:22:14 +00:00
Neels Hofmeyr 035cda8483 fix: handle dbus signals outside of the glib main loop
Collect incoming signals in a defer queue and handle them once the DBus polling
is through.

Related: OS#2220

Change-Id: Ic7520f2165888a4ee0f83b779cd58d20c4e45fa0
2017-05-07 01:21:28 +00:00
Neels Hofmeyr fd39f3eb81 osmo-bts-trx: wait for osmo-trx to launch before proceeding
Change-Id: I34feaf27b245f34a47f04cfacebdd19537eed44f
2017-05-07 01:15:57 +00:00
Neels Hofmeyr b69cebc5a3 osmo-bts-trx: add -x to use the external oscillator
Change-Id: I94ea9ab454d3d73b6d363209282df77d562d45dc
2017-05-07 01:15:50 +00:00
Neels Hofmeyr 9741de30d5 bts config: tweak logging parameters
The BTS logs grew exceptionally large because of logging 'level all debug'.

Change-Id: I2901bf47a7b12aabcbd416ca7da49db886a061d5
2017-05-07 01:14:58 +00:00
Neels Hofmeyr 506edbc869 jenkins: fix trials-cleanup.sh: use 'taken' marker
trials-cleanup.sh was still using the old 'SEEN' marker and thus didn't work.

In trial.py, make sure that *every* trial that is run is marked as taken, not
only those discovered by Trial.next().

Change-Id: I8aa6b2eece5d43266a7c84e6b2974b8fe7f3cda1
2017-05-07 01:14:23 +00:00
Neels Hofmeyr 930ac952aa fix osmo-gsm-tester.py -t option
Option to select test names had code rot. Use loaded suite definitions
properly.

Change-Id: I24f0a87a017f211f3a30fb98556a392f2a35be7b
2017-05-07 01:13:23 +00:00
Neels Hofmeyr c86ab211c9 fix resource error reporting for unavailable resource
On failure to find an unused resource (in case a test tries to use more
resources than are reserved), the handling code had a bug: print
reserved_resources from the proper source, i.e. suite_run.

Change-Id: Ifdc4201581b3293605196292339e841543ea284e
2017-05-06 23:07:42 +00:00
Neels Hofmeyr 8d8b03e1e3 compose SMS with more descriptive text
Allow tokens to be passed for SMS composition, and use that to pass MO and MT
modem names into the SMS text for easier debugging.

Change-Id: I5e0d066ffa7a4631e8568c6cd4f210627f209122
2017-05-06 22:29:45 +02:00
Neels Hofmeyr cf1e20ebe6 ofono_client: drop explicit exception catching
For some reason the code there catches exceptions happening while interfaces
are being established. That's not a good idea, drop it.

Related: OS#2220
Change-Id: Ida7731ed6ff3cad44ff437137abe2d6a424fcaa4
2017-05-05 18:36:37 +02:00
Neels Hofmeyr ef9ed2d3eb config: resolve real paths from symlinks, add paths debug logging
Tweak test expectations to include the new debug logging.

Go through the paths in alphabetical order to get deterministic logging output,
so the test expectations always match.

Change-Id: I11a905b2467cda691d9ccea30ae436bac96476c9
2017-05-04 20:56:48 +00:00
Pau Espin 107f2751a7 ofono_client: Sort events more logically
Change-Id: I515203a14cf629e789a7f7659d43126898ab4534
2017-05-04 20:56:38 +00:00
Pau Espin 504a664ca6 ofono_client: Allow other ifaces in some methods
Change-Id: Ic6df1e9c3f8948f694182bd2924753ae3cbe99ee
2017-05-04 20:56:38 +00:00
Neels Hofmeyr 51cfd8e195 fix sysmobts: also use username for dsp firmware reload command 2017-05-04 15:52:08 +02:00
Pau Espin 3895fec34b Add remote user for RemoteProcress
Use it to set root user for SysmoBTS, otherwise if osmo-gsm-tester is
run by another user it will fail to connect

Change-Id: I67d4126fc75cb9c2d249c713cd6f14db1f1e21da
2017-05-04 13:16:21 +00:00
Neels Hofmeyr 96ed9ab14d sysmobts: fix: reload firmware before each osmo-bts-sysmo run 2017-05-04 14:30:39 +02:00
Neels Hofmeyr 8dbad8701f nitb,sysmobts: tweak config
Set saner MCC+MNC, use more power.
2017-05-04 14:29:49 +02:00
Neels Hofmeyr 943f8a28d7 fixup: ofono: try a different way to catch missing dbus interfaces
Change-Id: Ifec1127d8ae38ca98f4d8e203b812ca16dee786e
2017-05-03 17:37:53 +02:00
Neels Hofmeyr 5fe88817d1 ofono: try a different way to catch missing dbus interfaces
The nested wait was definitely a bad idea. This here is certainly not very
nice either, but an attempt to catch cases where a dbus interface cannot
be used yet despite being signalled by ofono (sporadically happens).

Change-Id: I2ac7eb0f5174250f4b97e2bf758666410d8cb854
2017-05-03 17:20:17 +02:00
Neels Hofmeyr 93f5866bd2 cosmetic: rename ofono_client.get() to .systembus_get()
Change-Id: Iccce22fd4f07803e2468a2089f565d41e9a2cd9a
2017-05-03 16:32:16 +02:00
Neels Hofmeyr f1a9029514 fix resources: msisdn must not be too short, start with 1000 2017-05-02 16:31:15 +02:00
Neels Hofmeyr 24bfcee8ad fix: Modem.msisdn is not a function 2017-05-02 16:30:49 +02:00