-
Notifications
You must be signed in to change notification settings - Fork 44
/
gce-logger
executable file
·62 lines (54 loc) · 1.66 KB
/
gce-logger
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
. /usr/local/lib/gce-funcs
FORCE=
if test "$1" = "--force" ; then
FORCE="yes"
shift
fi
if test -z "$HOOK_ARG" # prevent recursion
then
run_hooks logger "$*"
fi
is_test=
status=$(echo "$*" | sed -e 's/^run xfstest //')
if echo "$*" | grep -q "^run xfstest "
then
is_test="y"
echo "$status" >> $RESULT_BASE/completed
if test ! -f $RESULT_BASE/rpt_status -o \
! -f $RESULT_BASE/tests-to-run -o \
! -f $RESULT_BASE/completed
then
status="--% $status"
else
rpt_status=$(cat $RESULT_BASE/rpt_status)
current_rpt=${rpt_status%%/*}
total_rpt=${rpt_status##*/}
total_tests=$(cat $RESULT_BASE/tests-to-run | sort | uniq | wc -l)
count_completed=$(cat $RESULT_BASE/completed | sort | uniq | wc -l)
progress=$(( ( ( $current_rpt - 1 ) * $total_tests + $count_completed ) * 100 / ( $total_tests * $total_rpt ) ))
status="$progress% $status"
fi
# sync completed file
/root/xfstests/bin/syncfs $RESULT_BASE
fi
if test -f /run/fstest-config
then
cfg="$(cat /run/fstest-config)"
status="$cfg $status"
fi
# force first test to upload it's test status and wait for it to finish
if test -n "$is_test" -a ! -s /run/last_logged; then
/usr/local/lib/gce-add-metadata "status=$(date +%H:%M) $status"
echo "Started testing" > /run/last_logged
elif test -n "$FORCE" -o -z "$(find /run/last_logged -mmin -1 -print 2> /dev/null)"
then
/usr/local/lib/gce-add-metadata "status=$(date +%H:%M) $status" &
touch /run/last_logged
fi
umask 022
echo $(date +%s) "$status" > /var/www/statusz
echo $(date +%H:%M) "$status" > /var/www/status
echo "$status" > /results/status
/root/xfstests/bin/syncfs /results/status
logger $cfg "$*"