Pau Espin Pedrol | bc1ed88 | 2018-05-17 16:59:58 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | set -e -x |
| 3 | base="$PWD" |
| 4 | |
| 5 | time_start="$(date '+%F %T')" |
| 6 | |
| 7 | prepare_docker() { |
| 8 | OLDPWD=$PWD |
| 9 | |
| 10 | # update docker-playground and update the BSC and bsc-test containers (if needed) |
| 11 | DIR=~/jenkins/docker-playground |
| 12 | if [ ! -d "$DIR" ]; then |
| 13 | mkdir -p ~/jenkins/ && cd ~/jenkins |
| 14 | git clone git://git.osmocom.org/docker-playground |
| 15 | fi |
| 16 | cd $DIR |
| 17 | git remote prune origin; git fetch; git checkout -f -B master origin/master |
| 18 | cd $DIR/debian-stretch-titan && make |
| 19 | docker pull laforge/debian-stretch-titan:latest # HACK |
| 20 | cd $DIR/ttcn3-bts-test && make |
| 21 | # execute the script to start containers, read results, ... |
| 22 | #cd $DIR/ttcn3-bts-test && sh -x ./jenkins.sh |
| 23 | PWD=$OLDPWD |
| 24 | } |
| 25 | |
| 26 | docker pull registry.sysmocom.de/ttcn3-bts-test |
| 27 | |
| 28 | # remove older trial dirs and *-run.tgz, if any |
| 29 | trial_dir_prefix="trial-" |
| 30 | rm -rf "$trial_dir_prefix"* || true |
| 31 | |
| 32 | # Expecting *.tgz artifacts to be copied to this workspace from the various |
| 33 | # jenkins-*.sh runs, via jenkins job configuration. Compose a trial dir: |
| 34 | trial_dir="${trial_dir_prefix}$BUILD_NUMBER" |
| 35 | mkdir -p "$trial_dir" |
| 36 | |
| 37 | mv *.tgz "$trial_dir" |
| 38 | cat *.md5 >> "$trial_dir/checksums.md5" |
| 39 | rm *.md5 |
| 40 | |
| 41 | # OSMO_GSM_TESTER_OPTS is a way to pass in e.g. logging preferences from the |
| 42 | # jenkins build job. |
| 43 | # On failure, first clean up below and then return the exit code. |
| 44 | exit_code="1" |
| 45 | if python3 -u "$(which osmo-gsm-tester.py)" "$trial_dir" $OSMO_GSM_TESTER_OPTS ; then |
| 46 | exit_code="0" |
| 47 | fi |
| 48 | |
| 49 | # no need to keep extracted binaries |
| 50 | rm -rf "$trial_dir/inst" || true |
| 51 | |
| 52 | # tar up all results for archiving (optional) |
| 53 | cd "$trial_dir" |
| 54 | journalctl -u ofono -o short-precise --since "${time_start}" > "$(readlink last_run)/ofono.log" |
| 55 | tar czf "$base/${trial_dir}-run.tgz" "$(readlink last_run)" |
| 56 | tar czf "$base/${trial_dir}-bin.tgz" *.md5 *.tgz |
| 57 | |
| 58 | exit $exit_code |