blob: 41c85e4496373a3ee1d5118fe7fec4f65d590012 [file] [log] [blame]
Neels Hofmeyrb52df172017-05-14 20:09:35 +02001== Installation on Main Unit
2
3The main unit is a general purpose computer that orchestrates the tests. It
4runs the core network components, controls the modems and so on. This can be
5anything from a dedicated production rack unit to your laptop at home.
6
7This manual will assume that tests are run from a jenkins build slave, by a
8user named 'jenkins'. The user configuration for manual test runs and/or a
9different user name is identical, simply replace the user name.
10
11=== Dependencies
12
13On a Debian/Ubuntu based system, these commands install the packages needed to
14run the osmo-gsm-tester.py code, i.e. install these on your main unit:
15
16----
17apt-get install \
18 dbus \
19 tcpdump \
Neels Hofmeyr97110692017-06-03 15:20:28 +020020 sqlite3 \
Neels Hofmeyrb52df172017-05-14 20:09:35 +020021 python3 \
22 python3-yaml \
23 python3-mako \
24 python3-gi \
25 ofono \
26 python3-pip
27pip3 install pydbus
28----
29
30IMPORTANT: ofono may need to be installed from source to contain the most
Neels Hofmeyr7b8dbd82017-05-15 15:28:34 +020031recent fixes needed to operate your modems. This depends on the modem hardware
Neels Hofmeyrb52df172017-05-14 20:09:35 +020032used and the tests run. Please see <<hardware_modems>>.
33
34To run osmo-bts-trx with a USRP attached, you may need to install a UHD driver.
35Please refer to http://osmocom.org/projects/osmotrx/wiki/OsmoTRX#UHD for
36details; the following is an example for the B200 family USRP devices:
37
38----
39apt-get install libuhd-dev uhd-host
40/usr/lib/uhd/utils/uhd_images_downloader.py
41----
42
43[[jenkins_deps]]
44==== Jenkins Build Dependencies
45
46Each of the jenkins builds requires individual dependencies. This is generally
47the same as for building the software outside of osmo-gsm-tester and will not
48be detailed here. For the Osmocom projects, refer to
49http://osmocom.org/projects/cellular-infrastructure/wiki/Build_from_Source . Be
50aware of specific requirements for BTS hardware: for example, the
51osmo-bts-sysmo build needs the sysmoBTS SDK installed on the build slave, which
52should match the installed sysmoBTS firmware.
53
54
55[[configure_build_slave]]
56=== Jenkins Build Slave
57
58==== Create 'jenkins' User on Main Unit
59
60On the main unit, create a jenkins user:
61
62----
63useradd -m jenkins
64----
65
66==== Allow SSH Access from Jenkins Master
67
68Create an SSH keypair to be used for login on the osmo-gsm-tester. This may be
69entered on the jenkins web UI; alternatively, use the jenkins server's shell:
70
71Login on the main jenkins server shell and create an SSH keypair, for example:
72
73----
74# su jenkins
75$ ssh-keygen
76Generating public/private rsa key pair.
77Enter file in which to save the key (/home/jenkins/.ssh/id_rsa): /usr/local/jenkins/keys/osmo-gsm-tester-rnd
78Enter passphrase (empty for no passphrase): <enter a passphrase>
79Enter same passphrase again: <enter a passphrase>
80Your identification has been saved in /usr/local/jenkins/keys/osmo-gsm-tester-rnd
81Your public key has been saved in /usr/local/jenkins/keys/osmo-gsm-tester-rnd.pub.
82The key fingerprint is:
83...
84----
85
86Copy the public key to the main unit, e.g. copy-paste:
87
88----
89cat /usr/local/jenkins/keys/osmo-gsm-tester-rnd.pub
90# copy this public key
91----
92
93On the main unit:
94
95----
96mkdir ~jenkins/.ssh
97cat > ~jenkins/.ssh/authorized_keys
98# paste above public key and hit Ctrl-D
99chown -R jenkins: ~jenkins/.ssh
100----
101
102Make sure that the user running the jenkins master accepts the main unit's host
103identification. There must be an actual RSA host key available in the
104known_hosts file for the jenkins master to be able to log in. Simply calling
105ssh and accepting the host key as usual is not enough. Jenkins may continue to
106say "Host key verification failed".
107
108To place an RSA host key in the jenkins' known_hosts file, you may do:
109
110On the Jenkins master:
111
112----
113main_unit_ip=10.9.8.7
114ssh-keyscan -H $main_unit_ip >> ~jenkins/.ssh/known_hosts
115chown jenkins: ~jenkins/.ssh/known_hosts
116----
117
118Verify that the jenkins user on the Jenkins master has SSH access to the main
119unit:
120
121----
122su jenkins
123main_unit_ip=10.9.8.7
124ssh jenkins@$main_unit_ip
125exit
126----
127
128[[install_add_build_slave]]
129==== Add Build Slave
130
131In the jenkins web UI, add a new build slave for the osmo-gsm-tester:
132
133* 'Manage Jenkins'
134** 'Manage Nodes'
135*** 'New Node'
136**** Enter a node name, e.g. "osmo-gsm-tester-1" +
137 (the "-1" is just some identification in case you'd like to add another
138 setup later).
139**** 'Permanent Agent'
140
141Configure the node as:
142
143* '# of executors': 1
144* 'Remote root directory': "/home/jenkins"
145* 'Labels': "osmo-gsm-tester" +
146 (This is a general label common to all osmo-gsm-tester build slaves you may set up in the future.)
147* 'Usage': 'Only build jobs with label expressions matching this node'
148* 'Launch method': 'Launch slave agents via SSH'
149** 'Host': your main unit's IP address
150** 'Credentials': choose 'Add' / 'Jenkins'
151*** 'Domain': 'Global credentials (unrestricted)'
152*** 'Kind': 'SSH Username with private key'
153*** 'Scope': 'Global'
154*** 'Username': "jenkins" +
155 (as created on the main unit above)
156*** 'Private Key': 'From a file on Jenkins master'
157**** 'File': "/usr/local/jenkins/keys/osmo-gsm-tester-rnd"
158*** 'Passphrase': enter same passphrase as above
159*** 'ID': "osmo-gsm-tester-1"
160*** 'Name': "jenkins for SSH to osmo-gsm-tester-1"
161
162The build slave should be able to start now.
163
164
165==== Add Build Jobs
166
167There are various jenkins-build-* scripts in osmo-gsm-tester/contrib/, which
168can be called as jenkins build jobs to build and bundle binaries as artifacts,
169to be run on the osmo-gsm-tester main unit and/or BTS hardware.
170
171Be aware of the dependencies, as hinted at in <<jenkins_deps>>.
172
173While the various binaries could technically be built on the osmo-gsm-tester
174main unit, it is recommended to use a separate build slave, to take load off
175of the main unit.
176
177On your jenkins master, set up build jobs to call these scripts -- typically
178one build job per script. Look in contrib/ and create one build job for each of
179the BTS types you would like to test, as well as one for the 'build-osmo-nitb'.
180
181These are generic steps to configure a jenkins build
182job for each of these build scripts, by example of the
183jenkins-build-osmo-nitb.sh script; all that differs to the other scripts is the
184"osmo-nitb" part:
185
186* 'Project name': "osmo-gsm-tester_build-osmo-nitb" +
187 (Replace 'osmo-nitb' according to which build script this is for)
188* 'Discard old builds' +
189 Configure this to taste, for example:
190** 'Max # of build to keep': "20"
191* 'Restrict where this project can be run': Choose a build slave label that
192 matches the main unit's architecture and distribution, typically a Debian
193 system, e.g.: "linux_amd64_debian8"
194* 'Source Code Management':
195** 'Git'
196*** 'Repository URL': "git://git.osmocom.org/osmo-gsm-tester"
197*** 'Branch Specifier': "*/master"
198*** 'Additional Behaviors'
199**** 'Check out to a sub-directory': "osmo-gsm-tester"
200* 'Build Triggers' +
201 The decision on when to build is complex. Here are some examples:
202** Once per day: +
203 'Build periodically': "H H * * *"
204** For the Osmocom project, the purpose is to verify our software changes.
205 Hence we would like to test every time our code has changed:
206*** We could add various git repositories to watch, and enable 'Poll SCM'.
207*** On jenkins.osmocom.org, we have various jobs that build the master branches
208 of their respective git repositories when a new change was merged. Here, we
209 can thus trigger e.g. an osmo-nitb build for osmo-gsm-tester everytime the
210 master build has run: +
211 'Build after other projects are built': "OpenBSC"
212*** Note that most of the Osmocom projects also need to be re-tested when their
213 dependencies like libosmo* have changed. Triggering on all those changes
214 typically causes more jenkins runs than necessary: for example, it rebuilds
215 once per each dependency that has rebuilt due to one libosmocore change.
216 There is so far no trivial way known to avoid this. It is indeed safest to
217 rebuild more often.
218* 'Build'
219** 'Execute Shell'
220+
221----
222#!/bin/sh
223set -e -x
224./osmo-gsm-tester/contrib/jenkins-build-osmo-nitb.sh
225----
226+
227(Replace 'osmo-nitb' according to which build script this is for)
228
229* 'Post-build Actions'
230** 'Archive the artifacts': "*.tgz, *.md5" +
231 (This step is important to be able to use the built binaries in the run job
232 below.)
233
234
235TIP: When you've created one build job, it is convenient to create further
236build jobs by copying the first and, e.g., simply replacing all "osmo-nitb"
237with "osmo-bts-trx".
238
239==== Add Run Job
240
241This is the build job that actually runs the tests on the GSM hardware:
242
243* It sources the artifacts from the build jobs.
244* It runs on the osmo-gsm-tester main unit's build slave.
245
246Here is the configuration for the run job:
247
248* 'Project name': "osmo-gsm-tester_run"
249* 'Discard old builds' +
250 Configure this to taste, for example:
251** 'Max # of build to keep': "20"
252* 'Restrict where this project can be run': "osmo-gsm-tester" +
253 (to match the 'Label' configured in <<install_add_build_slave>>).
254* 'Source Code Management':
255** 'Git'
256*** 'Repository URL': "git://git.osmocom.org/osmo-gsm-tester"
257*** 'Branch Specifier': "*/master"
258*** 'Additional Behaviors'
259**** 'Check out to a sub-directory': "osmo-gsm-tester"
260**** 'Clean before checkout'
261* 'Build Triggers' +
262 The decision on when to build is complex. For this run job, it is suggested
263 to rebuild:
264** after each of above build jobs that produced new artifacts: +
265 'Build after other projects are built': "osmo-gsm-tester_build-osmo-nitb,
266 osmo-gsm-tester_build-osmo-bts-sysmo, osmo-gsm-tester_build-osmo-bts-trx" +
267 (Add each build job name you configured above)
268** as well as once per day: +
269 'Build periodically': "H H * * *"
270** and, in addition, whenever the osmo-gsm-tester scripts have been modified: +
271 'Poll SCM': "H/5 * * * *" +
272 (i.e. look every five minutes whether the upstream git has changed)
273* 'Build'
274** Copy artifacts from each build job you have set up:
275*** 'Copy artifacts from another project'
276**** 'Project name': "osmo-gsm-tester_build-osmo-nitb"
277**** 'Which build': 'Latest successful build'
278**** enable 'Stable build only'
279**** 'Artifacts to copy': "*.tgz, *.md5"
280*** Add a separate similar 'Copy artifacts...' section for each build job you
281 have set up.
282** 'Execute Shell'
283+
284----
285#!/bin/sh
286set -e -x
287
288# debug: provoke a failure
289#export OSMO_GSM_TESTER_OPTS="-s debug -t fail"
290
291PATH="$PWD/osmo-gsm-tester/src:$PATH" \
292 ./osmo-gsm-tester/contrib/jenkins-run.sh
293----
294+
295Details:
296
297*** The 'jenkins-run.sh' script assumes to find the 'osmo-gsm-tester.py' in the
298 '$PATH'. To use the most recent osmo-gsm-tester code here, we direct
299 '$PATH' to the actual workspace checkout. This could also run from a sytem
300 wide install, in which case you could omit the explicit PATH to
301 "$PWD/osmo-gsm-tester/src".
302*** This assumes that there are configuration files for osmo-gsm-tester placed
303 on the system (see <<config_paths>>).
304*** If you'd like to check the behavior of test failures, you can uncomment the
305 line below "# debug" to produce a build failure on every run. Note that
306 this test typically produces a quite empty run result, since it launches no
307 NITB nor BTS.
308* 'Post-build Actions'
309** 'Archive the artifacts'
310*** 'Files to archive': "*-run.tgz" +
311 This stores the complete test report with config files, logs, stdout/stderr
312 output as well as pcaps in an artifact. This allows analysis of older
313 builds, instead of only the most recent build (which cleans up the jenkins
314 workspace every time). The 'trial-N-run.tgz' archive is produced by the
315 'jenkins-run.sh' script, both for successful and failing runs.
316
317
318=== Install osmo-gsm-tester on Main Unit
319
320This assumes you have already created the jenkins user (see <<configure_build_slave>>).
321
322==== Allow Core Files
323
324In case a binary run for the test crashes, a core file of the crash should be
325written. This requires a limit rule. Copy the following config file from the
326osmo-gsm-tester source tree to the main unit:
327
328----
Neels Hofmeyr05eb7792017-05-23 17:07:12 +0200329sudo -s
330echo "@osmo-gsm-tester - core unlimited" > /etc/security/limits.d/osmo-gsm-tester_allow-core.conf
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200331----
332
Neels Hofmeyr05eb7792017-05-23 17:07:12 +0200333Re-login the user to make these changes take effect.
334
335==== Allow Realtime Priority
336
337Certain binaries should be run with real-time priority, like 'osmo-bts-trx'.
338Add this permission on the main unit:
339
340----
341sudo -s
342echo "@osmo-gsm-tester - rtprio 99" > /etc/security/limits.d/osmo-gsm-tester_allow-rtprio.conf
343----
344
345Re-login the user to make these changes take effect.
346
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200347==== User Permissions
348
349On the main unit, create a group for all users that should be allowed to use
350the osmo-gsm-tester, and add users (here 'jenkins') to this group.
351
352----
353groupadd osmo-gsm-tester
354gpasswd -a jenkins osmo-gsm-tester
355----
356
357NOTE: you may also need to add users to the 'usrp' group, see
358<<user_config_uhd>>.
359
360A user added to a group needs to re-login for the group permissions to take
361effect.
362
363This group needs the following permissions:
364
365===== Paths
366
367Assuming that you are using the example config, prepare a system wide state
368location in '/var/tmp':
369
370----
371mkdir -p /var/tmp/osmo-gsm-tester/state
372chown -R :osmo-gsm-tester /var/tmp/osmo-gsm-tester
373chmod -R g+rwxs /var/tmp/osmo-gsm-tester
374setfacl -d -m group:osmo-gsm-tester:rwx /var/tmp/osmo-gsm-tester/state
375----
376
377IMPORTANT: the state directory needs to be shared between all users potentially
378running the osmo-gsm-tester to resolve resource allocations. Above 'setfacl'
379command sets the access control to keep all created files group writable.
380
381With the jenkins build as described here, the trials will live in the build
382slave's workspace. Other modes of operation (a daemon scheduling concurrent
383runs, *TODO*) may use a system wide directory to manage trials to run:
384
385----
386mkdir -p /var/tmp/osmo-gsm-tester/trials
387chown -R :osmo-gsm-tester /var/tmp/osmo-gsm-tester
388chmod -R g+rwxs /var/tmp/osmo-gsm-tester
389----
390
391===== Allow DBus Access to ofono
392
393Put a DBus configuration file in place that allows the 'osmo-gsm-tester' group
394to access the org.ofono DBus path:
395
396----
397cat > /etc/dbus-1/system.d/osmo-gsm-tester.conf <<END
398<!-- Additional rules for the osmo-gsm-tester to access org.ofono from user
399 land -->
400
401<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
402 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
403<busconfig>
404
405 <policy group="osmo-gsm-tester">
406 <allow send_destination="org.ofono"/>
407 </policy>
408
409</busconfig>
410END
411----
412
413(No restart of dbus nor ofono necessary.)
414
415[[install_capture_packets]]
416===== Capture Packets
417
418In order to allow collecting pcap traces of the network communication for later
419reference, allow the osmo-gsm-tester group to capture packets using the 'tcpdump'
420program:
421
422----
423chgrp osmo-gsm-tester /usr/sbin/tcpdump
424chmod 750 /usr/sbin/tcpdump
425setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump
426----
427
428Put 'tcpdump' in the '$PATH' -- assuming that 'tcpdump' is available for root:
429
430----
431ln -s `which tcpdump` /usr/local/bin/tcpdump
432----
433
434TIP: Why a symlink in '/usr/local/bin'? On Debian, 'tcpdump' lives in
435'/usr/sbin', which is not part of the '$PATH' for non-root users. To avoid
436hardcoding non-portable paths in the osmo-gsm-tester source, 'tcpdump' must be
437available in the '$PATH'. There are various trivial ways to modify '$PATH' for
438login shells, but the jenkins build slave typically runs in a *non-login*
439shell; modifying non-login shell enviroments is not trivially possible without
440also interfering with files installed from debian packages. Probably the
441easiest way to allow all users and all shells to find the 'tcpdump' binary is
442to actually place a symbolic link in a directory that is already part of the
443non-login shell's '$PATH'. Above example places such in '/usr/local/bin'.
444
445Verify that a non-login shell can find 'tcpdump':
446
447----
448su jenkins -c 'which tcpdump'
449# should print: "/usr/local/bin/tcpdump"
450----
451
452WARNING: When logged in via SSH on your main unit, running 'tcpdump' to capture
453packets may result in a feedback loop: SSH activity to send tcpdump's output to
454your terminal is in turn is picked up in the tcpdump trace, and so forth. When
455testing 'tcpdump' access, make sure to have proper filter expressions in place.
456
457TODO: allow skipping pcaps by configuration if access to tcpdump is not wanted
458
459[[user_config_uhd]]
460==== UHD
461
462Grant permission to use the UHD driver to run USRP devices for osmo-bts-trx, by
463adding the jenkins user to the 'usrp' group:
464
465----
466gpasswd -a jenkins usrp
467----
468
469==== Install Scripts
470
471IMPORTANT: When using the jenkins build slave as configured above, *there is no
472need to install the osmo-gsm-tester sources on the main unit*. The jenkins job
473will do so implicitly by checking out the latest osmo-gsm-tester sources in the
474workspace for every run. If you're using only the jenkins build slave, you may
475skip this section.
476
477If you prefer to use a fixed installation of the osmo-gsm-tester sources
478instead of the jenkins workspace, you can:
479
480. From the run job configured above, remove the line that says
481+
482----
483PATH="$PWD/osmo-gsm-tester/src:$PATH" \
484----
485+
486so that this uses a system wide installation instead.
487
488. Install the sources e.g. in '/usr/local/src' as indicated below.
489
490On the main unit, to install the latest in '/usr/local/src':
491
492----
493apt-get install git
494mkdir -p /usr/local/src
495cd /usr/local/src
496git clone git://git.osmocom.org/osmo-gsm-tester
497----
498
499To allow all users to run 'osmo-gsm-tester.py', from login as well as non-login
500shells, the easiest solution is to place a symlink in '/usr/local/bin':
501
502----
503ln -s /usr/local/src/osmo-gsm-tester/src/osmo-gsm-tester.py /usr/local/bin/
504----
505
506(See also the tip in <<install_capture_packets>> for a more detailed
507explanation.)
508
509The example configuration provided in the source is suitable for running as-is,
510*if* your hardware setup matches (you could technically use that directly by a
511symlink e.g. from '/usr/local/etc/osmo-gsm-tester' to the 'example' dir). If in
512doubt, rather copy the example, point 'paths.conf' at the 'suites' dir, and
513adjust your own configuration as needed. For example:
514
515----
516cd /etc
517cp -R /usr/local/src/osmo-gsm-tester/example osmo-gsm-tester
518sed -i 's#\.\./suites#/usr/local/src/osmo-gsm-tester/suites#' osmo-gsm-tester/paths.conf
519----
520
521NOTE: The configuration will be looked up in various places, see
522<<config_paths>>.
523
524
525== Hardware Choice and Configuration
526
527=== SysmoBTS
528
529To use the SysmoBTS in the osmo-gsm-tester, the following systemd services must
530be disabled:
531
532----
Neels Hofmeyree57f092017-06-03 15:20:50 +0200533systemctl mask osmo-nitb sysmobts sysmopcu sysmobts-mgr
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200534----
535
536This stops the stock setup keeping the BTS in operation and hence allows the
537osmo-gsm-tester to install and launch its own versions of the SysmoBTS
538software.
539
540==== IP Address
541
542To ensure that the SysmoBTS is always reachable at a fixed known IP address,
543configure the eth0 to use a static IP address:
544
545Adjust '/etc/network/interfaces' and replace the line
546
547----
548iface eth0 inet dhcp
549----
550
551with
552
553----
554iface eth0 inet static
555 address 10.42.42.114
556 netmask 255.255.255.0
557 gateway 10.42.42.1
558----
559
560You may set the name server in '/etc/resolve.conf' (most likely to the IP of
561the gateway), but this is not really needed by the osmo-gsm-tester.
562
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200563==== Allow Core Files
564
565In case a binary run for the test crashes, a core file of the crash should be
Neels Hofmeyree57f092017-06-03 15:20:50 +0200566written. This requires a limits rule. Append a line to /etc/limits like:
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200567
568----
Neels Hofmeyree57f092017-06-03 15:20:50 +0200569ssh root@10.42.42.114
570echo "* C16384" >> /etc/limits
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200571----
572
Neels Hofmeyree57f092017-06-03 15:20:50 +0200573==== Reboot
574
575Reboot the BTS and make sure that the IP address for eth0 is now indeed
57610.42.42.114, and that no osmo* programs are running.
577
578----
579ip a
580ps w | grep osmo
581----
582
583==== SSH Access
584
585Make sure that the jenkins user on the main unit is able to login on the
586sysmoBTS, possibly erasing outdated host keys after a new rootfs was loaded:
587
588On the main unit, for example do:
589
590----
591su - jenkins
592ssh root@10.42.42.114
593----
594
595Fix any problems until you get a login on the sysmoBTS.
596
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200597
598[[hardware_modems]]
599=== Modems
600
601TODO: describe modem choices and how to run ofono
602
603[[hardware_trx]]
604=== osmo-bts-trx
605
606TODO: describe B200 family
607