test 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. #!/usr/bin/env bash
  2. #
  3. # Run all etcd tests
  4. # ./test
  5. # ./test -v
  6. #
  7. # Run tests for one package
  8. #
  9. # PKG=./wal ./test
  10. # PKG=snap ./test
  11. #
  12. # Run code coverage
  13. # COVERDIR must either be a absolute path or a relative path to the etcd root
  14. # COVERDIR=coverage PASSES="build_cov cov" ./test
  15. set -e
  16. source ./build
  17. # build before setting up test GOPATH
  18. if [[ "${PASSES}" == *"functional"* ]]; then
  19. ./tools/functional-tester/build
  20. fi
  21. if [ -z "$PASSES" ]; then
  22. PASSES="fmt bom dep compile build unit"
  23. fi
  24. USERPKG=${PKG:-}
  25. # Invoke ./cover for HTML output
  26. COVER=${COVER:-"-cover"}
  27. # Hack: gofmt ./ will recursively check the .git directory. So use *.go for gofmt.
  28. IGNORE_PKGS="(vendor/|etcdserverpb|rafttest|gopath.proto|v3lockpb|v3electionpb)"
  29. INTEGRATION_PKGS="(integration|e2e|contrib|functional-tester)"
  30. # all github.com/coreos/etcd/whatever pkgs that are not auto-generated / tools
  31. PKGS=$(find . -name \*.go | while read -r a; do dirname "$a"; done | sort | uniq | grep -vE "$IGNORE_PKGS" | grep -vE "(tools/|contrib/|e2e|pb)" | sed "s|\.|${REPO_PATH}|g" | xargs echo)
  32. # pkg1,pkg2,pkg3
  33. PKGS_COMMA=${PKGS// /,}
  34. TEST_PKGS=$(find . -name \*_test.go | while read -r a; do dirname "$a"; done | sort | uniq | grep -vE "$IGNORE_PKGS" | sed "s|\./||g")
  35. FORMATTABLE=$(find . -name \*.go | while read -r a; do echo "$(dirname "$a")/*.go"; done | sort | uniq | grep -vE "$IGNORE_PKGS" | sed "s|\./||g")
  36. TESTABLE_AND_FORMATTABLE=$(echo "$TEST_PKGS" | grep -vE "$INTEGRATION_PKGS")
  37. # check if user provided PKG override
  38. if [ -z "${USERPKG}" ]; then
  39. TEST=$TESTABLE_AND_FORMATTABLE
  40. FMT=$FORMATTABLE
  41. else
  42. # strip out leading dotslashes and trailing slashes from PKG=./foo/
  43. TEST=${USERPKG/#./}
  44. TEST=${TEST/#\//}
  45. TEST=${TEST/%\//}
  46. # only run gofmt on packages provided by user
  47. FMT="$TEST"
  48. fi
  49. FMT=($FMT)
  50. # prepend REPO_PATH to each local package
  51. split=$TEST
  52. TEST=""
  53. for a in $split; do TEST="$TEST ${REPO_PATH}/${a}"; done
  54. TEST=($TEST)
  55. # TODO: 'client' pkg fails with gosimple from generated files
  56. # TODO: 'rafttest' is failing with unused
  57. STATIC_ANALYSIS_PATHS=$(find . -name \*.go | while read -r a; do dirname "$a"; done | sort | uniq | grep -vE "$IGNORE_PKGS" | grep -v 'client')
  58. STATIC_ANALYSIS_PATHS=($STATIC_ANALYSIS_PATHS)
  59. if [ -z "$GOARCH" ]; then
  60. GOARCH=$(go env GOARCH);
  61. fi
  62. # determine whether target supports race detection
  63. if [ "$GOARCH" == "amd64" ]; then
  64. RACE="--race"
  65. fi
  66. function unit_pass {
  67. echo "Running unit tests..."
  68. GO_TEST_FLAG=""
  69. if [ "${VERBOSE}" == "1" ]; then
  70. GO_TEST_FLAG="-v"
  71. fi
  72. if [ "${VERBOSE}" == "2" ]; then
  73. GO_TEST_FLAG="-v"
  74. export CLIENT_DEBUG=1
  75. fi
  76. # only -run=Test so examples can run in integration tests
  77. go test ${GO_TEST_FLAG} -timeout 3m "${COVER}" ${RACE} -cpu 1,2,4 -run=Test "$@" "${TEST[@]}"
  78. }
  79. function integration_pass {
  80. echo "Running integration tests..."
  81. go test -timeout 15m -v -cpu 1,2,4 "$@" "${REPO_PATH}/integration"
  82. integration_extra "$@"
  83. }
  84. function integration_extra {
  85. go test -timeout 1m -v ${RACE} -cpu 1,2,4 "$@" "${REPO_PATH}/client/integration"
  86. go test -timeout 20m -v ${RACE} -cpu 1,2,4 "$@" "${REPO_PATH}/clientv3/integration"
  87. go test -timeout 1m -v -cpu 1,2,4 "$@" "${REPO_PATH}/contrib/raftexample"
  88. go test -timeout 5m -v ${RACE} -tags v2v3 "$@" "${REPO_PATH}/store"
  89. go test -timeout 1m -v ${RACE} -cpu 1,2,4 -run=Example "$@" "${TEST[@]}"
  90. }
  91. function functional_pass {
  92. # Clean up any data and logs from previous runs
  93. rm -rf ./agent-*
  94. for a in 1 2 3; do
  95. mkdir -p ./agent-$a
  96. ./bin/etcd-agent -etcd-path ./bin/etcd -etcd-log-dir "./agent-$a" -port ":${a}9027" -use-root=false &
  97. pid="$!"
  98. agent_pids="${agent_pids} $pid"
  99. done
  100. for a in 1 2 3; do
  101. echo "Waiting for 'etcd-agent' on ${a}9027..."
  102. while ! nc -z localhost ${a}9027; do
  103. sleep 1
  104. done
  105. done
  106. echo "Starting 'etcd-tester'"
  107. ./bin/etcd-tester \
  108. -agent-endpoints "127.0.0.1:19027,127.0.0.1:29027,127.0.0.1:39027" \
  109. -client-ports 12379,22379,32379 \
  110. -peer-ports 12380,22380,32380 \
  111. -limit 1 \
  112. -schedule-cases "0 1 2 3 4 5" \
  113. -stress-qps 1000 \
  114. -stress-key-txn-count 100 \
  115. -stress-key-txn-ops 10 \
  116. -exit-on-failure && echo "'etcd-tester' succeeded"
  117. ETCD_TESTER_EXIT_CODE=$?
  118. echo "ETCD_TESTER_EXIT_CODE:" ${ETCD_TESTER_EXIT_CODE}
  119. echo "Waiting for processes to exit"
  120. agent_pids=($agent_pids)
  121. kill -s TERM "${agent_pids[@]}"
  122. for a in "${agent_pids[@]}"; do wait "$a" || true; done
  123. if [[ "${ETCD_TESTER_EXIT_CODE}" -ne "0" ]]; then
  124. echo "--- FAIL: exit code" ${ETCD_TESTER_EXIT_CODE}
  125. exit ${ETCD_TESTER_EXIT_CODE}
  126. fi
  127. }
  128. function cov_pass {
  129. echo "Running code coverage..."
  130. # install gocovmerge before running code coverage from github.com/wadey/gocovmerge
  131. # gocovmerge merges coverage files
  132. if ! which gocovmerge >/dev/null; then
  133. echo "gocovmerge not installed"
  134. exit 255
  135. fi
  136. if [ -z "$COVERDIR" ]; then
  137. echo "COVERDIR undeclared"
  138. exit 255
  139. fi
  140. if [ ! -f "bin/etcd_test" ]; then
  141. echo "etcd_test binary not found"
  142. exit 255
  143. fi
  144. mkdir -p "$COVERDIR"
  145. # run code coverage for unit and integration tests
  146. GOCOVFLAGS="-covermode=set -coverpkg ${PKGS_COMMA} -v -timeout 15m"
  147. GOCOVFLAGS=($GOCOVFLAGS)
  148. failed=""
  149. for t in $(echo "${TEST_PKGS}" | grep -vE "(e2e|functional-tester)"); do
  150. tf=$(echo "$t" | tr / _)
  151. # cache package compilation data for faster repeated builds
  152. go test "${GOCOVFLAGS[@]}" -i "${REPO_PATH}/$t" || true
  153. # uses -run=Test to skip examples because clientv3/ example tests will leak goroutines
  154. go test "${GOCOVFLAGS[@]}" -run=Test -coverprofile "$COVERDIR/${tf}.coverprofile" "${REPO_PATH}/$t" || failed="$failed $t"
  155. done
  156. # v2v3 tests
  157. go test -tags v2v3 "${GOCOVFLAGS[@]}" -coverprofile "$COVERDIR/store-v2v3.coverprofile" "${REPO_PATH}/clientv3/integration" || failed="$failed store-v2v3"
  158. # proxy tests
  159. go test -tags cluster_proxy "${GOCOVFLAGS[@]}" -coverprofile "$COVERDIR/proxy_integration.coverprofile" "${REPO_PATH}/integration" || failed="$failed proxy-integration"
  160. go test -tags cluster_proxy "${GOCOVFLAGS[@]}" -coverprofile "$COVERDIR/proxy_clientv3.coverprofile" "${REPO_PATH}/clientv3/integration" || failed="$failed proxy-clientv3/integration"
  161. # run code coverage for e2e tests
  162. # use 30m timeout because e2e coverage takes longer
  163. # due to many tests cause etcd process to wait
  164. # on leadership transfer timeout during gracefully shutdown
  165. echo Testing e2e without proxy...
  166. go test -tags cov -timeout 30m -v "${REPO_PATH}/e2e" || failed="$failed e2e"
  167. echo Testing e2e with proxy...
  168. go test -tags "cov cluster_proxy" -timeout 30m -v "${REPO_PATH}/e2e" || failed="$failed e2e-proxy"
  169. # incrementally merge to get coverage data even if some coverage files are corrupted
  170. # optimistically assume etcdserver package's coverage file is OK since gocovmerge
  171. # expects to start with a non-empty file
  172. cp "$COVERDIR"/etcdserver.coverprofile "$COVERDIR"/cover.out
  173. for f in "$COVERDIR"/*.coverprofile; do
  174. echo "merging test coverage file ${f}"
  175. gocovmerge "$f" "$COVERDIR"/cover.out >"$COVERDIR"/cover.tmp || failed="$failed $f"
  176. if [ -s "$COVERDIR"/cover.tmp ]; then
  177. mv "$COVERDIR"/cover.tmp "$COVERDIR"/cover.out
  178. fi
  179. done
  180. # strip out generated files (using GNU-style sed)
  181. sed --in-place '/generated.go/d' "$COVERDIR"/cover.out || true
  182. # held failures to generate the full coverage file, now fail
  183. if [ -n "$failed" ]; then
  184. for f in $failed; do
  185. echo "--- FAIL:" "$f"
  186. done
  187. exit 255
  188. fi
  189. }
  190. function e2e_pass {
  191. echo "Running e2e tests..."
  192. go test -timeout 15m -v -cpu 1,2,4 "$@" "${REPO_PATH}/e2e"
  193. }
  194. function integration_e2e_pass {
  195. echo "Running integration and e2e tests..."
  196. go test -timeout 15m -v -cpu 1,2,4 "$@" "${REPO_PATH}/e2e" &
  197. e2epid="$!"
  198. go test -timeout 15m -v -cpu 1,2,4 "$@" "${REPO_PATH}/integration" &
  199. intpid="$!"
  200. wait $e2epid
  201. wait $intpid
  202. integration_extra "$@"
  203. }
  204. function grpcproxy_pass {
  205. go test -timeout 20m -v ${RACE} -tags cluster_proxy -cpu 1,2,4 "$@" "${REPO_PATH}/integration"
  206. go test -timeout 20m -v ${RACE} -tags cluster_proxy -cpu 1,2,4 "$@" "${REPO_PATH}/clientv3/integration"
  207. go test -timeout 15m -v -tags cluster_proxy "$@" "${REPO_PATH}/e2e"
  208. }
  209. function release_pass {
  210. rm -f ./bin/etcd-last-release
  211. # to grab latest patch release; bump this up for every minor release
  212. UPGRADE_VER=$(git tag -l --sort=-version:refname "v3.3.*" | head -1)
  213. if [ -n "$MANUAL_VER" ]; then
  214. # in case, we need to test against different version
  215. UPGRADE_VER=$MANUAL_VER
  216. fi
  217. if [[ -z ${UPGRADE_VER} ]]; then
  218. UPGRADE_VER="v3.3.0"
  219. echo "fallback to" ${UPGRADE_VER}
  220. fi
  221. local file="etcd-$UPGRADE_VER-linux-$GOARCH.tar.gz"
  222. echo "Downloading $file"
  223. set +e
  224. curl --fail -L "https://github.com/coreos/etcd/releases/download/$UPGRADE_VER/$file" -o "/tmp/$file"
  225. local result=$?
  226. set -e
  227. case $result in
  228. 0) ;;
  229. *) echo "--- FAIL:" ${result}
  230. exit $result
  231. ;;
  232. esac
  233. tar xzvf "/tmp/$file" -C /tmp/ --strip-components=1
  234. mkdir -p ./bin
  235. mv /tmp/etcd ./bin/etcd-last-release
  236. }
  237. function gofmt_pass {
  238. fmtRes=$(gofmt -l -s -d "${FMT[@]}")
  239. if [ -n "${fmtRes}" ]; then
  240. echo -e "gofmt checking failed:\n${fmtRes}"
  241. exit 255
  242. fi
  243. }
  244. function govet_pass {
  245. vetRes=$(go vet "${TEST[@]}")
  246. if [ -n "${vetRes}" ]; then
  247. echo -e "govet checking failed:\n${vetRes}"
  248. exit 255
  249. fi
  250. }
  251. function govet_shadow_pass {
  252. fmtpkgs=$(for a in "${FMT[@]}"; do dirname "$a"; done | sort | uniq | grep -v "\\.")
  253. fmtpkgs=($fmtpkgs)
  254. vetRes=$(go tool vet -all -shadow "${fmtpkgs[@]}" 2>&1 | grep -v '/gw/' || true)
  255. if [ -n "${vetRes}" ]; then
  256. echo -e "govet -all -shadow checking failed:\n${vetRes}"
  257. exit 255
  258. fi
  259. }
  260. function shellcheck_pass {
  261. if which shellcheck >/dev/null; then
  262. shellcheckResult=$(shellcheck -fgcc build test scripts/* 2>&1 || true)
  263. if [ -n "${shellcheckResult}" ]; then
  264. echo -e "shellcheck checking failed:\n${shellcheckResult}"
  265. exit 255
  266. fi
  267. fi
  268. }
  269. function markdown_you_pass {
  270. # eschew you
  271. yous=$(find . -name \*.md -exec grep -E --color "[Yy]ou[r]?[ '.,;]" {} + | grep -v /v2/ || true)
  272. if [ ! -z "$yous" ]; then
  273. echo -e "found 'you' in documentation:\n${yous}"
  274. exit 255
  275. fi
  276. }
  277. function markdown_marker_pass {
  278. # TODO: check other markdown files when marker handles headers with '[]'
  279. if which marker >/dev/null; then
  280. markerResult=$(marker --skip-http --root ./Documentation 2>&1 || true)
  281. if [ -n "${markerResult}" ]; then
  282. echo -e "marker checking failed:\n${markerResult}"
  283. exit 255
  284. fi
  285. else
  286. echo "Skipping marker..."
  287. fi
  288. }
  289. function goword_pass {
  290. if which goword >/dev/null; then
  291. # get all go files to process
  292. gofiles=$(find "${FMT[@]}" -iname '*.go' 2>/dev/null)
  293. gofiles_all=($gofiles)
  294. # ignore tests and protobuf files
  295. gofiles=$(echo "${gofiles_all[@]}" | sort | uniq | sed "s/ /\n/g" | grep -vE "(\\_test.go|\\.pb\\.go)")
  296. gofiles=($gofiles)
  297. # only check for broken exported godocs
  298. gowordRes=$(goword -use-spell=false "${gofiles[@]}" | grep godoc-export | sort)
  299. if [ ! -z "$gowordRes" ]; then
  300. echo -e "goword checking failed:\n${gowordRes}"
  301. exit 255
  302. fi
  303. # check some spelling
  304. gowordRes=$(goword -ignore-file=.words clientv3/{*,*/*}.go 2>&1 | grep spell | sort)
  305. if [ ! -z "$gowordRes" ]; then
  306. echo -e "goword checking failed:\n${gowordRes}"
  307. exit 255
  308. fi
  309. else
  310. echo "Skipping goword..."
  311. fi
  312. }
  313. function gosimple_pass {
  314. if which gosimple >/dev/null; then
  315. gosimpleResult=$(gosimple "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
  316. if [ -n "${gosimpleResult}" ]; then
  317. echo -e "gosimple checking failed:\n${gosimpleResult}"
  318. exit 255
  319. fi
  320. else
  321. echo "Skipping gosimple..."
  322. fi
  323. }
  324. function unused_pass {
  325. if which unused >/dev/null; then
  326. unusedResult=$(unused "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
  327. if [ -n "${unusedResult}" ]; then
  328. echo -e "unused checking failed:\n${unusedResult}"
  329. exit 255
  330. fi
  331. else
  332. echo "Skipping unused..."
  333. fi
  334. }
  335. function staticcheck_pass {
  336. if which staticcheck >/dev/null; then
  337. staticcheckResult=$(staticcheck "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
  338. if [ -n "${staticcheckResult}" ]; then
  339. # TODO: resolve these after go1.8 migration
  340. # See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck
  341. STATIC_CHECK_MASK="SA(1012|1019|2002)"
  342. if echo "${staticcheckResult}" | grep -vE "$STATIC_CHECK_MASK"; then
  343. echo -e "staticcheck checking failed:\n${staticcheckResult}"
  344. exit 255
  345. else
  346. suppressed=$(echo "${staticcheckResult}" | sed 's/ /\n/g' | grep "(SA" | sort | uniq -c)
  347. echo -e "staticcheck suppressed warnings:\n${suppressed}"
  348. fi
  349. fi
  350. else
  351. echo "Skipping staticcheck..."
  352. fi
  353. }
  354. function ineffassign_pass {
  355. if which ineffassign >/dev/null; then
  356. ineffassignResult=$(ineffassign "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
  357. if [ -n "${ineffassignResult}" ]; then
  358. echo -e "ineffassign checking failed:\n${ineffassignResult}"
  359. exit 255
  360. fi
  361. else
  362. echo "Skipping ineffassign..."
  363. fi
  364. }
  365. function nakedret_pass {
  366. if which nakedret >/dev/null; then
  367. nakedretResult=$(nakedret "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
  368. if [ -n "${nakedretResult}" ]; then
  369. echo -e "nakedret checking failed:\n${nakedretResult}"
  370. exit 255
  371. fi
  372. else
  373. echo "Skipping nakedret..."
  374. fi
  375. }
  376. function license_header_pass {
  377. licRes=""
  378. files=$(find . -type f -iname '*.go' ! -path './vendor/*' ! -path './gopath.proto/*')
  379. for file in $files; do
  380. if ! head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)" ; then
  381. licRes="${licRes}"$(echo -e " ${file}")
  382. fi
  383. done
  384. if [ -n "${licRes}" ]; then
  385. echo -e "license header checking failed:\n${licRes}"
  386. exit 255
  387. fi
  388. }
  389. function receiver_name_pass {
  390. recvs=$(grep 'func ([^*]' {*,*/*,*/*/*}.go | grep -Ev "(generated|pb/)" | tr ':' ' ' | \
  391. awk ' { print $2" "$3" "$4" "$1 }' | sed "s/[a-zA-Z\.]*go//g" | sort | uniq | \
  392. grep -Ev "(Descriptor|Proto|_)" | awk ' { print $3" "$4 } ' | sort | uniq -c | grep -v ' 1 ' | awk ' { print $2 } ')
  393. if [ -n "${recvs}" ]; then
  394. recvs=($recvs)
  395. for recv in "${recvs[@]}"; do
  396. echo "Mismatched receiver for $recv..."
  397. grep "$recv" "${FMT[@]}" | grep 'func ('
  398. done
  399. exit 255
  400. fi
  401. }
  402. function commit_title_pass {
  403. git log --oneline "$(git merge-base HEAD master)"...HEAD | while read -r l; do
  404. commitMsg=$(echo "$l" | cut -f2- -d' ')
  405. if [[ "$commitMsg" == Merge* ]]; then
  406. # ignore "Merge pull" commits
  407. continue
  408. fi
  409. if [[ "$commitMsg" == Revert* ]]; then
  410. # ignore revert commits
  411. continue
  412. fi
  413. pkgPrefix=$(echo "$commitMsg" | cut -f1 -d':')
  414. spaceCommas=$(echo "$commitMsg" | sed 's/ /\n/g' | grep -c ',$' || echo 0)
  415. commaSpaces=$(echo "$commitMsg" | sed 's/,/\n/g' | grep -c '^ ' || echo 0)
  416. if [[ $(echo "$commitMsg" | grep -c ":..*") == 0 || "$commitMsg" == "$pkgPrefix" || "$spaceCommas" != "$commaSpaces" ]]; then
  417. echo "$l"...
  418. echo "Expected commit title format '<package>{\", \"<package>}: <description>'"
  419. echo "Got: $l"
  420. exit 255
  421. fi
  422. done
  423. }
  424. function fmt_pass {
  425. toggle_failpoints disable
  426. for p in gofmt \
  427. govet \
  428. govet_shadow \
  429. shellcheck \
  430. markdown_you \
  431. markdown_marker \
  432. goword \
  433. gosimple \
  434. unused \
  435. staticcheck \
  436. ineffassign \
  437. nakedret \
  438. license_header \
  439. receiver_name \
  440. commit_title \
  441. ; do
  442. echo "Starting '$p' pass at $(date)"
  443. "${p}"_pass "$@"
  444. echo "Finished '$p' pass at $(date)"
  445. done
  446. }
  447. function bom_pass {
  448. if ! which license-bill-of-materials >/dev/null; then
  449. return
  450. fi
  451. echo "Checking bill of materials..."
  452. license-bill-of-materials \
  453. --override-file bill-of-materials.override.json \
  454. github.com/coreos/etcd github.com/coreos/etcd/etcdctl >bom-now.json || true
  455. if ! diff bill-of-materials.json bom-now.json; then
  456. echo "vendored licenses do not match given bill of materials"
  457. exit 255
  458. fi
  459. rm bom-now.json
  460. }
  461. function dep_pass {
  462. echo "Checking package dependencies..."
  463. # don't pull in etcdserver package
  464. pushd clientv3 >/dev/null
  465. badpkg="(etcdserver$|mvcc$|backend$|grpc-gateway)"
  466. deps=$(go list -f '{{ .Deps }}' | sed 's/ /\n/g' | grep -E "${badpkg}" || echo "")
  467. popd >/dev/null
  468. if [ ! -z "$deps" ]; then
  469. echo -e "clientv3 has masked dependencies:\n${deps}"
  470. exit 255
  471. fi
  472. }
  473. function build_cov_pass {
  474. out="bin"
  475. if [ -n "${BINDIR}" ]; then out="${BINDIR}"; fi
  476. go test -tags cov -c -covermode=set -coverpkg="$PKGS_COMMA" -o "${out}/etcd_test"
  477. go test -tags cov -c -covermode=set -coverpkg="$PKGS_COMMA" -o "${out}/etcdctl_test" "${REPO_PATH}/etcdctl"
  478. }
  479. function compile_pass {
  480. echo "Checking build..."
  481. go build -v ./tools/...
  482. }
  483. # fail fast on static tests
  484. function build_pass {
  485. GO_BUILD_FLAGS="-a -v" etcd_build
  486. }
  487. for pass in $PASSES; do
  488. echo "Starting '$pass' pass at $(date)"
  489. "${pass}"_pass "$@"
  490. echo "Finished '$pass' pass at $(date)"
  491. done
  492. echo "Success"