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