test 16 KB

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