Makefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. # Example:
  50. # make build-docker-test -f ./hack/scripts-dev/Makefile
  51. # make compile-with-docker-test -f ./hack/scripts-dev/Makefile
  52. compile-with-docker-test:
  53. $(info GO_VERSION: $(_GO_VERSION))
  54. docker run \
  55. --rm \
  56. --mount type=bind,source=`pwd`,destination=/etcd \
  57. gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \
  58. /bin/bash -c "cd /etcd && GO_BUILD_FLAGS=-v ./build && ./bin/etcd --version"
  59. # Local machine:
  60. # TEST_OPTS="PASSES='fmt'" make test -f ./hack/scripts-dev/Makefile
  61. # TEST_OPTS="PASSES='fmt bom dep compile build unit'" make test -f ./hack/scripts-dev/Makefile
  62. # TEST_OPTS="RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional'" make test -f ./hack/scripts-dev/Makefile
  63. # TEST_OPTS="PASSES='build grpcproxy'" make test -f ./hack/scripts-dev/Makefile
  64. #
  65. # Example (test with docker):
  66. # make pull-docker-test -f ./hack/scripts-dev/Makefile
  67. # TEST_OPTS="PASSES='fmt'" make docker-test -f ./hack/scripts-dev/Makefile
  68. # TEST_OPTS="VERBOSE=2 PASSES='unit'" make docker-test -f ./hack/scripts-dev/Makefile
  69. #
  70. # Travis CI (test with docker):
  71. # TEST_OPTS="PASSES='fmt bom dep compile build unit'" make docker-test -f ./hack/scripts-dev/Makefile
  72. #
  73. # Semaphore CI (test with docker):
  74. # TEST_OPTS="RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional'" make docker-test -f ./hack/scripts-dev/Makefile
  75. # HOST_TMP_DI=/tmp TEST_OPTS="RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional'" make docker-test -f ./hack/scripts-dev/Makefile
  76. # TEST_OPTS="GOARCH=386 PASSES='build unit integration_e2e'" make docker-test -f ./hack/scripts-dev/Makefile
  77. #
  78. # grpc-proxy tests (test with docker):
  79. # TEST_OPTS="PASSES='build grpcproxy'" make docker-test -f ./hack/scripts-dev/Makefile
  80. # HOST_TMP_DI=/tmp TEST_OPTS="PASSES='build grpcproxy'" make docker-test -f ./hack/scripts-dev/Makefile
  81. TEST_SUFFIX = $(shell date +%s | base64 | head -c 15)
  82. _TEST_OPTS = PASSES='unit'
  83. ifdef TEST_OPTS
  84. _TEST_OPTS = $(TEST_OPTS)
  85. endif
  86. _TMP_DIR_MOUNT_FLAG = --mount type=tmpfs,destination=/tmp
  87. ifdef HOST_TMP_DIR
  88. _TMP_DIR_MOUNT_FLAG = --mount type=bind,source=$(HOST_TMP_DIR),destination=/tmp
  89. endif
  90. .PHONY: test
  91. test:
  92. $(info TEST_OPTS: $(_TEST_OPTS))
  93. $(info log-file: test-$(TEST_SUFFIX).log)
  94. $(_TEST_OPTS) ./test 2>&1 | tee test-$(TEST_SUFFIX).log
  95. ! egrep "(--- FAIL:|panic: test timed out|appears to have leaked)" -B50 -A10 test-$(TEST_SUFFIX).log
  96. docker-test:
  97. $(info GO_VERSION: $(_GO_VERSION))
  98. $(info TEST_OPTS: $(_TEST_OPTS))
  99. $(info log-file: test-$(TEST_SUFFIX).log)
  100. $(info HOST_TMP_DIR: $(HOST_TMP_DIR))
  101. $(info TMP_DIR_MOUNT_FLAG: $(_TMP_DIR_MOUNT_FLAG))
  102. docker run \
  103. --rm \
  104. $(_TMP_DIR_MOUNT_FLAG) \
  105. --mount type=bind,source=`pwd`,destination=/go/src/github.com/coreos/etcd \
  106. gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \
  107. /bin/bash -c "$(_TEST_OPTS) ./test 2>&1 | tee test-$(TEST_SUFFIX).log"
  108. ! egrep "(--- FAIL:|panic: test timed out|appears to have leaked)" -B50 -A10 test-$(TEST_SUFFIX).log
  109. docker-test-coverage:
  110. $(info GO_VERSION: $(_GO_VERSION))
  111. $(info log-file: docker-test-coverage-$(TEST_SUFFIX).log)
  112. $(info HOST_TMP_DIR: $(HOST_TMP_DIR))
  113. $(info TMP_DIR_MOUNT_FLAG: $(_TMP_DIR_MOUNT_FLAG))
  114. docker run \
  115. --rm \
  116. $(_TMP_DIR_MOUNT_FLAG) \
  117. --mount type=bind,source=`pwd`,destination=/go/src/github.com/coreos/etcd \
  118. gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \
  119. /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"
  120. ! egrep "(--- FAIL:|panic: test timed out|appears to have leaked)" -B50 -A10 docker-test-coverage-$(TEST_SUFFIX).log
  121. # build release container image with Linux
  122. _ETCD_VERSION ?= $(shell git rev-parse --short HEAD || echo "GitNotFound")
  123. ifdef ETCD_VERSION
  124. _ETCD_VERSION = $(ETCD_VERSION)
  125. endif
  126. # Example:
  127. # ETCD_VERSION=v3.3.0-test.0 make build-docker-release-master -f ./hack/scripts-dev/Makefile
  128. # ETCD_VERSION=v3.3.0-test.0 make push-docker-release-master -f ./hack/scripts-dev/Makefile
  129. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  130. build-docker-release-master: compile-with-docker-test
  131. $(info ETCD_VERSION: $(_ETCD_VERSION))
  132. cp ./Dockerfile-release ./bin/Dockerfile-release
  133. docker build \
  134. --tag gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \
  135. --file ./bin/Dockerfile-release \
  136. ./bin
  137. rm -f ./bin/Dockerfile-release
  138. docker run \
  139. --rm \
  140. gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \
  141. /bin/sh -c "/usr/local/bin/etcd --version && ETCDCTL_API=3 /usr/local/bin/etcdctl version"
  142. push-docker-release-master:
  143. $(info ETCD_VERSION: $(_ETCD_VERSION))
  144. gcloud docker -- push gcr.io/etcd-development/etcd:$(_ETCD_VERSION)
  145. # Example:
  146. # make build-docker-test -f ./hack/scripts-dev/Makefile
  147. # make compile-with-docker-test -f ./hack/scripts-dev/Makefile
  148. # make build-docker-dns-test -f ./hack/scripts-dev/Makefile
  149. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd-development.json)" https://gcr.io
  150. # make push-docker-dns-test -f ./hack/scripts-dev/Makefile
  151. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  152. # make pull-docker-dns-test -f ./hack/scripts-dev/Makefile
  153. # make docker-dns-test-certs-run -f ./hack/scripts-dev/Makefile
  154. # make docker-dns-test-certs-gateway-run -f ./hack/scripts-dev/Makefile
  155. # make docker-dns-test-certs-wildcard-run -f ./hack/scripts-dev/Makefile
  156. build-docker-dns-test:
  157. $(info GO_VERSION: $(_GO_VERSION))
  158. @cat ./hack/scripts-dev/docker-dns/Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
  159. > ./hack/scripts-dev/docker-dns/.Dockerfile
  160. docker build \
  161. --tag gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  162. --file ./hack/scripts-dev/docker-dns/.Dockerfile \
  163. ./hack/scripts-dev/docker-dns
  164. docker run \
  165. --rm \
  166. --dns 127.0.0.1 \
  167. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  168. /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig etcd.local"
  169. push-docker-dns-test:
  170. $(info GO_VERSION: $(_GO_VERSION))
  171. gcloud docker -- push gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION)
  172. pull-docker-dns-test:
  173. $(info GO_VERSION: $(_GO_VERSION))
  174. docker pull gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION)
  175. docker-dns-test-certs-run:
  176. $(info GO_VERSION: $(_GO_VERSION))
  177. $(info HOST_TMP_DIR: $(HOST_TMP_DIR))
  178. $(info TMP_DIR_MOUNT_FLAG: $(_TMP_DIR_MOUNT_FLAG))
  179. docker run \
  180. --rm \
  181. --tty \
  182. --dns 127.0.0.1 \
  183. $(_TMP_DIR_MOUNT_FLAG) \
  184. --mount type=bind,source=`pwd`/bin,destination=/etcd \
  185. --mount type=bind,source=`pwd`/hack/scripts-dev/docker-dns/certs,destination=/certs \
  186. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  187. /bin/bash -c "cd /etcd && /certs/run.sh && rm -rf m*.etcd"
  188. docker-dns-test-certs-gateway-run:
  189. $(info GO_VERSION: $(_GO_VERSION))
  190. $(info HOST_TMP_DIR: $(HOST_TMP_DIR))
  191. $(info TMP_DIR_MOUNT_FLAG: $(_TMP_DIR_MOUNT_FLAG))
  192. docker run \
  193. --rm \
  194. --tty \
  195. --dns 127.0.0.1 \
  196. $(_TMP_DIR_MOUNT_FLAG) \
  197. --mount type=bind,source=`pwd`/bin,destination=/etcd \
  198. --mount type=bind,source=`pwd`/hack/scripts-dev/docker-dns/certs-gateway,destination=/certs-gateway \
  199. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  200. /bin/bash -c "cd /etcd && /certs-gateway/run.sh && rm -rf m*.etcd"
  201. docker-dns-test-certs-wildcard-run:
  202. $(info GO_VERSION: $(_GO_VERSION))
  203. $(info HOST_TMP_DIR: $(HOST_TMP_DIR))
  204. $(info TMP_DIR_MOUNT_FLAG: $(_TMP_DIR_MOUNT_FLAG))
  205. docker run \
  206. --rm \
  207. --tty \
  208. --dns 127.0.0.1 \
  209. $(_TMP_DIR_MOUNT_FLAG) \
  210. --mount type=bind,source=`pwd`/bin,destination=/etcd \
  211. --mount type=bind,source=`pwd`/hack/scripts-dev/docker-dns/certs-wildcard,destination=/certs-wildcard \
  212. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  213. /bin/bash -c "cd /etcd && /certs-wildcard/run.sh && rm -rf m*.etcd"
  214. # Example:
  215. # make build-docker-test -f ./hack/scripts-dev/Makefile
  216. # make compile-with-docker-test -f ./hack/scripts-dev/Makefile
  217. # make build-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  218. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd-development.json)" https://gcr.io
  219. # make push-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  220. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  221. # make pull-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  222. # make docker-dns-srv-test-certs-run -f ./hack/scripts-dev/Makefile
  223. # make docker-dns-srv-test-certs-gateway-run -f ./hack/scripts-dev/Makefile
  224. # make docker-dns-srv-test-certs-wildcard-run -f ./hack/scripts-dev/Makefile
  225. build-docker-dns-srv-test:
  226. $(info GO_VERSION: $(_GO_VERSION))
  227. @cat ./hack/scripts-dev/docker-dns-srv/Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
  228. > ./hack/scripts-dev/docker-dns-srv/.Dockerfile
  229. docker build \
  230. --tag gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  231. --file ./hack/scripts-dev/docker-dns-srv/.Dockerfile \
  232. ./hack/scripts-dev/docker-dns-srv
  233. docker run \
  234. --rm \
  235. --dns 127.0.0.1 \
  236. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  237. /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"
  238. push-docker-dns-srv-test:
  239. $(info GO_VERSION: $(_GO_VERSION))
  240. gcloud docker -- push gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION)
  241. pull-docker-dns-srv-test:
  242. $(info GO_VERSION: $(_GO_VERSION))
  243. docker pull gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION)
  244. docker-dns-srv-test-certs-run:
  245. $(info GO_VERSION: $(_GO_VERSION))
  246. $(info HOST_TMP_DIR: $(HOST_TMP_DIR))
  247. $(info TMP_DIR_MOUNT_FLAG: $(_TMP_DIR_MOUNT_FLAG))
  248. docker run \
  249. --rm \
  250. --tty \
  251. --dns 127.0.0.1 \
  252. $(_TMP_DIR_MOUNT_FLAG) \
  253. --mount type=bind,source=`pwd`/bin,destination=/etcd \
  254. --mount type=bind,source=`pwd`/hack/scripts-dev/docker-dns-srv/certs,destination=/certs \
  255. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  256. /bin/bash -c "cd /etcd && /certs/run.sh && rm -rf m*.etcd"
  257. docker-dns-srv-test-certs-gateway-run:
  258. $(info GO_VERSION: $(_GO_VERSION))
  259. $(info HOST_TMP_DIR: $(HOST_TMP_DIR))
  260. $(info TMP_DIR_MOUNT_FLAG: $(_TMP_DIR_MOUNT_FLAG))
  261. docker run \
  262. --rm \
  263. --tty \
  264. --dns 127.0.0.1 \
  265. $(_TMP_DIR_MOUNT_FLAG) \
  266. --mount type=bind,source=`pwd`/bin,destination=/etcd \
  267. --mount type=bind,source=`pwd`/hack/scripts-dev/docker-dns-srv/certs-gateway,destination=/certs-gateway \
  268. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  269. /bin/bash -c "cd /etcd && /certs-gateway/run.sh && rm -rf m*.etcd"
  270. docker-dns-srv-test-certs-wildcard-run:
  271. $(info GO_VERSION: $(_GO_VERSION))
  272. $(info HOST_TMP_DIR: $(HOST_TMP_DIR))
  273. $(info TMP_DIR_MOUNT_FLAG: $(_TMP_DIR_MOUNT_FLAG))
  274. docker run \
  275. --rm \
  276. --tty \
  277. --dns 127.0.0.1 \
  278. $(_TMP_DIR_MOUNT_FLAG) \
  279. --mount type=bind,source=`pwd`/bin,destination=/etcd \
  280. --mount type=bind,source=`pwd`/hack/scripts-dev/docker-dns-srv/certs-wildcard,destination=/certs-wildcard \
  281. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  282. /bin/bash -c "cd /etcd && /certs-wildcard/run.sh && rm -rf m*.etcd"