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