Makefile 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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 ./covdir
  14. rm -f ./*.log
  15. rm -f ./bin/Dockerfile-release
  16. rm -rf ./bin/*.etcd
  17. rm -rf ./gopath
  18. rm -rf ./release
  19. rm -f ./integration/127.0.0.1:* ./integration/localhost:*
  20. rm -f ./clientv3/integration/127.0.0.1:* ./clientv3/integration/localhost:*
  21. rm -f ./clientv3/ordering/127.0.0.1:* ./clientv3/ordering/localhost:*
  22. _GO_VERSION = 1.9.2
  23. ifdef GO_VERSION
  24. _GO_VERSION = $(GO_VERSION)
  25. endif
  26. # Example:
  27. # GO_VERSION=1.8.5 make build-docker-test -f ./hack/scripts-dev/Makefile
  28. # make build-docker-test -f ./hack/scripts-dev/Makefile
  29. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io
  30. # GO_VERSION=1.8.5 make push-docker-test -f ./hack/scripts-dev/Makefile
  31. # make push-docker-test -f ./hack/scripts-dev/Makefile
  32. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  33. # GO_VERSION=1.8.5 make pull-docker-test -f ./hack/scripts-dev/Makefile
  34. # make pull-docker-test -f ./hack/scripts-dev/Makefile
  35. build-docker-test:
  36. $(info GO_VERSION: $(_GO_VERSION))
  37. @cat ./Dockerfile-test | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
  38. > ./.Dockerfile-test
  39. docker build \
  40. --tag gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \
  41. --file ./.Dockerfile-test .
  42. push-docker-test:
  43. $(info GO_VERSION: $(_GO_VERSION))
  44. gcloud docker -- push gcr.io/etcd-development/etcd-test:go$(_GO_VERSION)
  45. pull-docker-test:
  46. $(info GO_VERSION: $(_GO_VERSION))
  47. docker pull gcr.io/etcd-development/etcd-test:go$(_GO_VERSION)
  48. compile-with-docker-test:
  49. $(info GO_VERSION: $(_GO_VERSION))
  50. docker run \
  51. --rm \
  52. --volume=`pwd`/:/etcd \
  53. gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \
  54. /bin/bash -c "cd /etcd && GO_BUILD_FLAGS=-v ./build && ./bin/etcd --version"
  55. # Local machine:
  56. # TEST_OPTS="PASSES='fmt'" make test -f ./hack/scripts-dev/Makefile
  57. # TEST_OPTS="PASSES='fmt bom dep compile build unit'" make test -f ./hack/scripts-dev/Makefile
  58. # TEST_OPTS="RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional'" make test -f ./hack/scripts-dev/Makefile
  59. # TEST_OPTS="PASSES='build grpcproxy'" make test -f ./hack/scripts-dev/Makefile
  60. #
  61. # Example (test with docker):
  62. # make pull-docker-test -f ./hack/scripts-dev/Makefile
  63. # TEST_OPTS="PASSES='fmt'" make docker-test -f ./hack/scripts-dev/Makefile
  64. # TEST_OPTS="VERBOSE=2 PASSES='unit'" make docker-test -f ./hack/scripts-dev/Makefile
  65. #
  66. # Travis CI (test with docker):
  67. # TEST_OPTS="PASSES='fmt bom dep compile build unit'" make docker-test -f ./hack/scripts-dev/Makefile
  68. #
  69. # Semaphore CI (test with docker):
  70. # TEST_OPTS="RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional'" make docker-test -f ./hack/scripts-dev/Makefile
  71. # TEST_OPTS="GOARCH=386 PASSES='build unit integration_e2e'" make docker-test -f ./hack/scripts-dev/Makefile
  72. #
  73. # grpc-proxy tests (test with docker):
  74. # TEST_OPTS="PASSES='build grpcproxy'" make docker-test -f ./hack/scripts-dev/Makefile
  75. TEST_SUFFIX = $(shell date +%s | base64 | head -c 15)
  76. _TEST_OPTS = "PASSES='unit'"
  77. ifdef TEST_OPTS
  78. _TEST_OPTS = $(TEST_OPTS)
  79. endif
  80. .PHONY: test
  81. test:
  82. $(info TEST_OPTS: $(_TEST_OPTS))
  83. $(info log-file: test-$(TEST_SUFFIX).log)
  84. $(_TEST_OPTS) ./test 2>&1 | tee test-$(TEST_SUFFIX).log
  85. ! egrep "(--- FAIL:|leak|panic: test timed out)" -A10 -B50 test-$(TEST_SUFFIX).log
  86. docker-test:
  87. $(info GO_VERSION: $(_GO_VERSION))
  88. $(info TEST_OPTS: $(_TEST_OPTS))
  89. $(info log-file: test-$(TEST_SUFFIX).log)
  90. docker run \
  91. --rm \
  92. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  93. gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \
  94. /bin/bash -c "$(_TEST_OPTS) ./test 2>&1 | tee test-$(TEST_SUFFIX).log"
  95. ! egrep "(--- FAIL:|leak|panic: test timed out)" -A10 -B50 test-$(TEST_SUFFIX).log
  96. docker-test-coverage:
  97. $(info GO_VERSION: $(_GO_VERSION))
  98. $(info log-file: docker-test-coverage-$(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$(_GO_VERSION) \
  103. /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"
  104. ! egrep "(--- FAIL:|leak|panic: test timed out)" -A10 -B50 docker-test-coverage-$(TEST_SUFFIX).log
  105. # build release container image with Linux
  106. _ETCD_VERSION ?= $(shell git rev-parse --short HEAD || echo "GitNotFound")
  107. ifdef ETCD_VERSION
  108. _ETCD_VERSION = $(ETCD_VERSION)
  109. endif
  110. # Example:
  111. # ETCD_VERSION=v3.3.0-test.0 make build-docker-release-master -f ./hack/scripts-dev/Makefile
  112. # ETCD_VERSION=v3.3.0-test.0 make push-docker-release-master -f ./hack/scripts-dev/Makefile
  113. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  114. build-docker-release-master: compile-with-docker-test
  115. $(info ETCD_VERSION: $(_ETCD_VERSION))
  116. cp ./Dockerfile-release ./bin/Dockerfile-release
  117. docker build \
  118. --tag gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \
  119. --file ./bin/Dockerfile-release \
  120. ./bin
  121. rm -f ./bin/Dockerfile-release
  122. docker run \
  123. --rm \
  124. gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \
  125. /bin/sh -c "/usr/local/bin/etcd --version && ETCDCTL_API=3 /usr/local/bin/etcdctl version"
  126. push-docker-release-master:
  127. $(info ETCD_VERSION: $(_ETCD_VERSION))
  128. gcloud docker -- push gcr.io/etcd-development/etcd:$(_ETCD_VERSION)
  129. # Example:
  130. # make build-docker-test -f ./hack/scripts-dev/Makefile
  131. # make compile-with-docker-test -f ./hack/scripts-dev/Makefile
  132. # make build-docker-dns-test -f ./hack/scripts-dev/Makefile
  133. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io
  134. # make push-docker-dns-test -f ./hack/scripts-dev/Makefile
  135. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  136. # make pull-docker-dns-test -f ./hack/scripts-dev/Makefile
  137. # make docker-dns-test-run -f ./hack/scripts-dev/Makefile
  138. # build base container image for DNS testing
  139. build-docker-dns-test:
  140. $(info GO_VERSION: $(_GO_VERSION))
  141. @cat ./hack/scripts-dev/docker-dns/Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
  142. > ./hack/scripts-dev/docker-dns/.Dockerfile
  143. docker build \
  144. --tag gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  145. --file ./hack/scripts-dev/docker-dns/.Dockerfile \
  146. ./hack/scripts-dev/docker-dns
  147. docker run \
  148. --rm \
  149. --dns 127.0.0.1 \
  150. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  151. /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig etcd.local"
  152. push-docker-dns-test:
  153. $(info GO_VERSION: $(_GO_VERSION))
  154. gcloud docker -- push gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION)
  155. pull-docker-dns-test:
  156. $(info GO_VERSION: $(_GO_VERSION))
  157. docker pull gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION)
  158. # run DNS tests inside container
  159. docker-dns-test-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=`pwd`/integration/fixtures:/certs \
  167. gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \
  168. /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd"
  169. # Example:
  170. # make build-docker-test -f ./hack/scripts-dev/Makefile
  171. # make compile-with-docker-test -f ./hack/scripts-dev/Makefile
  172. # make build-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  173. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io
  174. # make push-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  175. # gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  176. # make pull-docker-dns-srv-test -f ./hack/scripts-dev/Makefile
  177. # make docker-dns-srv-test-run -f ./hack/scripts-dev/Makefile
  178. # build base container image for DNS/SRV testing
  179. build-docker-dns-srv-test:
  180. $(info GO_VERSION: $(_GO_VERSION))
  181. @cat ./hack/scripts-dev/docker-dns-srv/Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \
  182. > ./hack/scripts-dev/docker-dns-srv/.Dockerfile
  183. docker build \
  184. --tag gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  185. --file ./hack/scripts-dev/docker-dns-srv/.Dockerfile \
  186. ./hack/scripts-dev/docker-dns-srv
  187. docker run \
  188. --rm \
  189. --dns 127.0.0.1 \
  190. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  191. /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"
  192. push-docker-dns-srv-test:
  193. $(info GO_VERSION: $(_GO_VERSION))
  194. gcloud docker -- push gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION)
  195. pull-docker-dns-srv-test:
  196. $(info GO_VERSION: $(_GO_VERSION))
  197. docker pull gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION)
  198. # run DNS/SRV tests inside container
  199. docker-dns-srv-test-run:
  200. $(info GO_VERSION: $(_GO_VERSION))
  201. docker run \
  202. --rm \
  203. --tty \
  204. --dns 127.0.0.1 \
  205. --volume=`pwd`/bin:/etcd \
  206. --volume=`pwd`/integration/fixtures:/certs \
  207. gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \
  208. /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd"
  209. # TODO: add DNS integration tests