test 16 KB

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