Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. # run from repository root
  2. #
  3. # Example:
  4. # make clean -f ./hack/scripts-dev/Makefile
  5. # make build -f ./hack/scripts-dev/Makefile
  6. .PHONY: build
  7. build:
  8. GO_BUILD_FLAGS="-v" ./build
  9. ./bin/etcd --version
  10. ETCDCTL_API=3 ./bin/etcdctl version
  11. clean:
  12. rm -f ./codecov
  13. rm -rf ./agent-*
  14. rm -rf ./covdir
  15. rm -f ./*.log
  16. rm -f ./bin/Dockerfile-release
  17. rm -rf ./bin/*.etcd
  18. rm -rf ./gopath
  19. rm -rf ./release
  20. rm -f ./integration/127.0.0.1:* ./integration/localhost:*
  21. rm -f ./clientv3/integration/127.0.0.1:* ./clientv3/integration/localhost:*
  22. rm -f ./clientv3/ordering/127.0.0.1:* ./clientv3/ordering/localhost:*
  23. _GO_VERSION = 1.9.2
  24. ifdef GO_VERSION
  25. _GO_VERSION = $(GO_VERSION)
  26. endif
  27. # Example:
  28. # GO_VERSION=1.8.5 make build-docker-test -f ./hack/scripts-dev/Makefile
  29. # make build-docker-test -f ./hack/scripts-dev/Makefile
  30. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io
  31. # GO_VERSION=1.8.5 make push-docker-test -f ./hack/scripts-dev/Makefile
  32. # make push-docker-test -f ./hack/scripts-dev/Makefile
  33. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  34. # GO_VERSION=1.8.5 make pull-docker-test -f ./hack/scripts-dev/Makefile
  35. # make pull-docker-test -f ./hack/scripts-dev/Makefile
  36. build-docker-test:
  37. $(info GO_VERSION: $(_GO_VERSION))
  38. @cat ./Dockerfile-test | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
  39. > ./.Dockerfile-test
  40. docker build \
  41. --tag gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \
  42. --file ./.Dockerfile-test .
  43. push-docker-test:
  44. $(info GO_VERSION: $(_GO_VERSION))
  45. gcloud docker -- push gcr.io/etcd-development/etcd-test:go$(_GO_VERSION)
  46. pull-docker-test:
  47. $(info GO_VERSION: $(_GO_VERSION))
  48. docker pull gcr.io/etcd-development/etcd-test:go$(_GO_VERSION)
  49. compile-with-docker-test:
  50. $(info GO_VERSION: $(_GO_VERSION))
  51. docker run \
  52. --rm \
  53. --volume=`pwd`/:/etcd \
  54. gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \
  55. /bin/bash -c "cd /etcd && GO_BUILD_FLAGS=-v ./build && ./bin/etcd --version"
  56. # Local machine:
  57. # TEST_OPTS="PASSES='fmt'" make test -f ./hack/scripts-dev/Makefile
  58. # TEST_OPTS="PASSES='fmt bom dep compile build unit'" make test -f ./hack/scripts-dev/Makefile
  59. # TEST_OPTS="RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional'" make test -f ./hack/scripts-dev/Makefile
  60. # TEST_OPTS="PASSES='build grpcproxy'" make test -f ./hack/scripts-dev/Makefile
  61. #
  62. # Example (test with docker):
  63. # make pull-docker-test -f ./hack/scripts-dev/Makefile
  64. # TEST_OPTS="PASSES='fmt'" make docker-test -f ./hack/scripts-dev/Makefile
  65. # TEST_OPTS="VERBOSE=2 PASSES='unit'" make docker-test -f ./hack/scripts-dev/Makefile
  66. #
  67. # Travis CI (test with docker):
  68. # TEST_OPTS="PASSES='fmt bom dep compile build unit'" make docker-test -f ./hack/scripts-dev/Makefile
  69. #
  70. # Semaphore CI (test with docker):
  71. # TEST_OPTS="RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional'" make docker-test -f ./hack/scripts-dev/Makefile
  72. # TEST_OPTS="GOARCH=386 PASSES='build unit integration_e2e'" make docker-test -f ./hack/scripts-dev/Makefile
  73. #
  74. # grpc-proxy tests (test with docker):
  75. # TEST_OPTS="PASSES='build grpcproxy'" make docker-test -f ./hack/scripts-dev/Makefile
  76. TEST_SUFFIX = $(shell date +%s | base64 | head -c 15)
  77. _TEST_OPTS = "PASSES='unit'"
  78. ifdef TEST_OPTS
  79. _TEST_OPTS = $(TEST_OPTS)
  80. endif
  81. .PHONY: test
  82. test:
  83. $(info TEST_OPTS: $(_TEST_OPTS))
  84. $(info log-file: test-$(TEST_SUFFIX).log)
  85. $(_TEST_OPTS) ./test 2>&1 | tee test-$(TEST_SUFFIX).log
  86. ! egrep "(--- FAIL:|panic: test timed out|appears to have leaked|Too many goroutines)" -B50 -A10 test-$(TEST_SUFFIX).log
  87. docker-test:
  88. $(info GO_VERSION: $(_GO_VERSION))
  89. $(info TEST_OPTS: $(_TEST_OPTS))
  90. $(info log-file: test-$(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$(_GO_VERSION) \
  95. /bin/bash -c "$(_TEST_OPTS) ./test 2>&1 | tee test-$(TEST_SUFFIX).log"
  96. ! egrep "(--- FAIL:|panic: test timed out|appears to have leaked|Too many goroutines)" -B50 -A10 test-$(TEST_SUFFIX).log
  97. docker-test-coverage:
  98. $(info GO_VERSION: $(_GO_VERSION))
  99. $(info log-file: docker-test-coverage-$(TEST_SUFFIX).log)
  100. docker run \
  101. --rm \
  102. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  103. gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \
  104. /bin/bash -c "COVERDIR=covdir PASSES='build build_cov cov' ./test 2>&1 | tee docker-test-coverage-$(TEST_SUFFIX).log && /codecov -t 6040de41-c073-4d6f-bbf8-d89256ef31e1"
  105. ! egrep "(--- FAIL:|panic: test timed out|appears to have leaked|Too many goroutines)" -B50 -A10 docker-test-coverage-$(TEST_SUFFIX).log
  106. # build release container image with Linux
  107. _ETCD_VERSION ?= $(shell git rev-parse --short HEAD || echo "GitNotFound")
  108. ifdef ETCD_VERSION
  109. _ETCD_VERSION = $(ETCD_VERSION)
  110. endif
  111. # Example:
  112. # ETCD_VERSION=v3.3.0-test.0 make build-docker-release-master -f ./hack/scripts-dev/Makefile
  113. # ETCD_VERSION=v3.3.0-test.0 make push-docker-release-master -f ./hack/scripts-dev/Makefile
  114. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  115. build-docker-release-master: compile-with-docker-test
  116. $(info ETCD_VERSION: $(_ETCD_VERSION))
  117. cp ./Dockerfile-release ./bin/Dockerfile-release
  118. docker build \
  119. --tag gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \
  120. --file ./bin/Dockerfile-release \
  121. ./bin
  122. rm -f ./bin/Dockerfile-release
  123. docker run \
  124. --rm \
  125. gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \
  126. /bin/sh -c "/usr/local/bin/etcd --version && ETCDCTL_API=3 /usr/local/bin/etcdctl version"
  127. push-docker-release-master:
  128. $(info ETCD_VERSION: $(_ETCD_VERSION))
  129. gcloud docker -- push gcr.io/etcd-development/etcd:$(_ETCD_VERSION)
  130. # Example:
  131. # make build-docker-test -f ./hack/scripts-dev/Makefile
  132. # make compile-with-docker-test -f ./hack/scripts-dev/Makefile
  133. # make build-docker-dns-test -f ./hack/scripts-dev/Makefile
  134. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io
  135. # make push-docker-dns-test -f ./hack/scripts-dev/Makefile
  136. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  137. # make pull-docker-dns-test -f ./hack/scripts-dev/Makefile
  138. # make docker-dns-test-certs-run -f ./hack/scripts-dev/Makefile
  139. # make docker-dns-test-certs-gateway-run -f ./hack/scripts-dev/Makefile
  140. # make docker-dns-test-certs-wildcard-run -f ./hack/scripts-dev/Makefile
  141. build-docker-dns-test:
  142. $(info GO_VERSION: $(_GO_VERSION))
  143. @cat ./hack/scripts-dev/docker-dns/Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
  144. > ./hack/scripts-dev/docker-dns/.Dockerfile
  145. docker build \
  146. --tag gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  147. --file ./hack/scripts-dev/docker-dns/.Dockerfile \
  148. ./hack/scripts-dev/docker-dns
  149. docker run \
  150. --rm \
  151. --dns 127.0.0.1 \
  152. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  153. /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig etcd.local"
  154. push-docker-dns-test:
  155. $(info GO_VERSION: $(_GO_VERSION))
  156. gcloud docker -- push gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION)
  157. pull-docker-dns-test:
  158. $(info GO_VERSION: $(_GO_VERSION))
  159. docker pull gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION)
  160. docker-dns-test-certs-run:
  161. $(info GO_VERSION: $(_GO_VERSION))
  162. docker run \
  163. --rm \
  164. --tty \
  165. --dns 127.0.0.1 \
  166. --volume=`pwd`/bin:/etcd \
  167. --volume=/tmp:/tmp \
  168. --volume=`pwd`/hack/scripts-dev/docker-dns/certs:/certs \
  169. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  170. /bin/bash -c "cd /etcd && /certs/run.sh && rm -rf m*.etcd"
  171. docker-dns-test-certs-gateway-run:
  172. $(info GO_VERSION: $(_GO_VERSION))
  173. docker run \
  174. --rm \
  175. --tty \
  176. --dns 127.0.0.1 \
  177. --volume=`pwd`/bin:/etcd \
  178. --volume=/tmp:/tmp \
  179. --volume=`pwd`/hack/scripts-dev/docker-dns/certs-gateway:/certs-gateway \
  180. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  181. /bin/bash -c "cd /etcd && /certs-gateway/run.sh && rm -rf m*.etcd"
  182. docker-dns-test-certs-wildcard-run:
  183. $(info GO_VERSION: $(_GO_VERSION))
  184. docker run \
  185. --rm \
  186. --tty \
  187. --dns 127.0.0.1 \
  188. --volume=`pwd`/bin:/etcd \
  189. --volume=/tmp:/tmp \
  190. --volume=`pwd`/hack/scripts-dev/docker-dns/certs-wildcard:/certs-wildcard \
  191. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  192. /bin/bash -c "cd /etcd && /certs-wildcard/run.sh && rm -rf m*.etcd"
  193. # Example:
  194. # make build-docker-test -f ./hack/scripts-dev/Makefile
  195. # make compile-with-docker-test -f ./hack/scripts-dev/Makefile
  196. # make build-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  197. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io
  198. # make push-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  199. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  200. # make pull-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  201. # make docker-dns-srv-test-certs-run -f ./hack/scripts-dev/Makefile
  202. # make docker-dns-srv-test-certs-wildcard-run -f ./hack/scripts-dev/Makefile
  203. build-docker-dns-srv-test:
  204. $(info GO_VERSION: $(_GO_VERSION))
  205. @cat ./hack/scripts-dev/docker-dns-srv/Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
  206. > ./hack/scripts-dev/docker-dns-srv/.Dockerfile
  207. docker build \
  208. --tag gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  209. --file ./hack/scripts-dev/docker-dns-srv/.Dockerfile \
  210. ./hack/scripts-dev/docker-dns-srv
  211. docker run \
  212. --rm \
  213. --dns 127.0.0.1 \
  214. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  215. /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"
  216. push-docker-dns-srv-test:
  217. $(info GO_VERSION: $(_GO_VERSION))
  218. gcloud docker -- push gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION)
  219. pull-docker-dns-srv-test:
  220. $(info GO_VERSION: $(_GO_VERSION))
  221. docker pull gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION)
  222. docker-dns-srv-test-certs-run:
  223. $(info GO_VERSION: $(_GO_VERSION))
  224. docker run \
  225. --rm \
  226. --tty \
  227. --dns 127.0.0.1 \
  228. --volume=`pwd`/bin:/etcd \
  229. --volume=/tmp:/tmp \
  230. --volume=`pwd`/hack/scripts-dev/docker-dns-srv/certs:/certs \
  231. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  232. /bin/bash -c "cd /etcd && /certs/run.sh && rm -rf m*.etcd"
  233. docker-dns-srv-test-certs-wildcard-run:
  234. $(info GO_VERSION: $(_GO_VERSION))
  235. docker run \
  236. --rm \
  237. --tty \
  238. --dns 127.0.0.1 \
  239. --volume=`pwd`/bin:/etcd \
  240. --volume=/tmp:/tmp \
  241. --volume=`pwd`/hack/scripts-dev/docker-dns-srv/certs-wildcard:/certs-wildcard \
  242. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  243. /bin/bash -c "cd /etcd && /certs-wildcard/run.sh && rm -rf m*.etcd"