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