Makefile 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. # run from repository root
  2. TEST_SUFFIX = $(shell date +%s | base64 | head -c 15)
  3. .PHONY: build
  4. build:
  5. GO_BUILD_FLAGS="-v" ./build
  6. ./bin/etcd --version
  7. ETCDCTL_API=3 ./bin/etcdctl version
  8. .PHONY: test
  9. test:
  10. $(info log-file: test-$(TEST_SUFFIX).log)
  11. PASSES='fmt bom dep compile build unit' ./test 2>&1 | tee test-$(TEST_SUFFIX).log
  12. ! grep FAIL -A10 -B50 test-$(TEST_SUFFIX).log
  13. test-fmt:
  14. $(info log-file: test-fmt-$(TEST_SUFFIX).log)
  15. PASSES='fmt' ./test 2>&1 | tee test-fmt-$(TEST_SUFFIX).log
  16. ! grep FAIL -A10 -B50 test-fmt-$(TEST_SUFFIX).log
  17. test-all:
  18. $(info log-file: test-all-$(TEST_SUFFIX).log)
  19. RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional' ./test 2>&1 | tee test-all-$(TEST_SUFFIX).log
  20. ! grep FAIL -A10 -B50 test-all-$(TEST_SUFFIX).log
  21. test-proxy:
  22. $(info log-file: test-proxy-$(TEST_SUFFIX).log)
  23. PASSES='build grpcproxy' ./test 2>&1 | tee test-proxy-$(TEST_SUFFIX).log
  24. ! grep FAIL -A10 -B50 test-proxy-$(TEST_SUFFIX).log
  25. test-coverage:
  26. $(info log-file: test-coverage-$(TEST_SUFFIX).log)
  27. COVERDIR=covdir PASSES='build build_cov cov' ./test 2>&1 | tee test-coverage-$(TEST_SUFFIX).log
  28. $(shell curl -s https://codecov.io/bash >codecov)
  29. chmod 700 ./codecov
  30. ./codecov -h
  31. ./codecov -t 6040de41-c073-4d6f-bbf8-d89256ef31e1
  32. # clean up failed tests, logs, dependencies
  33. clean:
  34. rm -f ./codecov
  35. rm -f ./*.log
  36. rm -f ./bin/Dockerfile-release
  37. rm -rf ./bin/*.etcd
  38. rm -rf ./gopath
  39. rm -rf ./release
  40. rm -f ./integration/127.0.0.1:* ./integration/localhost:*
  41. rm -f ./clientv3/integration/127.0.0.1:* ./clientv3/integration/localhost:*
  42. rm -f ./clientv3/ordering/127.0.0.1:* ./clientv3/ordering/localhost:*
  43. # sync with Dockerfile-test, e2e/docker-dns/Dockerfile, e2e/docker-dns-srv/Dockerfile
  44. _GO_VERSION = go1.9.1
  45. ifdef GO_VERSION
  46. _GO_VERSION = $(GO_VERSION)
  47. endif
  48. # build base container image for testing on Linux
  49. docker-test-build:
  50. docker build --tag gcr.io/etcd-development/etcd-test:$(_GO_VERSION) --file ./Dockerfile-test .
  51. # e.g.
  52. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io
  53. docker-test-push:
  54. gcloud docker -- push gcr.io/etcd-development/etcd-test:$(_GO_VERSION)
  55. docker-test-pull:
  56. docker pull gcr.io/etcd-development/etcd-test:$(_GO_VERSION)
  57. # compile etcd and etcdctl with Linux
  58. docker-test-compile:
  59. docker run \
  60. --rm \
  61. --volume=`pwd`/:/etcd \
  62. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  63. /bin/bash -c "cd /etcd && GO_BUILD_FLAGS=-v ./build && ./bin/etcd --version"
  64. # run tests inside container
  65. docker-test:
  66. $(info log-file: docker-test-$(TEST_SUFFIX).log)
  67. docker run \
  68. --rm \
  69. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  70. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  71. /bin/bash -c "PASSES='fmt bom dep compile build unit' ./test 2>&1 | tee docker-test-$(TEST_SUFFIX).log"
  72. ! grep FAIL -A10 -B50 docker-test-$(TEST_SUFFIX).log
  73. docker-test-386:
  74. $(info log-file: docker-test-386-$(TEST_SUFFIX).log)
  75. docker run \
  76. --rm \
  77. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  78. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  79. /bin/bash -c "GOARCH=386 PASSES='build unit integration_e2e' ./test 2>&1 | tee docker-test-386-$(TEST_SUFFIX).log"
  80. ! grep FAIL -A10 -B50 docker-test-386-$(TEST_SUFFIX).log
  81. docker-test-fmt:
  82. $(info log-file: docker-test-fmt-$(TEST_SUFFIX).log)
  83. docker run \
  84. --rm \
  85. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  86. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  87. /bin/bash -c "PASSES='fmt' ./test 2>&1 | tee docker-test-fmt-$(TEST_SUFFIX).log"
  88. ! grep FAIL -A10 -B50 docker-test-fmt-$(TEST_SUFFIX).log
  89. docker-test-all:
  90. $(info log-file: docker-test-all-$(TEST_SUFFIX).log)
  91. docker run \
  92. --rm \
  93. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  94. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  95. /bin/bash -c "RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional' ./test 2>&1 | tee docker-test-all-$(TEST_SUFFIX).log"
  96. ! grep FAIL -A10 -B50 docker-test-all-$(TEST_SUFFIX).log
  97. docker-test-all-386:
  98. $(info log-file: docker-test-all-386-$(TEST_SUFFIX).log)
  99. docker run \
  100. --rm \
  101. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  102. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  103. /bin/bash -c "GOARCH=386 PASSES='build unit release integration_e2e functional' ./test 2>&1 | tee docker-test-all-386-$(TEST_SUFFIX).log"
  104. ! grep FAIL -A10 -B50 docker-test-all-386-$(TEST_SUFFIX).log
  105. docker-test-proxy:
  106. $(info log-file: docker-test-proxy-$(TEST_SUFFIX).log)
  107. docker run \
  108. --rm \
  109. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  110. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  111. /bin/bash -c "PASSES='build grpcproxy' ./test 2>&1 | tee docker-test-proxy-$(TEST_SUFFIX).log"
  112. ! grep FAIL -A10 -B50 docker-test-proxy-$(TEST_SUFFIX).log
  113. # build release container image with Linux
  114. _ETCD_VERSION ?= $(shell git rev-parse --short HEAD || echo "GitNotFound")
  115. ifdef ETCD_VERSION
  116. _ETCD_VERSION = $(ETCD_VERSION)
  117. endif
  118. docker-release-master-build: docker-test-compile
  119. cp ./Dockerfile-release ./bin/Dockerfile-release
  120. docker build \
  121. --tag gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \
  122. --file ./bin/Dockerfile-release \
  123. ./bin
  124. rm -f ./bin/Dockerfile-release
  125. docker run \
  126. --rm \
  127. gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \
  128. /bin/sh -c "/usr/local/bin/etcd --version && ETCDCTL_API=3 /usr/local/bin/etcdctl version"
  129. docker-release-master-push:
  130. gcloud docker -- push gcr.io/etcd-development/etcd:$(_ETCD_VERSION)
  131. # build base container image for DNS testing
  132. docker-dns-test-build:
  133. docker build \
  134. --tag gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) \
  135. --file ./e2e/docker-dns/Dockerfile \
  136. ./e2e/docker-dns
  137. docker run \
  138. --rm \
  139. --dns 127.0.0.1 \
  140. gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) \
  141. /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig etcd.local"
  142. docker-dns-test-push:
  143. gcloud docker -- push gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION)
  144. docker-dns-test-pull:
  145. docker pull gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION)
  146. # run DNS tests inside container
  147. docker-dns-test-run:
  148. docker run \
  149. --rm \
  150. --tty \
  151. --dns 127.0.0.1 \
  152. --volume=`pwd`/bin:/etcd \
  153. --volume=`pwd`/integration/fixtures:/certs \
  154. gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) \
  155. /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd"
  156. # build base container image for DNS/SRV testing
  157. docker-dns-srv-test-build:
  158. docker build \
  159. --tag gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) \
  160. --file ./e2e/docker-dns-srv/Dockerfile \
  161. ./e2e/docker-dns-srv
  162. docker run \
  163. --rm \
  164. --dns 127.0.0.1 \
  165. gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) \
  166. /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig +noall +answer SRV _etcd-client-ssl._tcp.etcd.local && dig +noall +answer SRV _etcd-server-ssl._tcp.etcd.local && dig +noall +answer m1.etcd.local m2.etcd.local m3.etcd.local"
  167. docker-dns-srv-test-push:
  168. gcloud docker -- push gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION)
  169. docker-dns-srv-test-pull:
  170. docker pull gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION)
  171. # run DNS/SRV tests inside container
  172. docker-dns-srv-test-run:
  173. docker run \
  174. --rm \
  175. --tty \
  176. --dns 127.0.0.1 \
  177. --volume=`pwd`/bin:/etcd \
  178. --volume=`pwd`/integration/fixtures:/certs \
  179. gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) \
  180. /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd"
  181. # TODO: add DNS integration tests