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