summaryrefslogtreecommitdiffstats
path: root/src/osmo_gsm_tester/process.py
AgeCommit message (Collapse)AuthorFilesLines
2019-09-10process: Introduce respawn_sync() methodPau Espin Pedrol1-0/+7
Change-Id: Ifd1f553d9bead78bf1659f6c778c1b70888ba433
2019-09-10process: respawn(): return process resultPau Espin Pedrol1-1/+1
Change-Id: Ic6b57b8d0c2993a40ba39b87f45c7a524a8ca440
2019-04-05processes: Fix kill of processes run under sudoPau Espin Pedrol1-0/+11
sudo drops forwarding of signals sent by processes of the same process group, which means by default will drop signals from parent and children processes. By moving it to another group, we will later be able to kill it. Note: sudo documentation is wrong, since it states it only drops signals from children. See following link for more information: https://stackoverflow.com/questions/34337840/cant-terminate-a-sudo-process-created-with-python-in-ubuntu-15-10 Change-Id: I25990234aaa496c501ff45ad7f7fd549d6f188da
2019-04-04process: Early return during process termination if no proc runningPau Espin Pedrol1-1/+6
This avoids extra unneeded logging about killing with signal when actually no signal is being sent. Change-Id: I5b5dd78fe3301d8eef2ab93da3b37029268ae198
2019-04-03process: Prevent NetNSProcess alive forever after SIGKILLPau Espin Pedrol1-0/+5
NetNSProcess are run in the following process tree: osmo-gsm-tester -> sudo -> bash (osmo-gsm-tester_netns_exec.sh) -> tcpdump. Lots of osmo-gsm-tester_netns_exec.sh scripts with tcpdump child process were spotted in prod setup of osmo-gsm-tester. Apparently that happens because sometimes tcpdump doesn't get killed in time with SIGTERM and SIGINT, and as a result SIGKILL is sent by osmo-gsm-tester as usual termination procedure. When SIGKILL is sent, the parent sudo process is instantly killed without possibility to forward the signal to its children, leaving the bash script and tcpdump alive. In order to fix it, catch SIGKILL for this process class and send instead SIGUSR1. Then, modify the script under sudo to handle SIGUSR1 as if it was a SIGKILL towards its children to make sure child process in the netns terminates. Change-Id: I2bf389c47bbbd75f46af413e7ba897be5be386e1
2019-04-03process: add signal to NetNSProcess kill pathPau Espin Pedrol1-1/+1
This allows to easily differentiate different calls to kill in order to terminate the process when looking at the logs. Change-Id: Ida88f2674b0ed1802f20c519aa4e3cbe81e0def8
2019-03-05process: Make killing processes non-sequentialHolger Hans Peter Freyther1-3/+73
Change-Id: Icf1ac6774ea11880542012fd6c6ac73302bb74f5
2019-03-04process: Make sending signals (kill) externally visibleHolger Hans Peter Freyther1-9/+9
Change-Id: I87bba8a8c467ba5936e0b6604d8abb9432e5e7a8
2019-03-04process: Speed-up terminating lots of processes by batching itHolger Hans Peter Freyther1-0/+26
Introduce a strategy to terminate processes and begin with an implementation for parallel (that has no degree of parallelism right now). Change-Id: I7dd4a7e26aca758198aa08a434eaf5f3f5af632d
2018-11-12process: launch_sync: allow non success returnPau Espin Pedrol1-3/+4
Change-Id: I0617335b594ba565cf2e5ffd0edfb8bffa398c48
2018-11-12process: Move standalone run_local_sync as method of ProcessPau Espin Pedrol1-14/+18
Change-Id: Ib2b3fd39db5400a93a8caabae367dac3e3250247
2018-10-31Add support to test gprs IPv4 data planePau Espin Pedrol1-3/+27
Since the modem iface and the GGSN iface are on the same host/netns, it's really difficult to conveniently test data plane without getting routing loops. As a result, either GGSN or modem iface must be moved to a different namespace. The decision after a few discussions was finally to move modem interfaces to a different netns. Expected setup: * ofono is patched to avoid removing modem if it detects through udev that its net iface was removed (due to for instance, net iface being moved to another netns and thus not being reachable anymore by systemd-udev process running in root netns). * After ofono is started (and successfully configured all the modems and detected its net ifaces through syfs/udev), script "modem-netns-setup.py start" which creates a netns for each modem, naming it after its usb path ID. net ifaces for that modem are moved into its netns. * Modem is configured to use 802-3 data format, and as a result the net iface is configured through DHCP (DHCP req only replied AFTER pdp ctx is activated!). * Since osmo-gsm-tester knowns the modem USB path ID (available in resources.conf), it can run required steps (ifup, DHCP) to configure the interface. The interface name is provided by ofono to osmo-gsm-tester. * As a result, any process willing to transmit data through the modem must be in the modem netns. Related: OS#2308 Change-Id: Icb06bdfcdd37c797be95ab5addb28da2d9f6681c
2018-10-26process: Make sure sync process is terminated if ogt is stoppedPau Espin Pedrol1-12/+13
Change-Id: Iecdac96ea576a312be2a6c6b6799e249074687ef
2018-10-02osmotrx: Make sure remote process stops after ssh session is closedPau Espin Pedrol1-1/+4
First of all, it was found that vty allocation must be forced (-t -t) during ssh session creation to make sure SIGHUP is forwarded when session is closed. Second, since osmo-trx ignores SIGHUP (osmo_init_ignore_signals()), we must add a wrapper script which converts received SIGHUP into a SIGINT to stop osmo-trx. Change-Id: Ic334a54b1a1827d74fe0b453ac32bb77b8616147
2018-10-02Make code copying inst through ssh genericPau Espin Pedrol1-0/+37
It can later on be used by other classes that need to run binaries in inst remotely. Change-Id: I838b999528695207e1147cfe76e6f7aaf3b1dd53
2018-08-13Cleanup of class scoped variablesPau Espin Pedrol1-5/+3
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
2018-05-25Add option to expect bts/pcu failures and respawn its processesPau Espin Pedrol1-0/+7
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-25process: Move cleanup log inside cleanup methodPau Espin Pedrol1-1/+1
Change-Id: I72ad453e9dc8340946d7e7d041643fe8ef97439f
2018-04-04Drop event_loop global functions and import MainLoopPau Espin Pedrol1-2/+3
Take the chance to identify and drop modules importing event_loop but not using it. Change-Id: Ifa1940cd00138ebc72fbcfd45a0e28246f7a5ed9
2017-11-12modem, process: Remove unneeded test importPau Espin Pedrol1-1/+1
Change-Id: Icd8cbb753aafdef49bde56bc5b0294f82133887c
2017-07-03Add microsecond accuracy to log timestampsPau Espin Pedrol1-1/+2
This is useful while debugging and trying to check events across other outputs such as pcap files, process logs, etc. Change-Id: I43bb5c6e9977189251802bc2b078c52eb046bab8
2017-06-13fix and refactor logging: drop 'with', simplifyNeels Hofmeyr1-19/+16
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-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-25event_loop: Create a global event loop to poll and wait for eventsPau Espin Pedrol1-2/+2
Tweaked-by: nhofmeyr Change-Id: Iaa78bae0f053496377609b24a11ebaef3fd77598
2017-05-08fix prompt()Neels Hofmeyr1-0/+1
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-04Add remote user for RemoteProcressPau Espin Pedrol1-2/+3
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-04-10trying to get sysmobts to work and various detailsNeels Hofmeyr1-14/+23
I know that these commit messages aren't very good, but the code is not stable yet, so I'm not bothering with details. Change-Id: I2d5e5f4a5407725d71093cbd71ef97b271eb8197
2017-04-09make prematurely exited processes fail the testNeels Hofmeyr1-2/+17
Change-Id: I54394c40718b44378df597e32003742059052869
2017-04-08core implementationNeels Hofmeyr1-0/+183
code bomb implementing the bulk of the osmo-gsm-tester Change-Id: I53610becbf643ed51b90cfd9debc6992fe211ec9
2017-03-28initial import0.1Neels Hofmeyr1-0/+23
The original osmo-gsm-tester was an internal development at sysmocom, mostly by D. Laszlo Sitzer <dlsitzer@sysmocom.de>, of which this public osmo-gsm-tester is a refactoring / rewrite. This imports an early state of the refactoring and is not functional yet. Bits from the earlier osmo-gsm-tester will be added as needed. The earlier commit history is not imported.