aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo_gsm_tester/osmo_nitb.py
AgeCommit message (Collapse)AuthorFilesLines
2020-04-10Rename object classes to be {obj_class}_{implementation}Pau Espin Pedrol1-234/+0
Change-Id: Ieafd96d7ee5b4baef08ca767629b93834f6a8c7c
2019-02-27pyflakes: Remove assigned but unread variablesHolger Hans Peter Freyther1-2/+0
Change-Id: Ie257ac051739ea6f846d1aac2c8f778638b5f8a6
2018-08-13Cleanup of class scoped variablesPau Espin Pedrol1-8/+4
After bug described in OS#3456 and fixed in last commit, let's categorize and place variables in its correct plac to avoid similar issus. We leave under the class keyword (class scoped variables) the attributes which are to be used as static class attributes. All other ones are initialized during __init__(). This way w avoid scenarios in which while using an object from an instance attribute we end up reading a class scoped variable which is shared among all instances. Change-Id: I5ad4cac34a9f49eaf42966c01c9c5a4d3f3e9dc8
2017-12-13OsmoNitb: Introduce bts_is_connected APIPau Espin Pedrol1-0/+27
This can be used by tests to wait until bts is successfully connected to NITB. Change-Id: Idb9b7087e38f638d8b8acbad6dd8ab4218746832
2017-11-20Configure PcapRecorder to record on any ifacePau Espin Pedrol1-2/+1
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-09-16Use own format to specify encryption algorithmPau Espin Pedrol1-1/+4
... 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-08-24Introduce auth_algo modem config attributePau Espin Pedrol1-4/+14
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-23nitb: Introduce subscriber_delete APIPau Espin Pedrol1-0/+17
Change-Id: I62829ed243857681bcc40a4a1861c5c583907f4b
2017-08-23nitb: ctrl: Remove unused return statement in subscriber_addPau Espin Pedrol1-1/+0
In case of failure an exception is raised. If everything goes well no need to return True. Change-Id: I5194eeb9208f973da12f2fa710f2b3e7acd78fb5
2017-08-23Allow tests to select network encryptionPau Espin Pedrol1-0/+9
Change-Id: I273eee44c095690d0c2e3994befa97edc42496ac
2017-06-18Add support for SMPP testingPau Espin Pedrol1-1/+4
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-17Use a subdir of run_dir for each testPau Espin Pedrol1-1/+1
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-13fix and refactor logging: drop 'with', simplifyNeels Hofmeyr1-8/+4
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-12ofono_client: Implement network registration during connect()Pau Espin Pedrol1-0/+10
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-03Re-License under GPLv3-or-later instead of AGPLv3-or-laterHarald Welte1-3/+3
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-05-29config: nitb template: move ip_address to nitb.ip_addressNeels Hofmeyr1-1/+1
It's the NITB's address, so it should go in the nitb.* scope. Change-Id: I71a5ef153b7156b0644253f5aa8a0c848f42ab3b
2017-05-29rename more items from nitb to bscNeels Hofmeyr1-2/+2
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-29rename resource nitb_iface to ip_addressNeels Hofmeyr1-6/+6
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-29debug: config logging before templates: use pprint and an all-caps labelNeels Hofmeyr1-1/+2
Change-Id: I0e1c1d3ce8163d5b40c17b7d0fb0847a068ced76
2017-05-25osmo_nitb.py: remove unused importsNeels Hofmeyr1-2/+0
Change-Id: I55c118c6b277a2c8cddc251e3d36571b12504266
2017-05-22osmo_nitb.py: Remove unused varPau Espin Pedrol1-1/+0
Change-Id: Ifb0c274aac9f8fda177992f19146807387485627
2017-05-15nitb: Filter ssh packets in pcapPau Espin Pedrol1-1/+1
Change-Id: I62a6ae7bd3a84baceb684c26727d2269c86ed023
2017-05-15pcap: pass complete filter string to PcapRecorderNeels Hofmeyr1-2/+2
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-15cosmetic: rather have an underscore in pcap_recorder.pyNeels Hofmeyr1-3/+3
Change-Id: Ib4886cb3fe0cb9c66d170097b98b4d1eb67cab81
2017-05-10Log network activity using tcpdump for nitb interfacePau Espin Pedrol1-1/+5
Change-Id: I4c5d0e2d9857160f905e743517e744f1a06368af
2017-05-08Prepend LD_LIBRARY_PATH instead of overwritting itPau Espin Pedrol1-1/+3
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-04-09wipNeels Hofmeyr1-10/+12
Change-Id: Icce6bd83173db86a64fa621e641131758380c7cd
2017-04-09implement modem and nitb bits for a real testNeels Hofmeyr1-12/+13
Change-Id: I1ca3bd874aed1265d83a46340e9b3e469075c7ee
2017-04-08clearly mark not yet implemented test apiNeels Hofmeyr1-0/+2
Change-Id: Ie0781e618ed49ac31685d69b860e77d791ec5300
2017-04-08various fixes from first test runsYour Name1-3/+6
Change-Id: Ifa5a780dc0123aa84273c57c726c8c1bea563495
2017-04-08core implementationNeels Hofmeyr1-0/+155
code bomb implementing the bulk of the osmo-gsm-tester Change-Id: I53610becbf643ed51b90cfd9debc6992fe211ec9