Makefile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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-development.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)" -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=/tmp:/tmp \
  94. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  95. gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \
  96. /bin/bash -c "$(_TEST_OPTS) ./test 2>&1 | tee test-$(TEST_SUFFIX).log"
  97. ! egrep "(--- FAIL:|panic: test timed out|appears to have leaked)" -B50 -A10 test-$(TEST_SUFFIX).log
  98. docker-test-coverage:
  99. $(info GO_VERSION: $(_GO_VERSION))
  100. $(info log-file: docker-test-coverage-$(TEST_SUFFIX).log)
  101. docker run \
  102. --rm \
  103. --volume=/tmp:/tmp \
  104. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  105. gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \
  106. /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"
  107. ! egrep "(--- FAIL:|panic: test timed out|appears to have leaked)" -B50 -A10 docker-test-coverage-$(TEST_SUFFIX).log
  108. # build release container image with Linux
  109. _ETCD_VERSION ?= $(shell git rev-parse --short HEAD || echo "GitNotFound")
  110. ifdef ETCD_VERSION
  111. _ETCD_VERSION = $(ETCD_VERSION)
  112. endif
  113. # Example:
  114. # ETCD_VERSION=v3.3.0-test.0 make build-docker-release-master -f ./hack/scripts-dev/Makefile
  115. # ETCD_VERSION=v3.3.0-test.0 make push-docker-release-master -f ./hack/scripts-dev/Makefile
  116. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  117. build-docker-release-master: compile-with-docker-test
  118. $(info ETCD_VERSION: $(_ETCD_VERSION))
  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. push-docker-release-master:
  130. $(info ETCD_VERSION: $(_ETCD_VERSION))
  131. gcloud docker -- push gcr.io/etcd-development/etcd:$(_ETCD_VERSION)
  132. # Example:
  133. # make build-docker-test -f ./hack/scripts-dev/Makefile
  134. # make compile-with-docker-test -f ./hack/scripts-dev/Makefile
  135. # make build-docker-dns-test -f ./hack/scripts-dev/Makefile
  136. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd-development.json)" https://gcr.io
  137. # make push-docker-dns-test -f ./hack/scripts-dev/Makefile
  138. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  139. # make pull-docker-dns-test -f ./hack/scripts-dev/Makefile
  140. # make docker-dns-test-certs-run -f ./hack/scripts-dev/Makefile
  141. # make docker-dns-test-certs-gateway-run -f ./hack/scripts-dev/Makefile
  142. # make docker-dns-test-certs-wildcard-run -f ./hack/scripts-dev/Makefile
  143. build-docker-dns-test:
  144. $(info GO_VERSION: $(_GO_VERSION))
  145. @cat ./hack/scripts-dev/docker-dns/Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
  146. > ./hack/scripts-dev/docker-dns/.Dockerfile
  147. docker build \
  148. --tag gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  149. --file ./hack/scripts-dev/docker-dns/.Dockerfile \
  150. ./hack/scripts-dev/docker-dns
  151. docker run \
  152. --rm \
  153. --dns 127.0.0.1 \
  154. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  155. /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig etcd.local"
  156. push-docker-dns-test:
  157. $(info GO_VERSION: $(_GO_VERSION))
  158. gcloud docker -- push gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION)
  159. pull-docker-dns-test:
  160. $(info GO_VERSION: $(_GO_VERSION))
  161. docker pull gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION)
  162. docker-dns-test-certs-run:
  163. $(info GO_VERSION: $(_GO_VERSION))
  164. docker run \
  165. --rm \
  166. --tty \
  167. --dns 127.0.0.1 \
  168. --volume=/tmp:/tmp \
  169. --volume=`pwd`/bin:/etcd \
  170. --volume=`pwd`/hack/scripts-dev/docker-dns/certs:/certs \
  171. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  172. /bin/bash -c "cd /etcd && /certs/run.sh && rm -rf m*.etcd"
  173. docker-dns-test-certs-gateway-run:
  174. $(info GO_VERSION: $(_GO_VERSION))
  175. docker run \
  176. --rm \
  177. --tty \
  178. --dns 127.0.0.1 \
  179. --volume=/tmp:/tmp \
  180. --volume=`pwd`/bin:/etcd \
  181. --volume=`pwd`/hack/scripts-dev/docker-dns/certs-gateway:/certs-gateway \
  182. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  183. /bin/bash -c "cd /etcd && /certs-gateway/run.sh && rm -rf m*.etcd"
  184. docker-dns-test-certs-wildcard-run:
  185. $(info GO_VERSION: $(_GO_VERSION))
  186. docker run \
  187. --rm \
  188. --tty \
  189. --dns 127.0.0.1 \
  190. --volume=/tmp:/tmp \
  191. --volume=`pwd`/bin:/etcd \
  192. --volume=`pwd`/hack/scripts-dev/docker-dns/certs-wildcard:/certs-wildcard \
  193. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  194. /bin/bash -c "cd /etcd && /certs-wildcard/run.sh && rm -rf m*.etcd"
  195. # Example:
  196. # make build-docker-test -f ./hack/scripts-dev/Makefile
  197. # make compile-with-docker-test -f ./hack/scripts-dev/Makefile
  198. # make build-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  199. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd-development.json)" https://gcr.io
  200. # make push-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  201. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  202. # make pull-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  203. # make docker-dns-srv-test-certs-run -f ./hack/scripts-dev/Makefile
  204. # make docker-dns-srv-test-certs-gateway-run -f ./hack/scripts-dev/Makefile
  205. # make docker-dns-srv-test-certs-wildcard-run -f ./hack/scripts-dev/Makefile
  206. build-docker-dns-srv-test:
  207. $(info GO_VERSION: $(_GO_VERSION))
  208. @cat ./hack/scripts-dev/docker-dns-srv/Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
  209. > ./hack/scripts-dev/docker-dns-srv/.Dockerfile
  210. docker build \
  211. --tag gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  212. --file ./hack/scripts-dev/docker-dns-srv/.Dockerfile \
  213. ./hack/scripts-dev/docker-dns-srv
  214. docker run \
  215. --rm \
  216. --dns 127.0.0.1 \
  217. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  218. /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"
  219. push-docker-dns-srv-test:
  220. $(info GO_VERSION: $(_GO_VERSION))
  221. gcloud docker -- push gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION)
  222. pull-docker-dns-srv-test:
  223. $(info GO_VERSION: $(_GO_VERSION))
  224. docker pull gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION)
  225. docker-dns-srv-test-certs-run:
  226. $(info GO_VERSION: $(_GO_VERSION))
  227. docker run \
  228. --rm \
  229. --tty \
  230. --dns 127.0.0.1 \
  231. --volume=/tmp:/tmp \
  232. --volume=`pwd`/bin:/etcd \
  233. --volume=`pwd`/hack/scripts-dev/docker-dns-srv/certs:/certs \
  234. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  235. /bin/bash -c "cd /etcd && /certs/run.sh && rm -rf m*.etcd"
  236. docker-dns-srv-test-certs-gateway-run:
  237. $(info GO_VERSION: $(_GO_VERSION))
  238. docker run \
  239. --rm \
  240. --tty \
  241. --dns 127.0.0.1 \
  242. --volume=/tmp:/tmp \
  243. --volume=`pwd`/bin:/etcd \
  244. --volume=`pwd`/hack/scripts-dev/docker-dns-srv/certs-gateway:/certs-gateway \
  245. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  246. /bin/bash -c "cd /etcd && /certs-gateway/run.sh && rm -rf m*.etcd"
  247. docker-dns-srv-test-certs-wildcard-run:
  248. $(info GO_VERSION: $(_GO_VERSION))
  249. docker run \
  250. --rm \
  251. --tty \
  252. --dns 127.0.0.1 \
  253. --volume=/tmp:/tmp \
  254. --volume=`pwd`/bin:/etcd \
  255. --volume=`pwd`/hack/scripts-dev/docker-dns-srv/certs-wildcard:/certs-wildcard \
  256. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  257. /bin/bash -c "cd /etcd && /certs-wildcard/run.sh && rm -rf m*.etcd"