blob: 4d2b677b619c3297ba2ea7e5755a44258bf90807 [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
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200333==== User Permissions
334
335On the main unit, create a group for all users that should be allowed to use
336the osmo-gsm-tester, and add users (here 'jenkins') to this group.
337
338----
339groupadd osmo-gsm-tester
340gpasswd -a jenkins osmo-gsm-tester
341----
342
343NOTE: you may also need to add users to the 'usrp' group, see
344<<user_config_uhd>>.
345
346A user added to a group needs to re-login for the group permissions to take
347effect.
348
349This group needs the following permissions:
350
351===== Paths
352
353Assuming that you are using the example config, prepare a system wide state
354location in '/var/tmp':
355
356----
357mkdir -p /var/tmp/osmo-gsm-tester/state
358chown -R :osmo-gsm-tester /var/tmp/osmo-gsm-tester
359chmod -R g+rwxs /var/tmp/osmo-gsm-tester
360setfacl -d -m group:osmo-gsm-tester:rwx /var/tmp/osmo-gsm-tester/state
361----
362
363IMPORTANT: the state directory needs to be shared between all users potentially
364running the osmo-gsm-tester to resolve resource allocations. Above 'setfacl'
365command sets the access control to keep all created files group writable.
366
367With the jenkins build as described here, the trials will live in the build
368slave's workspace. Other modes of operation (a daemon scheduling concurrent
369runs, *TODO*) may use a system wide directory to manage trials to run:
370
371----
372mkdir -p /var/tmp/osmo-gsm-tester/trials
373chown -R :osmo-gsm-tester /var/tmp/osmo-gsm-tester
374chmod -R g+rwxs /var/tmp/osmo-gsm-tester
375----
376
377===== Allow DBus Access to ofono
378
379Put a DBus configuration file in place that allows the 'osmo-gsm-tester' group
380to access the org.ofono DBus path:
381
382----
383cat > /etc/dbus-1/system.d/osmo-gsm-tester.conf <<END
384<!-- Additional rules for the osmo-gsm-tester to access org.ofono from user
385 land -->
386
387<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
388 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
389<busconfig>
390
391 <policy group="osmo-gsm-tester">
392 <allow send_destination="org.ofono"/>
393 </policy>
394
395</busconfig>
396END
397----
398
399(No restart of dbus nor ofono necessary.)
400
401[[install_capture_packets]]
402===== Capture Packets
403
404In order to allow collecting pcap traces of the network communication for later
405reference, allow the osmo-gsm-tester group to capture packets using the 'tcpdump'
406program:
407
408----
409chgrp osmo-gsm-tester /usr/sbin/tcpdump
410chmod 750 /usr/sbin/tcpdump
411setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump
412----
413
414Put 'tcpdump' in the '$PATH' -- assuming that 'tcpdump' is available for root:
415
416----
417ln -s `which tcpdump` /usr/local/bin/tcpdump
418----
419
420TIP: Why a symlink in '/usr/local/bin'? On Debian, 'tcpdump' lives in
421'/usr/sbin', which is not part of the '$PATH' for non-root users. To avoid
422hardcoding non-portable paths in the osmo-gsm-tester source, 'tcpdump' must be
423available in the '$PATH'. There are various trivial ways to modify '$PATH' for
424login shells, but the jenkins build slave typically runs in a *non-login*
425shell; modifying non-login shell enviroments is not trivially possible without
426also interfering with files installed from debian packages. Probably the
427easiest way to allow all users and all shells to find the 'tcpdump' binary is
428to actually place a symbolic link in a directory that is already part of the
429non-login shell's '$PATH'. Above example places such in '/usr/local/bin'.
430
431Verify that a non-login shell can find 'tcpdump':
432
433----
434su jenkins -c 'which tcpdump'
435# should print: "/usr/local/bin/tcpdump"
436----
437
438WARNING: When logged in via SSH on your main unit, running 'tcpdump' to capture
439packets may result in a feedback loop: SSH activity to send tcpdump's output to
440your terminal is in turn is picked up in the tcpdump trace, and so forth. When
441testing 'tcpdump' access, make sure to have proper filter expressions in place.
442
443TODO: allow skipping pcaps by configuration if access to tcpdump is not wanted
444
Pau Espin Pedrol018e1042017-08-28 11:58:25 +0200445==== Allow Core Files
446
447In case a binary run for the test crashes, a core file of the crash should be
448written. This requires a limit rule. Create a file with the required rule:
449
450----
451sudo -s
452echo "@osmo-gsm-tester - core unlimited" > /etc/security/limits.d/osmo-gsm-tester_allow-core.conf
453----
454
455Re-login the user to make these changes take effect.
456
457Set the *kernel.core_pattern* sysctl to *core* (usually the default). For each
458binary run by osmo-gsm-tester, a core file will then appear in the same dir that
459contains stdout and stderr for that process (because this dir is set as CWD).
460
461----
462sysctl -w kernel.core_pattern=core
463----
464
465==== Allow Realtime Priority
466
467Certain binaries should be run with real-time priority, like 'osmo-bts-trx'.
468Add this permission on the main unit:
469
470----
471sudo -s
472echo "@osmo-gsm-tester - rtprio 99" > /etc/security/limits.d/osmo-gsm-tester_allow-rtprio.conf
473----
474
475Re-login the user to make these changes take effect.
476
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200477[[user_config_uhd]]
478==== UHD
479
480Grant permission to use the UHD driver to run USRP devices for osmo-bts-trx, by
481adding the jenkins user to the 'usrp' group:
482
483----
484gpasswd -a jenkins usrp
485----
486
487==== Install Scripts
488
489IMPORTANT: When using the jenkins build slave as configured above, *there is no
490need to install the osmo-gsm-tester sources on the main unit*. The jenkins job
491will do so implicitly by checking out the latest osmo-gsm-tester sources in the
492workspace for every run. If you're using only the jenkins build slave, you may
493skip this section.
494
495If you prefer to use a fixed installation of the osmo-gsm-tester sources
496instead of the jenkins workspace, you can:
497
498. From the run job configured above, remove the line that says
499+
500----
501PATH="$PWD/osmo-gsm-tester/src:$PATH" \
502----
503+
504so that this uses a system wide installation instead.
505
506. Install the sources e.g. in '/usr/local/src' as indicated below.
507
508On the main unit, to install the latest in '/usr/local/src':
509
510----
511apt-get install git
512mkdir -p /usr/local/src
513cd /usr/local/src
514git clone git://git.osmocom.org/osmo-gsm-tester
515----
516
517To allow all users to run 'osmo-gsm-tester.py', from login as well as non-login
518shells, the easiest solution is to place a symlink in '/usr/local/bin':
519
520----
521ln -s /usr/local/src/osmo-gsm-tester/src/osmo-gsm-tester.py /usr/local/bin/
522----
523
524(See also the tip in <<install_capture_packets>> for a more detailed
525explanation.)
526
527The example configuration provided in the source is suitable for running as-is,
528*if* your hardware setup matches (you could technically use that directly by a
529symlink e.g. from '/usr/local/etc/osmo-gsm-tester' to the 'example' dir). If in
530doubt, rather copy the example, point 'paths.conf' at the 'suites' dir, and
531adjust your own configuration as needed. For example:
532
533----
534cd /etc
535cp -R /usr/local/src/osmo-gsm-tester/example osmo-gsm-tester
536sed -i 's#\.\./suites#/usr/local/src/osmo-gsm-tester/suites#' osmo-gsm-tester/paths.conf
537----
538
539NOTE: The configuration will be looked up in various places, see
540<<config_paths>>.
541
542
543== Hardware Choice and Configuration
544
545=== SysmoBTS
546
547To use the SysmoBTS in the osmo-gsm-tester, the following systemd services must
548be disabled:
549
550----
Maxbe69b6b2017-07-03 19:03:25 +0200551systemctl mask osmo-nitb osmo-bts-sysmo osmo-pcu sysmobts-mgr
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200552----
553
554This stops the stock setup keeping the BTS in operation and hence allows the
555osmo-gsm-tester to install and launch its own versions of the SysmoBTS
556software.
557
558==== IP Address
559
560To ensure that the SysmoBTS is always reachable at a fixed known IP address,
561configure the eth0 to use a static IP address:
562
563Adjust '/etc/network/interfaces' and replace the line
564
565----
566iface eth0 inet dhcp
567----
568
569with
570
571----
572iface eth0 inet static
573 address 10.42.42.114
574 netmask 255.255.255.0
575 gateway 10.42.42.1
576----
577
578You may set the name server in '/etc/resolve.conf' (most likely to the IP of
579the gateway), but this is not really needed by the osmo-gsm-tester.
580
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200581==== Allow Core Files
582
583In case a binary run for the test crashes, a core file of the crash should be
Neels Hofmeyree57f092017-06-03 15:20:50 +0200584written. This requires a limits rule. Append a line to /etc/limits like:
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200585
586----
Neels Hofmeyree57f092017-06-03 15:20:50 +0200587ssh root@10.42.42.114
588echo "* C16384" >> /etc/limits
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200589----
590
Neels Hofmeyree57f092017-06-03 15:20:50 +0200591==== Reboot
592
593Reboot the BTS and make sure that the IP address for eth0 is now indeed
59410.42.42.114, and that no osmo* programs are running.
595
596----
597ip a
598ps w | grep osmo
599----
600
601==== SSH Access
602
603Make sure that the jenkins user on the main unit is able to login on the
604sysmoBTS, possibly erasing outdated host keys after a new rootfs was loaded:
605
606On the main unit, for example do:
607
608----
609su - jenkins
610ssh root@10.42.42.114
611----
612
613Fix any problems until you get a login on the sysmoBTS.
614
Neels Hofmeyrb52df172017-05-14 20:09:35 +0200615
616[[hardware_modems]]
617=== Modems
618
619TODO: describe modem choices and how to run ofono
620
621[[hardware_trx]]
622=== osmo-bts-trx
623
624TODO: describe B200 family