1
1
#! /bin/bash -e
2
2
3
+ function print_results() {
4
+ total=$( grep -E ' ^--- (:?PASS|SKIP|FAIL)' functional/functional-tests.log | wc -l)
5
+ pass=$( grep ' ^--- PASS' functional/functional-tests.log | wc -l)
6
+ skip=$( grep ' ^--- SKIP' functional/functional-tests.log | wc -l)
7
+ fail=$( grep ' ^--- FAIL' functional/functional-tests.log | wc -l)
8
+ smoke_logs=$( awk ' /Test.*_smoke.*\.log/{print $NF}' functional/functional-tests.log)
9
+
10
+ if [ " x$smoke_logs " != " x" ]; then
11
+ echo
12
+ echo " ==========================================================="
13
+ echo " Functional test debug logs"
14
+ echo " ==========================================================="
15
+ fi
16
+
17
+ for smoke_log in $smoke_logs ; do
18
+ echo " # Printing last $TAIL_LOGS of $smoke_log (systemd)"
19
+ grep ' systemd\[1\]' $smoke_log | tail -$TAIL_LOGS
20
+ echo " # Printing last $TAIL_LOGS of $smoke_log (fleetd)"
21
+ grep ' fleetd\[.*\]' $smoke_log | tail -$TAIL_LOGS
22
+ echo " # Printing last $TAIL_LOGS of $smoke_log excluding fleetd/systemd/sshd"
23
+ grep -vE ' fleetd\[.*\]|systemd\[1\]|sshd\[.*\]' $smoke_log | tail -$TAIL_LOGS
24
+ echo " ==========================================================="
25
+ done
26
+
27
+ echo " "
28
+ grep -E ' ^--- (:?PASS|FAIL|SKIP)' functional/functional-tests.log
29
+
30
+ echo " ==========================================================="
31
+ echo " Functional test summary"
32
+ echo " ==========================================================="
33
+ echo " # TOTAL: $total "
34
+ echo " # PASS: $pass "
35
+ echo " # SKIP: $skip "
36
+ echo " # FAIL: $fail "
37
+ echo " "
38
+ echo " See ${CDIR} /functional-tests.log for the detailed output."
39
+ if [ " ${TESTS_RETURN_CODE_1} " -ne " 0" ]; then
40
+ exit ${TESTS_RETURN_CODE_1}
41
+ else
42
+ exit ${TESTS_RETURN_CODE_2}
43
+ fi
44
+ }
45
+
3
46
CDIR=$( cd ` dirname $0 ` && pwd)
4
47
USER_ID=${SUDO_UID:- $(id -u)}
5
48
HOME=$( getent passwd " ${USER_ID} " | cut -d: -f6)
@@ -10,7 +53,7 @@ export VERSION=$(git describe --dirty)
10
53
export GOROOT=${HOME} /go
11
54
export PATH=${HOME} /go/bin:${PATH}
12
55
13
- if [ ! -S " $SSH_AUTH_SOCK " ]; then
56
+ if [ ! -S " ${ SSH_AUTH_SOCK} " ]; then
14
57
eval $( ssh-agent)
15
58
trap " ssh-agent -k > /dev/null" EXIT
16
59
fi
25
68
26
69
if [ ! -x " bin/fleetd" ] || \
27
70
[ ! -x " bin/fleetctl" ] || \
28
- [ ! $( bin/fleetctl | grep " $VERSION " ) ]; then
71
+ [ ! $( bin/fleetctl | grep " ${ VERSION} " ) ]; then
29
72
./build
30
73
fi
31
74
32
75
source build-env
33
76
eval $( go env)
34
- go test github.com/coreos/fleet/functional -ldflags " ${GLDFLAGS} " -v " $@ " 2>&1 | tee functional/functional-tests.log
35
- TESTS_RETURN_CODE=${PIPESTATUS[0]}
36
77
37
- total=$( grep -E ' ^--- (PASS|FAIL)' functional/functional-tests.log | wc -l)
38
- pass=$( grep ' ^--- PASS' functional/functional-tests.log | wc -l)
39
- fail=$( grep ' ^--- FAIL' functional/functional-tests.log | wc -l)
40
- smoke_logs=$( awk ' /Test.*_smoke.*\.log/{print $NF}' functional/functional-tests.log)
41
-
42
- if [ " x$smoke_logs " != " x" ]; then
43
- echo
44
- echo " ==========================================================="
45
- echo " Functional test debug logs"
46
- echo " ==========================================================="
47
- fi
48
-
49
- for smoke_log in $smoke_logs ; do
50
- echo " # Printing last $TAIL_LOGS of $smoke_log (systemd)"
51
- grep ' systemd\[1\]' $smoke_log | tail -$TAIL_LOGS
52
- echo " # Printing last $TAIL_LOGS of $smoke_log (fleetd)"
53
- grep ' fleetd\[.*\]' $smoke_log | tail -$TAIL_LOGS
54
- echo " # Printing last $TAIL_LOGS of $smoke_log excluding fleetd/systemd/sshd"
55
- grep -vE ' fleetd\[.*\]|systemd\[1\]|sshd\[.*\]' $smoke_log | tail -$TAIL_LOGS
56
- echo " ==========================================================="
57
- done
58
-
59
- echo
60
- grep -E ' ^--- (PASS|FAIL)' functional/functional-tests.log
78
+ go test github.com/coreos/fleet/functional -ldflags " ${GLDFLAGS} " -v " $@ " 2>&1 | tee functional/functional-tests.log
79
+ TESTS_RETURN_CODE_1=${PIPESTATUS[0]}
61
80
62
- echo " =========================================================== "
63
- echo " Functional test summary "
64
- echo " =========================================================== "
65
- echo " # TOTAL: $total "
66
- echo " # PASS: $pass "
67
- echo " # FAIL: $fail "
68
- echo
69
- echo " See ${CDIR} /functional-tests.log for the detailed output. "
81
+ # Run tests with cache enable on fleetd side
82
+ # NOTE: this test with unit state cache doesn't need to run, as unit state
83
+ # cache is going to be obsolete. But in the future, we could set $FLEETD_TEST_ENV
84
+ # to an env variable to run another round of tests, if necessary. - 20160518 dpark
85
+ # export FLEETD_TEST_ENV="enable_unitstate_cache=true "
86
+ # go test github.com/coreos/fleet/functional -ldflags "${GLDFLAGS}" -v "$@" 2>&1 | sed -r "s/^(---\s+(:?PASS|SKIP| FAIL):\s+Test[^\(]*)/\\1(fleet.conf=\[$FLEETD_TEST_ENV\]) /g;s/^(=== RUN\s+Test.*)/\1 (fleet.conf=\[$FLEETD_TEST_ENV\])/g" | tee -a functional/functional-tests.log
87
+ # TESTS_RETURN_CODE_2=${PIPESTATUS[0]}
88
+ TESTS_RETURN_CODE_2=0
70
89
71
- exit $TESTS_RETURN_CODE
90
+ print_results
0 commit comments