Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 3a974af

Browse files
author
Dongsu Park
committed
Merge pull request #1556 from endocode/kayrus/cache_func_tests
tests: test fleetd with extra configuration options
2 parents 1882d3c + 5cc9d3b commit 3a974af

File tree

2 files changed

+59
-37
lines changed

2 files changed

+59
-37
lines changed

functional/test

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,48 @@
11
#!/bin/bash -e
22

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+
346
CDIR=$(cd `dirname $0` && pwd)
447
USER_ID=${SUDO_UID:-$(id -u)}
548
HOME=$(getent passwd "${USER_ID}" | cut -d: -f6)
@@ -10,7 +53,7 @@ export VERSION=$(git describe --dirty)
1053
export GOROOT=${HOME}/go
1154
export PATH=${HOME}/go/bin:${PATH}
1255

13-
if [ ! -S "$SSH_AUTH_SOCK" ]; then
56+
if [ ! -S "${SSH_AUTH_SOCK}" ]; then
1457
eval $(ssh-agent)
1558
trap "ssh-agent -k > /dev/null" EXIT
1659
fi
@@ -25,47 +68,23 @@ fi
2568

2669
if [ ! -x "bin/fleetd" ] || \
2770
[ ! -x "bin/fleetctl" ] || \
28-
[ ! $(bin/fleetctl | grep "$VERSION") ]; then
71+
[ ! $(bin/fleetctl | grep "${VERSION}") ]; then
2972
./build
3073
fi
3174

3275
source build-env
3376
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]}
3677

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]}
6180

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
7089

71-
exit $TESTS_RETURN_CODE
90+
print_results

functional/util/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ write_files:
3737
etcd_key_prefix={{.EtcdKeyPrefix}}
3838
public_ip={{.IP}}
3939
agent_ttl={{.FleetAgentTTL}}
40+
{{.FleetExtra}}
4041
4142
ssh_authorized_keys:
4243
- {{printf "%q" .PublicKey}}
@@ -80,6 +81,7 @@ type configValues struct {
8081
EtcdKeyPrefix string
8182
FleetAPIPort int
8283
FleetAgentTTL string
84+
FleetExtra string
8385
}
8486

8587
func init() {
@@ -117,6 +119,7 @@ func BuildCloudConfig(dst io.Writer, ip, etcdEndpoint, etcdKeyPrefix string) err
117119
EtcdKeyPrefix: etcdKeyPrefix,
118120
FleetAPIPort: fleetAPIPort,
119121
FleetAgentTTL: FleetTTL,
122+
FleetExtra: os.Getenv("FLEETD_TEST_ENV"),
120123
}
121124

122125
return configTemplate.Execute(dst, &values)

0 commit comments

Comments
 (0)