~curtin-dev/curtin/trunk

« back to all changes in this revision

Viewing changes to tools/jenkins-runner

  • Committer: Scott Moser
  • Date: 2017-12-20 17:33:03 UTC
  • Revision ID: smoser@ubuntu.com-20171220173303-29gha5qb8wpqrd40
README: Mention move of revision control to git.

curtin development has moved its revision control to git.
It is available at
  https://code.launchpad.net/curtin

Clone with
  git clone https://git.launchpad.net/curtin
or
  git clone git+ssh://git.launchpad.net/curtin

For more information see
  http://curtin.readthedocs.io/en/latest/topics/development.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
 
3
 
topdir="${CURTIN_VMTEST_TOPDIR:-${WORKSPACE:-$PWD}/output}"
4
 
pkeep=${CURTIN_VMTEST_KEEP_DATA_PASS:-logs,collect}
5
 
fkeep=${CURTIN_VMTEST_KEEP_DATA_FAIL:-logs,collect}
6
 
reuse=${CURTIN_VMTEST_REUSE_TOPDIR:-0}
7
 
export CURTIN_VMTEST_TAR_DISKS=${CURTIN_VMTEST_TAR_DISKS:-0}
8
 
export CURTIN_VMTEST_REUSE_TOPDIR=$reuse
9
 
export CURTIN_VMTEST_IMAGE_SYNC=${CURTIN_VMTEST_IMAGE_SYNC:-0}
10
 
export CURTIN_VMTEST_KEEP_DATA_PASS=$pkeep
11
 
export CURTIN_VMTEST_KEEP_DATA_FAIL=$fkeep
12
 
export CURTIN_VMTEST_TOPDIR="$topdir"
13
 
export CURTIN_VMTEST_LOG="${CURTIN_VMTEST_LOG:-$topdir/debug.log}"
14
 
export CURTIN_VMTEST_PARALLEL=${CURTIN_VMTEST_PARALLEL:-0}
15
 
export IMAGE_DIR=${IMAGE_DIR:-/srv/images}
16
 
 
17
 
# empty TGT_* variables in current env to avoid killing a pid we didn't start.
18
 
TGT_PID=""
19
 
TGT_LOG_D=""
20
 
 
21
 
error() { echo "$@" 1>&2; }
22
 
fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
23
 
cleanup() {
24
 
    local ret=$?
25
 
    local keep_rules
26
 
    [ "$ret" -eq 0 ] && keep_rules="$pkeep" || keep_rules="$fkeep"
27
 
    # kill a tgtd pid that was started here.
28
 
    if [ -n "$TGT_PID" ]; then
29
 
        kill -9 ${TGT_PID};
30
 
        if [ -n "${TGT_IPC_SOCKET}" ]; then
31
 
            # var is <path>/socket but the actual socket is <path>/socket.0
32
 
            rm -f "${TGT_IPC_SOCKET}" "${TGT_IPC_SOCKET}".* ||
33
 
                error "WARN: failed removal of $TGT_IPC_SOCKET"
34
 
        fi
35
 
    fi
36
 
    if [ -n "$TGT_LOG_D" ]; then
37
 
        case ",${keep_rules}," in
38
 
            *,logs,*|*,all,*) :;;
39
 
            *) rm -Rf "${TGT_LOG_D}";;
40
 
        esac
41
 
    fi
42
 
}
43
 
 
44
 
if [ "$reuse" != "1" ]; then
45
 
    if [ -d "$topdir" ]; then
46
 
        fail "topdir '$topdir' existed."
47
 
    fi
48
 
    mkdir -p "$topdir" || fail "failed mkdir $topdir"
49
 
fi
50
 
 
51
 
start_s=$(date +%s)
52
 
parallel=${CURTIN_VMTEST_PARALLEL}
53
 
ntargs=( )
54
 
while [ $# -ne 0 ]; do
55
 
    case "$1" in
56
 
        -p|--parallel) parallel="$2"; shift;;
57
 
        --parallel=*) parallel=${1#*=};;
58
 
        -p[0-9]|-p-1|-p[0-9][0-9]) parallel=${1#-p};;
59
 
        --)
60
 
            shift
61
 
            break
62
 
            ;;
63
 
        *) ntargs[${#ntargs[@]}]="$1";;
64
 
    esac
65
 
    shift;
66
 
done
67
 
 
68
 
CURTIN_VMTEST_PARALLEL=$parallel
69
 
 
70
 
if [ ${#ntargs[@]} -eq 0 ]; then
71
 
   set -- -vv --nologcapture tests/vmtests/
72
 
fi
73
 
 
74
 
trap cleanup EXIT
75
 
 
76
 
ntargs=( "${ntargs[@]}" "$@" )
77
 
 
78
 
pargs=( )
79
 
if [ -n "$parallel" -a "$parallel" != "0" -a "$parallel" != "1" ]; then
80
 
    pargs=( --process-timeout=86400 "--processes=$parallel" )
81
 
fi
82
 
 
83
 
if [ -n "$TGT_IPC_SOCKET" ]; then
84
 
    error "existing TGT_IPC_SOCKET=${TGT_IPC_SOCKET}"
85
 
elif command -v tgtd >/dev/null 2>&1; then
86
 
    tgtdir="$topdir/tgt.d"
87
 
    mkdir -p "$tgtdir" || fail "failed to create $tgtdir"
88
 
    rm -f "$tgtdir/info" || fail "failed to remove $tgtdir/info"
89
 
    ./tools/find-tgt "$tgtdir" >"${tgtdir}/find-tgt.log" 2>&1 || {
90
 
        cat "${tgtdir}/find-tgt.log" 1>&2
91
 
        fail "could not start a tgt service"
92
 
    }
93
 
    TGT_LOG_D="$tgtdir"
94
 
    . "$tgtdir/info" >"$tgtdir/source-output.txt" 2>&1
95
 
    [ -n "$TGT_PID" ] || fail "find-tgt did not write TGT_PID"
96
 
    [ -d "/proc/${TGT_PID}" ] || fail "no tgtd process in /proc/${TGT_PID}"
97
 
else
98
 
    error "no tgtd command, iscsi tests will be skipped"
99
 
fi
100
 
 
101
 
# dump CURTIN_* and TGT_* and proxy variables just for info
102
 
for v in ${!CURTIN_*} ${!TGT_*} http_proxy https_proxy no_proxy; do
103
 
   echo "$v=${!v}"
104
 
done
105
 
 
106
 
# avoid LOG info by running python3 tests/vmtests/image_sync.py
107
 
# rather than python3 -m tests.vmtests.image_sync (LP: #1594465)
108
 
echo "Working with images in $IMAGE_DIR"
109
 
fmt="  %(release)-7s %(arch)s/%(subarch)s %(version_name)-10s"
110
 
PYTHONPATH="$PWD" python3 tests/vmtests/image_sync.py query \
111
 
    --output-format="$fmt" "$IMAGE_DIR" ftype=root-image.gz ||
112
 
    { ret=$?; echo "FATAL: error querying images in $IMAGE_DIR" 1>&2;
113
 
      exit $ret; }
114
 
 
115
 
echo "$(date -R): vmtest start: nosetests3 ${pargs[*]} ${ntargs[*]}"
116
 
nosetests3 "${pargs[@]}" "${ntargs[@]}"
117
 
ret=$?
118
 
end_s=$(date +%s)
119
 
echo "$(date -R): vmtest end [$ret] in $(($end_s-$start_s))s"
120
 
exit $ret
121
 
 
122
 
# vi: ts=4 expandtab syntax=sh