blob: fb364aa964db2d1263d568ad848f08331dba76ae [file] [log] [blame]
Pau Espin Pedrol06376b72020-05-05 18:39:44 +02001== Installation
Neels Hofmeyrb52df172017-05-14 20:09:35 +02002
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +01003=== Trial Builder
Neels Hofmeyrb52df172017-05-14 20:09:35 +02004
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +01005The Trial Builder is the jenkins build slave (host) building all sysroot binary
6packages used later by {app-name} to run the tests. It's purpose is to build the
7sysroots and provide them to {app-anme}, for instance, as jenkins job artifacts
8which the {app-name} runner job can fetch.
Neels Hofmeyrb52df172017-05-14 20:09:35 +02009
10[[jenkins_deps]]
Pau Espin Pedrolf5c83da2017-11-02 15:48:10 +010011==== Osmocom Build Dependencies
Neels Hofmeyrb52df172017-05-14 20:09:35 +020012
13Each of the jenkins builds requires individual dependencies. This is generally
14the same as for building the software outside of osmo-gsm-tester and will not
15be detailed here. For the Osmocom projects, refer to
16http://osmocom.org/projects/cellular-infrastructure/wiki/Build_from_Source . Be
17aware of specific requirements for BTS hardware: for example, the
18osmo-bts-sysmo build needs the sysmoBTS SDK installed on the build slave, which
19should match the installed sysmoBTS firmware.
20
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +010021==== Add Build Jobs
22
23There are various jenkins-build-* scripts in osmo-gsm-tester/contrib/, which
24can be called as jenkins build jobs to build and bundle binaries as artifacts,
25to be run on the osmo-gsm-tester main unit and/or BTS hardware.
26
27Be aware of the dependencies, as hinted at in <<jenkins_deps>>.
28
29While the various binaries could technically be built on the osmo-gsm-tester
30main unit, it is recommended to use a separate build slave, to take load off
31of the main unit.
32
33Please note nowadays we set up all the osmocom jenkins jobs (including
34{app-name} ones) using 'jenkins-job-builder'. You can find all the
35configuration's in Osmocom's 'osmo-ci.git' files 'jobs/osmo-gsm-tester-*.yml.
36Explanation below on how to set up jobs manually is left as a reference for
37other projects.
38
39On your jenkins master, set up build jobs to call these scripts -- typically
40one build job per script. Look in contrib/ and create one build job for each of
41the BTS types you would like to test, as well as one for the 'build-osmo-nitb'.
42
43These are generic steps to configure a jenkins build
44job for each of these build scripts, by example of the
45jenkins-build-osmo-nitb.sh script; all that differs to the other scripts is the
46"osmo-nitb" part:
47
48* 'Project name': "osmo-gsm-tester_build-osmo-nitb" +
49 (Replace 'osmo-nitb' according to which build script this is for)
50* 'Discard old builds' +
51 Configure this to taste, for example:
52** 'Max # of build to keep': "20"
53* 'Restrict where this project can be run': Choose a build slave label that
54 matches the main unit's architecture and distribution, typically a Debian
55 system, e.g.: "linux_amd64_debian8"
56* 'Source Code Management':
57** 'Git'
58*** 'Repository URL': "git://git.osmocom.org/osmo-gsm-tester"
59*** 'Branch Specifier': "*/master"
60*** 'Additional Behaviors'
61**** 'Check out to a sub-directory': "osmo-gsm-tester"
62* 'Build Triggers' +
63 The decision on when to build is complex. Here are some examples:
64** Once per day: +
65 'Build periodically': "H H * * *"
66** For the Osmocom project, the purpose is to verify our software changes.
67 Hence we would like to test every time our code has changed:
68*** We could add various git repositories to watch, and enable 'Poll SCM'.
69*** On jenkins.osmocom.org, we have various jobs that build the master branches
70 of their respective git repositories when a new change was merged. Here, we
71 can thus trigger e.g. an osmo-nitb build for osmo-gsm-tester everytime the
72 master build has run: +
73 'Build after other projects are built': "OpenBSC"
74*** Note that most of the Osmocom projects also need to be re-tested when their
75 dependencies like libosmo* have changed. Triggering on all those changes
76 typically causes more jenkins runs than necessary: for example, it rebuilds
77 once per each dependency that has rebuilt due to one libosmocore change.
78 There is so far no trivial way known to avoid this. It is indeed safest to
79 rebuild more often.
80* 'Build'
81** 'Execute Shell'
82+
83----
84#!/bin/sh
85set -e -x
86./osmo-gsm-tester/contrib/jenkins-build-osmo-nitb.sh
87----
88+
89(Replace 'osmo-nitb' according to which build script this is for)
90
91* 'Post-build Actions'
92** 'Archive the artifacts': "*.tgz, *.md5" +
93 (This step is important to be able to use the built binaries in the run job
94 below.)
95
96
97TIP: When you've created one build job, it is convenient to create further
98build jobs by copying the first one and, e.g., simply replacing all "osmo-nitb"
99with "osmo-bts-trx".
100
101[[install_main_unit]]
102=== Main Unit
103
104The main unit is a general purpose computer that orchestrates the tests. It
105runs the core network components, controls the modems and so on. This can be
106anything from a dedicated production rack unit to your laptop at home.
107
108This manual will assume that tests are run from a jenkins build slave, by a user
109named 'jenkins' that belongs to group 'osmo-gsm-tester'. The user configuration
110for manual test runs and/or a different user name is identical, simply replace
111the user name or group.
112
113Please, note installation steps and dependencies needed will depend on lots of
114factors, like your distribution, your specific setup, which hardware you plan to
115support, etc.
116
117This section aims at being one place to document the rationale behind certain
118configurations being done in one way or another. For an up to date step by step
119detailed way to install and maintain the Osmocom {app-name} setup, one will want
120to look at the <<ansible,ansible scripts section>>.
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200121
Pau Espin Pedrolf5c83da2017-11-02 15:48:10 +0100122[[configure_jenkins_slave]]
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100123==== Create 'jenkins' User
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200124
125On the main unit, create a jenkins user:
126
127----
128useradd -m jenkins
129----
130
Neels Hofmeyr3f596ed2017-07-14 00:04:40 +0200131==== Install Java on Main Unit
132
133To be able to launch the Jenkins build slave, a Java RE must be available on
134the main unit. For example:
135
136----
137apt-get install default-jdk
138----
139
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200140==== Allow SSH Access from Jenkins Master
141
142Create an SSH keypair to be used for login on the osmo-gsm-tester. This may be
143entered on the jenkins web UI; alternatively, use the jenkins server's shell:
144
145Login on the main jenkins server shell and create an SSH keypair, for example:
146
147----
148# su jenkins
Neels Hofmeyr3f596ed2017-07-14 00:04:40 +0200149$ mkdir -p /usr/local/jenkins/keys
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200150$ ssh-keygen
151Generating public/private rsa key pair.
152Enter file in which to save the key (/home/jenkins/.ssh/id_rsa): /usr/local/jenkins/keys/osmo-gsm-tester-rnd
153Enter passphrase (empty for no passphrase): <enter a passphrase>
154Enter same passphrase again: <enter a passphrase>
155Your identification has been saved in /usr/local/jenkins/keys/osmo-gsm-tester-rnd
156Your public key has been saved in /usr/local/jenkins/keys/osmo-gsm-tester-rnd.pub.
157The key fingerprint is:
158...
159----
160
161Copy the public key to the main unit, e.g. copy-paste:
162
163----
164cat /usr/local/jenkins/keys/osmo-gsm-tester-rnd.pub
165# copy this public key
166----
167
168On the main unit:
169
170----
171mkdir ~jenkins/.ssh
172cat > ~jenkins/.ssh/authorized_keys
173# paste above public key and hit Ctrl-D
174chown -R jenkins: ~jenkins/.ssh
175----
176
177Make sure that the user running the jenkins master accepts the main unit's host
178identification. There must be an actual RSA host key available in the
179known_hosts file for the jenkins master to be able to log in. Simply calling
180ssh and accepting the host key as usual is not enough. Jenkins may continue to
181say "Host key verification failed".
182
183To place an RSA host key in the jenkins' known_hosts file, you may do:
184
185On the Jenkins master:
186
187----
188main_unit_ip=10.9.8.7
189ssh-keyscan -H $main_unit_ip >> ~jenkins/.ssh/known_hosts
190chown jenkins: ~jenkins/.ssh/known_hosts
191----
192
193Verify that the jenkins user on the Jenkins master has SSH access to the main
194unit:
195
196----
197su jenkins
198main_unit_ip=10.9.8.7
Neels Hofmeyr3f596ed2017-07-14 00:04:40 +0200199ssh -i /usr/local/jenkins/keys/osmo-gsm-tester-rnd jenkins@$main_unit_ip
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200200exit
201----
202
Pau Espin Pedrolf5c83da2017-11-02 15:48:10 +0100203[[install_add_jenkins_slave]]
204==== Add Jenkins Slave
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200205
206In the jenkins web UI, add a new build slave for the osmo-gsm-tester:
207
208* 'Manage Jenkins'
209** 'Manage Nodes'
210*** 'New Node'
211**** Enter a node name, e.g. "osmo-gsm-tester-1" +
212 (the "-1" is just some identification in case you'd like to add another
213 setup later).
214**** 'Permanent Agent'
215
216Configure the node as:
217
218* '# of executors': 1
219* 'Remote root directory': "/home/jenkins"
220* 'Labels': "osmo-gsm-tester" +
221 (This is a general label common to all osmo-gsm-tester build slaves you may set up in the future.)
222* 'Usage': 'Only build jobs with label expressions matching this node'
223* 'Launch method': 'Launch slave agents via SSH'
224** 'Host': your main unit's IP address
225** 'Credentials': choose 'Add' / 'Jenkins'
226*** 'Domain': 'Global credentials (unrestricted)'
227*** 'Kind': 'SSH Username with private key'
228*** 'Scope': 'Global'
229*** 'Username': "jenkins" +
230 (as created on the main unit above)
231*** 'Private Key': 'From a file on Jenkins master'
232**** 'File': "/usr/local/jenkins/keys/osmo-gsm-tester-rnd"
233*** 'Passphrase': enter same passphrase as above
234*** 'ID': "osmo-gsm-tester-1"
235*** 'Name': "jenkins for SSH to osmo-gsm-tester-1"
236
237The build slave should be able to start now.
238
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200239==== Add Run Job
240
Pau Espin Pedrolf5c83da2017-11-02 15:48:10 +0100241This is the jenkins job that runs the tests on the GSM hardware:
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200242
Pau Espin Pedrolf5c83da2017-11-02 15:48:10 +0100243* It sources the artifacts from jenkins' build jobs.
244* It runs on the osmo-gsm-tester main unit.
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200245
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100246Sample script to run {app-name} as a jenkins job can be found in
247'osmo-gsm-tester.git' file 'contrib/jenkins-run.sh'.
248
249Please note nowadays we set up all the osmocom jenkins jobs (including
250{app-name} ones) using 'jenkins-job-builder'. You can find all the
251configuration's in Osmocom's 'osmo-ci.git' files 'jobs/osmo-gsm-tester-*.yml.
252Explanation below on how to set up jobs manually is left as a reference for
253other projects.
254
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200255Here is the configuration for the run job:
256
257* 'Project name': "osmo-gsm-tester_run"
258* 'Discard old builds' +
259 Configure this to taste, for example:
260** 'Max # of build to keep': "20"
261* 'Restrict where this project can be run': "osmo-gsm-tester" +
Pau Espin Pedrolf5c83da2017-11-02 15:48:10 +0100262 (to match the 'Label' configured in <<install_add_jenkins_slave>>).
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200263* 'Source Code Management':
264** 'Git'
265*** 'Repository URL': "git://git.osmocom.org/osmo-gsm-tester"
266*** 'Branch Specifier': "*/master"
267*** 'Additional Behaviors'
268**** 'Check out to a sub-directory': "osmo-gsm-tester"
269**** 'Clean before checkout'
270* 'Build Triggers' +
271 The decision on when to build is complex. For this run job, it is suggested
272 to rebuild:
273** after each of above build jobs that produced new artifacts: +
274 'Build after other projects are built': "osmo-gsm-tester_build-osmo-nitb,
275 osmo-gsm-tester_build-osmo-bts-sysmo, osmo-gsm-tester_build-osmo-bts-trx" +
276 (Add each build job name you configured above)
277** as well as once per day: +
278 'Build periodically': "H H * * *"
279** and, in addition, whenever the osmo-gsm-tester scripts have been modified: +
280 'Poll SCM': "H/5 * * * *" +
281 (i.e. look every five minutes whether the upstream git has changed)
282* 'Build'
283** Copy artifacts from each build job you have set up:
284*** 'Copy artifacts from another project'
285**** 'Project name': "osmo-gsm-tester_build-osmo-nitb"
286**** 'Which build': 'Latest successful build'
287**** enable 'Stable build only'
288**** 'Artifacts to copy': "*.tgz, *.md5"
289*** Add a separate similar 'Copy artifacts...' section for each build job you
290 have set up.
291** 'Execute Shell'
292+
293----
294#!/bin/sh
295set -e -x
296
297# debug: provoke a failure
298#export OSMO_GSM_TESTER_OPTS="-s debug -t fail"
299
300PATH="$PWD/osmo-gsm-tester/src:$PATH" \
301 ./osmo-gsm-tester/contrib/jenkins-run.sh
302----
303+
304Details:
305
306*** The 'jenkins-run.sh' script assumes to find the 'osmo-gsm-tester.py' in the
307 '$PATH'. To use the most recent osmo-gsm-tester code here, we direct
308 '$PATH' to the actual workspace checkout. This could also run from a sytem
309 wide install, in which case you could omit the explicit PATH to
310 "$PWD/osmo-gsm-tester/src".
311*** This assumes that there are configuration files for osmo-gsm-tester placed
Pau Espin Pedrolffa325e2020-06-10 17:49:55 +0200312 on the system (see <<config_main>>).
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200313*** If you'd like to check the behavior of test failures, you can uncomment the
314 line below "# debug" to produce a build failure on every run. Note that
315 this test typically produces a quite empty run result, since it launches no
316 NITB nor BTS.
317* 'Post-build Actions'
318** 'Archive the artifacts'
Neels Hofmeyr8d8a1362017-06-18 02:31:38 +0200319*** 'Files to archive': "*-run.tgz, *-bin.tgz" +
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200320 This stores the complete test report with config files, logs, stdout/stderr
Neels Hofmeyr8d8a1362017-06-18 02:31:38 +0200321 output, pcaps as well as the binaries used for the test run in artifacts.
322 This allows analysis of older builds, instead of only the most recent build
323 (which cleans up the jenkins workspace every time). The 'trial-N-run.tgz'
324 and 'trial-N-bin.tgz' archives are produced by the 'jenkins-run.sh' script,
325 both for successful and failing runs.
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200326
Pau Espin Pedrol0baa5c72020-05-05 19:08:13 +0200327==== Install osmo-gsm-tester dependencies
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200328
Pau Espin Pedrolf5c83da2017-11-02 15:48:10 +0100329This assumes you have already created the jenkins user (see <<configure_jenkins_slave>>).
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200330
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100331Dependencies needed will depend on lots of factors, like your distribution, your
332specific setup, which hardware you plan to support, etc.
333
Pau Espin Pedrol0baa5c72020-05-05 19:08:13 +0200334On a Debian/Ubuntu based system, these commands install the mandatory packages
335needed to run the osmo-gsm-tester.py code, i.e. install these on your main unit:
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100336
337----
338apt-get install \
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100339 python3 \
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100340 python3-yaml \
341 python3-mako \
342 python3-gi \
Pau Espin Pedrol600c7992020-11-09 21:17:51 +0100343 python3-watchdog \
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100344 locales
Pau Espin Pedrol0baa5c72020-05-05 19:08:13 +0200345----
346
347If one plans to use the 2G ESME (_esme.py_), following extra dependencies shall
348be installed:
349----
350apt-get install python3-setuptools python3-pip
351pip3 install "git+https://github.com/podshumok/python-smpplib.git@master#egg=smpplib"
352----
353
354If one plans to use the 2G OsmoHLR (_hlr_osmo.py_), following extra dependencies shall
355be installed:
356----
357apt-get install sqlite3
358----
359
360If one plans to use SISPM power supply hardware (_powersupply_sispm.py_),
361following extra dependencies shall be installed:
362----
363apt-get install python3-setuptools python3-pip
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100364pip3 install \
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100365 pyusb \
366 pysispm
367----
368
Pau Espin Pedrol0baa5c72020-05-05 19:08:13 +0200369If one plans to use software-based RF emulation on Amarisoft ENB implemented
370through its CTRL interface (_rfemu_amarisoftctrl.py_), following extra
371dependencies shall be installed:
372----
373apt-get install python3-websocket
374----
375
376If one plans to use srsLTE UE metrics subsystems (_ms_srs.py_), following extra
377dependencies shall be installed:
378----
379apt-get install python3-numpy
380----
381
382If one plans to use ofono modems (_ms_ofono.py_), following extra dependencies
383shall be installed:
384----
385apt-get install \
386 dbus \
387 python3 \
388 ofono \
389 python3-pip \
390 udhcpc
391pip3 install \
392 pydbus
393----
394
Pau Espin Pedrol0696c602021-03-16 14:25:37 +0100395If one plans to use Open5GS EPC, pymongo modules to interact against MongoDB
396(_epc_open5gs.py_) shall be installed:
397----
398pip3 install \
399 pymongo
400----
401
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100402IMPORTANT: ofono may need to be installed from source to contain the most
403recent fixes needed to operate your modems. This depends on the modem hardware
404used and the tests run. Please see <<hardware_modems>>.
405
Pau Espin Pedrol0baa5c72020-05-05 19:08:13 +0200406Finally, these programs are usually required by osmo-gsm-tester on the Slave Unit to run and manage processes:
407
408----
409apt-get install \
410 tcpdump \
411 patchelf \
412 sudo \
413 libcap2-bin \
414 iperf3
415----
416
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200417==== User Permissions
418
419On the main unit, create a group for all users that should be allowed to use
420the osmo-gsm-tester, and add users (here 'jenkins') to this group.
421
422----
423groupadd osmo-gsm-tester
424gpasswd -a jenkins osmo-gsm-tester
425----
426
427NOTE: you may also need to add users to the 'usrp' group, see
428<<user_config_uhd>>.
429
430A user added to a group needs to re-login for the group permissions to take
431effect.
432
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200433===== Paths
434
435Assuming that you are using the example config, prepare a system wide state
436location in '/var/tmp':
437
438----
439mkdir -p /var/tmp/osmo-gsm-tester/state
440chown -R :osmo-gsm-tester /var/tmp/osmo-gsm-tester
441chmod -R g+rwxs /var/tmp/osmo-gsm-tester
442setfacl -d -m group:osmo-gsm-tester:rwx /var/tmp/osmo-gsm-tester/state
443----
444
445IMPORTANT: the state directory needs to be shared between all users potentially
446running the osmo-gsm-tester to resolve resource allocations. Above 'setfacl'
447command sets the access control to keep all created files group writable.
448
449With the jenkins build as described here, the trials will live in the build
450slave's workspace. Other modes of operation (a daemon scheduling concurrent
451runs, *TODO*) may use a system wide directory to manage trials to run:
452
453----
454mkdir -p /var/tmp/osmo-gsm-tester/trials
455chown -R :osmo-gsm-tester /var/tmp/osmo-gsm-tester
456chmod -R g+rwxs /var/tmp/osmo-gsm-tester
457----
458
459===== Allow DBus Access to ofono
460
461Put a DBus configuration file in place that allows the 'osmo-gsm-tester' group
462to access the org.ofono DBus path:
463
464----
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100465# cat > /etc/dbus-1/system.d/osmo-gsm-tester.conf <<END
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200466<!-- Additional rules for the osmo-gsm-tester to access org.ofono from user
467 land -->
468
469<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
470 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
471<busconfig>
472
473 <policy group="osmo-gsm-tester">
474 <allow send_destination="org.ofono"/>
475 </policy>
476
477</busconfig>
478END
479----
480
481(No restart of dbus nor ofono necessary.)
482
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100483[[install_slave_unit]]
484=== Slave Unit(s)
485
486The slave units are the hosts used by {app-name} to run proceses on. It may be
487the <<install_main_unit,Main Unit>> itself and processes will be run locally, or
488it may be a remote host were processes are run usually through SSH.
489
490This guide assumes slaves unit(s) use same configuration as the Main Unit, that
491is, it runs under 'jenkins' user which is a member of the 'osmo-gsm-tester' user
492group. In order to do so, follow the instruction under the
493<<install_main_unit,Main Unit>> section above. Keep in mind the 'jenkins' user
494on the Main Unit will need to be able to log in through SSH as the slave unit
495'jenkins' user to run the processes. No direct access from Jenkins Master node
496is required here.
497
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200498[[install_capture_packets]]
Pau Espin Pedrol71a54fb2020-03-14 19:20:03 +0100499==== Capture Packets
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200500
501In order to allow collecting pcap traces of the network communication for later
502reference, allow the osmo-gsm-tester group to capture packets using the 'tcpdump'
503program:
504
505----
506chgrp osmo-gsm-tester /usr/sbin/tcpdump
507chmod 750 /usr/sbin/tcpdump
508setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump
509----
510
511Put 'tcpdump' in the '$PATH' -- assuming that 'tcpdump' is available for root:
512
513----
514ln -s `which tcpdump` /usr/local/bin/tcpdump
515----
516
517TIP: Why a symlink in '/usr/local/bin'? On Debian, 'tcpdump' lives in
518'/usr/sbin', which is not part of the '$PATH' for non-root users. To avoid
519hardcoding non-portable paths in the osmo-gsm-tester source, 'tcpdump' must be
520available in the '$PATH'. There are various trivial ways to modify '$PATH' for
521login shells, but the jenkins build slave typically runs in a *non-login*
522shell; modifying non-login shell enviroments is not trivially possible without
523also interfering with files installed from debian packages. Probably the
524easiest way to allow all users and all shells to find the 'tcpdump' binary is
525to actually place a symbolic link in a directory that is already part of the
526non-login shell's '$PATH'. Above example places such in '/usr/local/bin'.
527
528Verify that a non-login shell can find 'tcpdump':
529
530----
531su jenkins -c 'which tcpdump'
532# should print: "/usr/local/bin/tcpdump"
533----
534
535WARNING: When logged in via SSH on your main unit, running 'tcpdump' to capture
536packets may result in a feedback loop: SSH activity to send tcpdump's output to
537your terminal is in turn is picked up in the tcpdump trace, and so forth. When
538testing 'tcpdump' access, make sure to have proper filter expressions in place.
539
Pau Espin Pedrol71a54fb2020-03-14 19:20:03 +0100540==== Allow Core Files
Pau Espin Pedrol018e1042017-08-28 11:58:25 +0200541
542In case a binary run for the test crashes, a core file of the crash should be
543written. This requires a limit rule. Create a file with the required rule:
544
545----
546sudo -s
547echo "@osmo-gsm-tester - core unlimited" > /etc/security/limits.d/osmo-gsm-tester_allow-core.conf
548----
549
550Re-login the user to make these changes take effect.
551
552Set the *kernel.core_pattern* sysctl to *core* (usually the default). For each
553binary run by osmo-gsm-tester, a core file will then appear in the same dir that
554contains stdout and stderr for that process (because this dir is set as CWD).
555
556----
557sysctl -w kernel.core_pattern=core
558----
559
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100560TIP: Files required to be installed under '/etc/security/limits.d/' can be found
561under 'osmo-gsm-tester.git/utils/limits.d/', so one can simply cp them from
562there.
563
Pau Espin Pedrol71a54fb2020-03-14 19:20:03 +0100564==== Allow Realtime Priority
Pau Espin Pedrol018e1042017-08-28 11:58:25 +0200565
566Certain binaries should be run with real-time priority, like 'osmo-bts-trx'.
567Add this permission on the main unit:
568
569----
570sudo -s
571echo "@osmo-gsm-tester - rtprio 99" > /etc/security/limits.d/osmo-gsm-tester_allow-rtprio.conf
572----
573
574Re-login the user to make these changes take effect.
575
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100576TIP: Files required to be installed under '/etc/security/limits.d/' can be found
577under 'osmo-gsm-tester.git/utils/limits.d/', so one can simply cp them from
578there.
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200579
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100580===== Allow capabilities: 'CAP_NET_RAW', 'CAP_NET_ADMIN', 'CAP_SYS_ADMIN'
Pau Espin Pedrol8ad5e6a2017-11-02 16:08:05 +0100581
582Certain binaries require 'CAP_NET_RAW' to be set, like 'osmo-bts-octphy' as it
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100583uses a 'AF_PACKET' socket. Similarly, others (like osmo-ggsn) require
584'CAP_NET_ADMIN' to be able to create tun devices, and so on.
Pau Espin Pedrol8ad5e6a2017-11-02 16:08:05 +0100585
586To be able to set the following capability without being root, osmo-gsm-tester
587uses sudo to gain permissions to set the capability.
588
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100589This is the script that osmo-gsm-tester expects on the host running the process:
Pau Espin Pedrol8ad5e6a2017-11-02 16:08:05 +0100590
591----
592echo /usr/local/bin/osmo-gsm-tester_setcap_net_raw.sh <<EOF
593#!/bin/bash
594/sbin/setcap cap_net_raw+ep $1
595EOF
596chmod +x /usr/local/bin/osmo-gsm-tester_setcap_net_raw.sh
597----
598
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100599Now, again on the same host, we need to provide sudo access to this script for
Pau Espin Pedrol8ad5e6a2017-11-02 16:08:05 +0100600osmo-gsm-tester:
601
602----
603echo "%osmo-gsm-tester ALL=(root) NOPASSWD: /usr/local/bin/osmo-gsm-tester_setcap_net_raw.sh" > /etc/sudoers.d/osmo-gsm-tester_setcap_net_raw
604chmod 0440 /etc/sudoers.d/osmo-gsm-tester_setcap_net_raw
605----
606
607The script file name 'osmo-gsm-tester_setcap_net_raw.sh' is important, as
608osmo-gsm-tester expects to find a script with this name in '$PATH' at run time.
609
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100610TIP: Files required to be installed under '/etc/sudoers.d/' can be found
611under 'osmo-gsm-tester.git/utils/sudoers.d/', so one can simply cp them from
612there.
613
614TIP: Files required to be installed under '/usr/local/bin/' can be found
615under 'osmo-gsm-tester.git/utils/bin/', so one can simply cp them from
616there.
617
618[[user_config_uhd]]
Pau Espin Pedrol71a54fb2020-03-14 19:20:03 +0100619==== UHD
Pau Espin Pedrol7e0b2dd2020-03-10 11:46:39 +0100620
621Grant permission to use the UHD driver to run USRP devices for osmo-bts-trx, by
622adding the jenkins user to the 'usrp' group:
623
624----
625gpasswd -a jenkins usrp
626----
627
628To run osmo-bts-trx with a USRP attached, you may need to install a UHD driver.
629Please refer to http://osmocom.org/projects/osmotrx/wiki/OsmoTRX#UHD for
630details; the following is an example for the B200 family USRP devices:
631
632----
633apt-get install libuhd-dev uhd-host
634/usr/lib/uhd/utils/uhd_images_downloader.py
635----
Pau Espin Pedrol8ad5e6a2017-11-02 16:08:05 +0100636
Neels Hofmeyr74689532017-09-05 19:43:02 +0200637==== Log Rotation
638
639To avoid clogging up /var/log, it makes sense to choose a sane maximum log size:
640
641----
642echo maxsize 10M > /etc/logrotate.d/maxsize
643----
644
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200645==== Install Scripts
646
647IMPORTANT: When using the jenkins build slave as configured above, *there is no
648need to install the osmo-gsm-tester sources on the main unit*. The jenkins job
649will do so implicitly by checking out the latest osmo-gsm-tester sources in the
650workspace for every run. If you're using only the jenkins build slave, you may
651skip this section.
652
653If you prefer to use a fixed installation of the osmo-gsm-tester sources
654instead of the jenkins workspace, you can:
655
656. From the run job configured above, remove the line that says
657+
658----
659PATH="$PWD/osmo-gsm-tester/src:$PATH" \
660----
661+
662so that this uses a system wide installation instead.
663
664. Install the sources e.g. in '/usr/local/src' as indicated below.
665
666On the main unit, to install the latest in '/usr/local/src':
667
668----
669apt-get install git
670mkdir -p /usr/local/src
671cd /usr/local/src
672git clone git://git.osmocom.org/osmo-gsm-tester
673----
674
675To allow all users to run 'osmo-gsm-tester.py', from login as well as non-login
676shells, the easiest solution is to place a symlink in '/usr/local/bin':
677
678----
679ln -s /usr/local/src/osmo-gsm-tester/src/osmo-gsm-tester.py /usr/local/bin/
680----
681
682(See also the tip in <<install_capture_packets>> for a more detailed
683explanation.)
684
685The example configuration provided in the source is suitable for running as-is,
686*if* your hardware setup matches (you could technically use that directly by a
687symlink e.g. from '/usr/local/etc/osmo-gsm-tester' to the 'example' dir). If in
688doubt, rather copy the example, point 'paths.conf' at the 'suites' dir, and
689adjust your own configuration as needed. For example:
690
691----
692cd /etc
693cp -R /usr/local/src/osmo-gsm-tester/example osmo-gsm-tester
Pau Espin Pedrol69488f62020-04-07 16:40:41 +0200694sed -i 's#\./suites#/usr/local/src/osmo-gsm-tester/suites#' osmo-gsm-tester/paths.conf
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200695----
696
697NOTE: The configuration will be looked up in various places, see
Pau Espin Pedrolffa325e2020-06-10 17:49:55 +0200698<<config_main>>.