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