test 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  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}/internal/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" &
  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 1379,2379,3379 \
  110. -advertise-client-ports 13790,23790,33790 \
  111. -peer-ports 1380,2380,3380 \
  112. -advertise-peer-ports 13800,23800,33800 \
  113. -limit 1 \
  114. -schedule-cases "0 1 2 3 4 5 6 7 8 9" \
  115. -stress-qps 1000 \
  116. -stress-key-txn-count 100 \
  117. -stress-key-txn-ops 10 \
  118. -exit-on-failure && echo "'etcd-tester' succeeded"
  119. ETCD_TESTER_EXIT_CODE=$?
  120. echo "ETCD_TESTER_EXIT_CODE:" ${ETCD_TESTER_EXIT_CODE}
  121. echo "Waiting for processes to exit"
  122. agent_pids=($agent_pids)
  123. kill -s TERM "${agent_pids[@]}"
  124. for a in "${agent_pids[@]}"; do wait "$a" || true; done
  125. if [[ "${ETCD_TESTER_EXIT_CODE}" -ne "0" ]]; then
  126. echo "--- FAIL: exit code" ${ETCD_TESTER_EXIT_CODE}
  127. exit ${ETCD_TESTER_EXIT_CODE}
  128. fi
  129. }
  130. function cov_pass {
  131. echo "Running code coverage..."
  132. # install gocovmerge before running code coverage from github.com/wadey/gocovmerge
  133. # gocovmerge merges coverage files
  134. if ! which gocovmerge >/dev/null; then
  135. echo "gocovmerge not installed"
  136. exit 255
  137. fi
  138. if [ -z "$COVERDIR" ]; then
  139. echo "COVERDIR undeclared"
  140. exit 255
  141. fi
  142. if [ ! -f "bin/etcd_test" ]; then
  143. echo "etcd_test binary not found"
  144. exit 255
  145. fi
  146. mkdir -p "$COVERDIR"
  147. # run code coverage for unit and integration tests
  148. GOCOVFLAGS="-covermode=set -coverpkg ${PKGS_COMMA} -v -timeout 15m"
  149. GOCOVFLAGS=($GOCOVFLAGS)
  150. failed=""
  151. for t in $(echo "${TEST_PKGS}" | grep -vE "(e2e|functional-tester)"); do
  152. tf=$(echo "$t" | tr / _)
  153. # cache package compilation data for faster repeated builds
  154. go test "${GOCOVFLAGS[@]}" -i "${REPO_PATH}/$t" || true
  155. # uses -run=Test to skip examples because clientv3/ example tests will leak goroutines
  156. go test "${GOCOVFLAGS[@]}" -run=Test -coverprofile "$COVERDIR/${tf}.coverprofile" "${REPO_PATH}/$t" || failed="$failed $t"
  157. done
  158. # v2v3 tests
  159. go test -tags v2v3 "${GOCOVFLAGS[@]}" -coverprofile "$COVERDIR/store-v2v3.coverprofile" "${REPO_PATH}/clientv3/integration" || failed="$failed store-v2v3"
  160. # proxy tests
  161. go test -tags cluster_proxy "${GOCOVFLAGS[@]}" -coverprofile "$COVERDIR/proxy_integration.coverprofile" "${REPO_PATH}/integration" || failed="$failed proxy-integration"
  162. go test -tags cluster_proxy "${GOCOVFLAGS[@]}" -coverprofile "$COVERDIR/proxy_clientv3.coverprofile" "${REPO_PATH}/clientv3/integration" || failed="$failed proxy-clientv3/integration"
  163. # run code coverage for e2e tests
  164. # use 30m timeout because e2e coverage takes longer
  165. # due to many tests cause etcd process to wait
  166. # on leadership transfer timeout during gracefully shutdown
  167. echo Testing e2e without proxy...
  168. go test -tags cov -timeout 30m -v "${REPO_PATH}/e2e" || failed="$failed e2e"
  169. echo Testing e2e with proxy...
  170. go test -tags "cov cluster_proxy" -timeout 30m -v "${REPO_PATH}/e2e" || failed="$failed e2e-proxy"
  171. # incrementally merge to get coverage data even if some coverage files are corrupted
  172. # optimistically assume etcdserver package's coverage file is OK since gocovmerge
  173. # expects to start with a non-empty file
  174. cp "$COVERDIR"/etcdserver.coverprofile "$COVERDIR"/cover.out
  175. for f in "$COVERDIR"/*.coverprofile; do
  176. echo "merging test coverage file ${f}"
  177. gocovmerge "$f" "$COVERDIR"/cover.out >"$COVERDIR"/cover.tmp || failed="$failed $f"
  178. if [ -s "$COVERDIR"/cover.tmp ]; then
  179. mv "$COVERDIR"/cover.tmp "$COVERDIR"/cover.out
  180. fi
  181. done
  182. # strip out generated files (using GNU-style sed)
  183. sed --in-place '/generated.go/d' "$COVERDIR"/cover.out || true
  184. # held failures to generate the full coverage file, now fail
  185. if [ -n "$failed" ]; then
  186. for f in $failed; do
  187. echo "--- FAIL:" "$f"
  188. done
  189. exit 255
  190. fi
  191. }
  192. function e2e_pass {
  193. echo "Running e2e tests..."
  194. go test -timeout 15m -v -cpu 1,2,4 "$@" "${REPO_PATH}/e2e"
  195. }
  196. function integration_e2e_pass {
  197. echo "Running integration and e2e tests..."
  198. go test -timeout 15m -v -cpu 1,2,4 "$@" "${REPO_PATH}/e2e" &
  199. e2epid="$!"
  200. go test -timeout 15m -v -cpu 1,2,4 "$@" "${REPO_PATH}/integration" &
  201. intpid="$!"
  202. wait $e2epid
  203. wait $intpid
  204. integration_extra "$@"
  205. }
  206. function grpcproxy_pass {
  207. go test -timeout 20m -v ${RACE} -tags cluster_proxy -cpu 1,2,4 "$@" "${REPO_PATH}/integration"
  208. go test -timeout 20m -v ${RACE} -tags cluster_proxy -cpu 1,2,4 "$@" "${REPO_PATH}/clientv3/integration"
  209. go test -timeout 15m -v -tags cluster_proxy "$@" "${REPO_PATH}/e2e"
  210. }
  211. function release_pass {
  212. rm -f ./bin/etcd-last-release
  213. # to grab latest patch release; bump this up for every minor release
  214. UPGRADE_VER=$(git tag -l --sort=-version:refname "v3.3.*" | head -1)
  215. if [ -n "$MANUAL_VER" ]; then
  216. # in case, we need to test against different version
  217. UPGRADE_VER=$MANUAL_VER
  218. fi
  219. if [[ -z ${UPGRADE_VER} ]]; then
  220. UPGRADE_VER="v3.3.0"
  221. echo "fallback to" ${UPGRADE_VER}
  222. fi
  223. local file="etcd-$UPGRADE_VER-linux-$GOARCH.tar.gz"
  224. echo "Downloading $file"
  225. set +e
  226. curl --fail -L "https://github.com/coreos/etcd/releases/download/$UPGRADE_VER/$file" -o "/tmp/$file"
  227. local result=$?
  228. set -e
  229. case $result in
  230. 0) ;;
  231. *) echo "--- FAIL:" ${result}
  232. exit $result
  233. ;;
  234. esac
  235. tar xzvf "/tmp/$file" -C /tmp/ --strip-components=1
  236. mkdir -p ./bin
  237. mv /tmp/etcd ./bin/etcd-last-release
  238. }
  239. function gofmt_pass {
  240. fmtRes=$(gofmt -l -s -d "${FMT[@]}")
  241. if [ -n "${fmtRes}" ]; then
  242. echo -e "gofmt checking failed:\n${fmtRes}"
  243. exit 255
  244. fi
  245. }
  246. function govet_pass {
  247. vetRes=$(go vet "${TEST[@]}")
  248. if [ -n "${vetRes}" ]; then
  249. echo -e "govet checking failed:\n${vetRes}"
  250. exit 255
  251. fi
  252. }
  253. function govet_shadow_pass {
  254. fmtpkgs=$(for a in "${FMT[@]}"; do dirname "$a"; done | sort | uniq | grep -v "\\.")
  255. fmtpkgs=($fmtpkgs)
  256. vetRes=$(go tool vet -all -shadow "${fmtpkgs[@]}" 2>&1 | grep -v '/gw/' || true)
  257. if [ -n "${vetRes}" ]; then
  258. echo -e "govet -all -shadow checking failed:\n${vetRes}"
  259. exit 255
  260. fi
  261. }
  262. function shellcheck_pass {
  263. if which shellcheck >/dev/null; then
  264. shellcheckResult=$(shellcheck -fgcc build test scripts/* 2>&1 || true)
  265. if [ -n "${shellcheckResult}" ]; then
  266. echo -e "shellcheck checking failed:\n${shellcheckResult}"
  267. exit 255
  268. fi
  269. fi
  270. }
  271. function markdown_you_pass {
  272. # eschew you
  273. yous=$(find . -name \*.md -exec grep -E --color "[Yy]ou[r]?[ '.,;]" {} + | grep -v /v2/ || true)
  274. if [ ! -z "$yous" ]; then
  275. echo -e "found 'you' in documentation:\n${yous}"
  276. exit 255
  277. fi
  278. }
  279. function markdown_marker_pass {
  280. # TODO: check other markdown files when marker handles headers with '[]'
  281. if which marker >/dev/null; then
  282. markerResult=$(marker --skip-http --root ./Documentation 2>&1 || true)
  283. if [ -n "${markerResult}" ]; then
  284. echo -e "marker checking failed:\n${markerResult}"
  285. exit 255
  286. fi
  287. else
  288. echo "Skipping marker..."
  289. fi
  290. }
  291. function goword_pass {
  292. if which goword >/dev/null; then
  293. # get all go files to process
  294. gofiles=$(find "${FMT[@]}" -iname '*.go' 2>/dev/null)
  295. gofiles_all=($gofiles)
  296. # ignore tests and protobuf files
  297. gofiles=$(echo "${gofiles_all[@]}" | sort | uniq | sed "s/ /\n/g" | grep -vE "(\\_test.go|\\.pb\\.go)")
  298. gofiles=($gofiles)
  299. # only check for broken exported godocs
  300. gowordRes=$(goword -use-spell=false "${gofiles[@]}" | grep godoc-export | sort)
  301. if [ ! -z "$gowordRes" ]; then
  302. echo -e "goword checking failed:\n${gowordRes}"
  303. exit 255
  304. fi
  305. # check some spelling
  306. gowordRes=$(goword -ignore-file=.words clientv3/{*,*/*}.go 2>&1 | grep spell | sort)
  307. if [ ! -z "$gowordRes" ]; then
  308. echo -e "goword checking failed:\n${gowordRes}"
  309. exit 255
  310. fi
  311. else
  312. echo "Skipping goword..."
  313. fi
  314. }
  315. function gosimple_pass {
  316. if which gosimple >/dev/null; then
  317. gosimpleResult=$(gosimple "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
  318. if [ -n "${gosimpleResult}" ]; then
  319. echo -e "gosimple checking failed:\n${gosimpleResult}"
  320. exit 255
  321. fi
  322. else
  323. echo "Skipping gosimple..."
  324. fi
  325. }
  326. function unused_pass {
  327. if which unused >/dev/null; then
  328. unusedResult=$(unused "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
  329. if [ -n "${unusedResult}" ]; then
  330. echo -e "unused checking failed:\n${unusedResult}"
  331. exit 255
  332. fi
  333. else
  334. echo "Skipping unused..."
  335. fi
  336. }
  337. function staticcheck_pass {
  338. if which staticcheck >/dev/null; then
  339. staticcheckResult=$(staticcheck "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
  340. if [ -n "${staticcheckResult}" ]; then
  341. # TODO: resolve these after go1.8 migration
  342. # See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck
  343. STATIC_CHECK_MASK="SA(1012|1019|2002)"
  344. if echo "${staticcheckResult}" | grep -vE "$STATIC_CHECK_MASK"; then
  345. echo -e "staticcheck checking failed:\n${staticcheckResult}"
  346. exit 255
  347. else
  348. suppressed=$(echo "${staticcheckResult}" | sed 's/ /\n/g' | grep "(SA" | sort | uniq -c)
  349. echo -e "staticcheck suppressed warnings:\n${suppressed}"
  350. fi
  351. fi
  352. else
  353. echo "Skipping staticcheck..."
  354. fi
  355. }
  356. function ineffassign_pass {
  357. if which ineffassign >/dev/null; then
  358. ineffassignResult=$(ineffassign "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
  359. if [ -n "${ineffassignResult}" ]; then
  360. echo -e "ineffassign checking failed:\n${ineffassignResult}"
  361. exit 255
  362. fi
  363. else
  364. echo "Skipping ineffassign..."
  365. fi
  366. }
  367. function nakedret_pass {
  368. if which nakedret >/dev/null; then
  369. nakedretResult=$(nakedret "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
  370. if [ -n "${nakedretResult}" ]; then
  371. echo -e "nakedret checking failed:\n${nakedretResult}"
  372. exit 255
  373. fi
  374. else
  375. echo "Skipping nakedret..."
  376. fi
  377. }
  378. function license_header_pass {
  379. licRes=""
  380. files=$(find . -type f -iname '*.go' ! -path './vendor/*' ! -path './gopath.proto/*')
  381. for file in $files; do
  382. if ! head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)" ; then
  383. licRes="${licRes}"$(echo -e " ${file}")
  384. fi
  385. done
  386. if [ -n "${licRes}" ]; then
  387. echo -e "license header checking failed:\n${licRes}"
  388. exit 255
  389. fi
  390. }
  391. function receiver_name_pass {
  392. recvs=$(grep 'func ([^*]' {*,*/*,*/*/*}.go | grep -Ev "(generated|pb/)" | tr ':' ' ' | \
  393. awk ' { print $2" "$3" "$4" "$1 }' | sed "s/[a-zA-Z\.]*go//g" | sort | uniq | \
  394. grep -Ev "(Descriptor|Proto|_)" | awk ' { print $3" "$4 } ' | sort | uniq -c | grep -v ' 1 ' | awk ' { print $2 } ')
  395. if [ -n "${recvs}" ]; then
  396. recvs=($recvs)
  397. for recv in "${recvs[@]}"; do
  398. echo "Mismatched receiver for $recv..."
  399. grep "$recv" "${FMT[@]}" | grep 'func ('
  400. done
  401. exit 255
  402. fi
  403. }
  404. function commit_title_pass {
  405. git log --oneline "$(git merge-base HEAD master)"...HEAD | while read -r l; do
  406. commitMsg=$(echo "$l" | cut -f2- -d' ')
  407. if [[ "$commitMsg" == Merge* ]]; then
  408. # ignore "Merge pull" commits
  409. continue
  410. fi
  411. if [[ "$commitMsg" == Revert* ]]; then
  412. # ignore revert commits
  413. continue
  414. fi
  415. pkgPrefix=$(echo "$commitMsg" | cut -f1 -d':')
  416. spaceCommas=$(echo "$commitMsg" | sed 's/ /\n/g' | grep -c ',$' || echo 0)
  417. commaSpaces=$(echo "$commitMsg" | sed 's/,/\n/g' | grep -c '^ ' || echo 0)
  418. if [[ $(echo "$commitMsg" | grep -c ":..*") == 0 || "$commitMsg" == "$pkgPrefix" || "$spaceCommas" != "$commaSpaces" ]]; then
  419. echo "$l"...
  420. echo "Expected commit title format '<package>{\", \"<package>}: <description>'"
  421. echo "Got: $l"
  422. exit 255
  423. fi
  424. done
  425. }
  426. function fmt_pass {
  427. toggle_failpoints disable
  428. for p in gofmt \
  429. govet \
  430. govet_shadow \
  431. shellcheck \
  432. markdown_you \
  433. markdown_marker \
  434. goword \
  435. gosimple \
  436. unused \
  437. staticcheck \
  438. ineffassign \
  439. nakedret \
  440. license_header \
  441. receiver_name \
  442. commit_title \
  443. ; do
  444. echo "Starting '$p' pass at $(date)"
  445. "${p}"_pass "$@"
  446. echo "Finished '$p' pass at $(date)"
  447. done
  448. }
  449. function bom_pass {
  450. if ! which license-bill-of-materials >/dev/null; then
  451. return
  452. fi
  453. echo "Checking bill of materials..."
  454. license-bill-of-materials \
  455. --override-file bill-of-materials.override.json \
  456. github.com/coreos/etcd github.com/coreos/etcd/etcdctl >bom-now.json || true
  457. if ! diff bill-of-materials.json bom-now.json; then
  458. echo "vendored licenses do not match given bill of materials"
  459. exit 255
  460. fi
  461. rm bom-now.json
  462. }
  463. function dep_pass {
  464. echo "Checking package dependencies..."
  465. # don't pull in etcdserver package
  466. pushd clientv3 >/dev/null
  467. badpkg="(etcdserver$|mvcc$|backend$|grpc-gateway)"
  468. deps=$(go list -f '{{ .Deps }}' | sed 's/ /\n/g' | grep -E "${badpkg}" || echo "")
  469. popd >/dev/null
  470. if [ ! -z "$deps" ]; then
  471. echo -e "clientv3 has masked dependencies:\n${deps}"
  472. exit 255
  473. fi
  474. }
  475. function build_cov_pass {
  476. out="bin"
  477. if [ -n "${BINDIR}" ]; then out="${BINDIR}"; fi
  478. go test -tags cov -c -covermode=set -coverpkg="$PKGS_COMMA" -o "${out}/etcd_test"
  479. go test -tags cov -c -covermode=set -coverpkg="$PKGS_COMMA" -o "${out}/etcdctl_test" "${REPO_PATH}/etcdctl"
  480. }
  481. function compile_pass {
  482. echo "Checking build..."
  483. go build -v ./tools/...
  484. }
  485. # fail fast on static tests
  486. function build_pass {
  487. GO_BUILD_FLAGS="-a -v" etcd_build
  488. }
  489. for pass in $PASSES; do
  490. echo "Starting '$pass' pass at $(date)"
  491. "${pass}"_pass "$@"
  492. echo "Finished '$pass' pass at $(date)"
  493. done
  494. echo "Success"