Makefile 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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-wildcard-run -f ./hack/scripts-dev/Makefile
  140. build-docker-dns-test:
  141. $(info GO_VERSION: $(_GO_VERSION))
  142. @cat ./hack/scripts-dev/docker-dns/Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
  143. > ./hack/scripts-dev/docker-dns/.Dockerfile
  144. docker build \
  145. --tag gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  146. --file ./hack/scripts-dev/docker-dns/.Dockerfile \
  147. ./hack/scripts-dev/docker-dns
  148. docker run \
  149. --rm \
  150. --dns 127.0.0.1 \
  151. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  152. /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig etcd.local"
  153. push-docker-dns-test:
  154. $(info GO_VERSION: $(_GO_VERSION))
  155. gcloud docker -- push gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION)
  156. pull-docker-dns-test:
  157. $(info GO_VERSION: $(_GO_VERSION))
  158. docker pull gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION)
  159. docker-dns-test-certs-run:
  160. $(info GO_VERSION: $(_GO_VERSION))
  161. docker run \
  162. --rm \
  163. --tty \
  164. --dns 127.0.0.1 \
  165. --volume=`pwd`/bin:/etcd \
  166. --volume=/tmp:/tmp \
  167. --volume=`pwd`/hack/scripts-dev/docker-dns/certs:/certs \
  168. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  169. /bin/bash -c "cd /etcd && /certs/run.sh && rm -rf m*.etcd"
  170. docker-dns-test-certs-wildcard-run:
  171. $(info GO_VERSION: $(_GO_VERSION))
  172. docker run \
  173. --rm \
  174. --tty \
  175. --dns 127.0.0.1 \
  176. --volume=`pwd`/bin:/etcd \
  177. --volume=/tmp:/tmp \
  178. --volume=`pwd`/hack/scripts-dev/docker-dns/certs-wildcard:/certs-wildcard \
  179. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  180. /bin/bash -c "cd /etcd && /certs-wildcard/run.sh && rm -rf m*.etcd"
  181. # Example:
  182. # make build-docker-test -f ./hack/scripts-dev/Makefile
  183. # make compile-with-docker-test -f ./hack/scripts-dev/Makefile
  184. # make build-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  185. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io
  186. # make push-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  187. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  188. # make pull-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  189. # make docker-dns-srv-test-run -f ./hack/scripts-dev/Makefile
  190. # build base container image for DNS/SRV testing
  191. build-docker-dns-srv-test:
  192. $(info GO_VERSION: $(_GO_VERSION))
  193. @cat ./hack/scripts-dev/docker-dns-srv/Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
  194. > ./hack/scripts-dev/docker-dns-srv/.Dockerfile
  195. docker build \
  196. --tag gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  197. --file ./hack/scripts-dev/docker-dns-srv/.Dockerfile \
  198. ./hack/scripts-dev/docker-dns-srv
  199. docker run \
  200. --rm \
  201. --dns 127.0.0.1 \
  202. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  203. /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"
  204. push-docker-dns-srv-test:
  205. $(info GO_VERSION: $(_GO_VERSION))
  206. gcloud docker -- push gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION)
  207. pull-docker-dns-srv-test:
  208. $(info GO_VERSION: $(_GO_VERSION))
  209. docker pull gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION)
  210. # run DNS/SRV tests inside container
  211. docker-dns-srv-test-run:
  212. $(info GO_VERSION: $(_GO_VERSION))
  213. docker run \
  214. --rm \
  215. --tty \
  216. --dns 127.0.0.1 \
  217. --volume=`pwd`/bin:/etcd \
  218. --volume=`pwd`/integration/fixtures:/certs \
  219. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  220. /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd"
  221. # TODO: add DNS integration tests