Makefile 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. # run from repository root
  2. TEST_SUFFIX = $(shell date +%s | base64 | head -c 15)
  3. .PHONY: build
  4. build:
  5. GO_BUILD_FLAGS="-v" ./build
  6. ./bin/etcd --version
  7. ETCDCTL_API=3 ./bin/etcdctl version
  8. test:
  9. $(info log-file: test-$(TEST_SUFFIX).log)
  10. PASSES='fmt bom dep compile build unit' ./test 2>&1 | tee test-$(TEST_SUFFIX).log
  11. ! grep FAIL -A10 -B50 test-$(TEST_SUFFIX).log
  12. test-all:
  13. $(info log-file: test-all-$(TEST_SUFFIX).log)
  14. RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional' ./test 2>&1 | tee test-all-$(TEST_SUFFIX).log
  15. ! grep FAIL -A10 -B50 test-all-$(TEST_SUFFIX).log
  16. test-proxy:
  17. $(info log-file: test-proxy-$(TEST_SUFFIX).log)
  18. PASSES='build grpcproxy' ./test 2>&1 | tee test-proxy-$(TEST_SUFFIX).log
  19. ! grep FAIL -A10 -B50 test-proxy-$(TEST_SUFFIX).log
  20. test-coverage:
  21. $(info log-file: test-coverage-$(TEST_SUFFIX).log)
  22. COVERDIR=covdir PASSES='build build_cov cov' ./test 2>&1 | tee test-coverage-$(TEST_SUFFIX).log
  23. $(shell curl -s https://codecov.io/bash >codecov)
  24. chmod 700 ./codecov
  25. ./codecov -h
  26. ./codecov -t 6040de41-c073-4d6f-bbf8-d89256ef31e1
  27. # clean up failed tests, logs, dependencies
  28. clean:
  29. rm -f ./codecov
  30. rm -f ./*.log
  31. rm -f ./bin/Dockerfile-release
  32. rm -rf ./bin/*.etcd
  33. rm -rf ./gopath
  34. rm -rf ./release
  35. rm -f ./integration/127.0.0.1:* ./integration/localhost:*
  36. rm -f ./clientv3/integration/127.0.0.1:* ./clientv3/integration/localhost:*
  37. rm -f ./clientv3/ordering/127.0.0.1:* ./clientv3/ordering/localhost:*
  38. # sync with Dockerfile-test, e2e/docker-dns/Dockerfile, e2e/docker-dns-srv/Dockerfile
  39. _GO_VERSION = go1.9.1
  40. ifdef GO_VERSION
  41. _GO_VERSION = $(GO_VERSION)
  42. endif
  43. # build base container image for testing on Linux
  44. docker-test-build:
  45. docker build --tag gcr.io/etcd-development/etcd-test:$(_GO_VERSION) --file ./Dockerfile-test .
  46. # e.g.
  47. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io
  48. docker-test-push:
  49. gcloud docker -- push gcr.io/etcd-development/etcd-test:$(_GO_VERSION)
  50. docker-test-pull:
  51. docker pull gcr.io/etcd-development/etcd-test:$(_GO_VERSION)
  52. # compile etcd and etcdctl with Linux
  53. docker-test-compile:
  54. docker run \
  55. --rm \
  56. --volume=`pwd`/:/etcd \
  57. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  58. /bin/bash -c "cd /etcd && GO_BUILD_FLAGS=-v ./build && ./bin/etcd --version"
  59. # run tests inside container
  60. docker-test:
  61. $(info log-file: docker-test-$(TEST_SUFFIX).log)
  62. docker run \
  63. --rm \
  64. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  65. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  66. /bin/bash -c "RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional' ./test 2>&1 | tee docker-test-$(TEST_SUFFIX).log"
  67. ! grep FAIL -A10 -B50 docker-test-$(TEST_SUFFIX).log
  68. docker-test-386:
  69. $(info log-file: docker-test-386-$(TEST_SUFFIX).log)
  70. docker run \
  71. --rm \
  72. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  73. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  74. /bin/bash -c "GOARCH=386 PASSES='build unit integration_e2e' ./test 2>&1 | tee docker-test-386-$(TEST_SUFFIX).log"
  75. ! grep FAIL -A10 -B50 docker-test-386-$(TEST_SUFFIX).log
  76. docker-test-proxy:
  77. $(info log-file: docker-test-proxy-$(TEST_SUFFIX).log)
  78. docker run \
  79. --rm \
  80. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  81. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  82. /bin/bash -c "PASSES='build grpcproxy' ./test ./test 2>&1 | tee docker-test-proxy-$(TEST_SUFFIX).log"
  83. ! grep FAIL -A10 -B50 docker-test-proxy-$(TEST_SUFFIX).log
  84. # build release container image with Linux
  85. _ETCD_VERSION ?= $(shell git rev-parse --short HEAD || echo "GitNotFound")
  86. ifdef ETCD_VERSION
  87. _ETCD_VERSION = $(ETCD_VERSION)
  88. endif
  89. docker-release-master-build: docker-test-compile
  90. cp ./Dockerfile-release ./bin/Dockerfile-release
  91. docker build \
  92. --tag gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \
  93. --file ./bin/Dockerfile-release \
  94. ./bin
  95. rm -f ./bin/Dockerfile-release
  96. docker run \
  97. --rm \
  98. gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \
  99. /bin/sh -c "/usr/local/bin/etcd --version && ETCDCTL_API=3 /usr/local/bin/etcdctl version"
  100. docker-release-master-push:
  101. gcloud docker -- push gcr.io/etcd-development/etcd:$(_ETCD_VERSION)
  102. # build base container image for DNS testing
  103. docker-dns-test-build:
  104. docker build \
  105. --tag gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) \
  106. --file ./e2e/docker-dns/Dockerfile \
  107. ./e2e/docker-dns
  108. docker run \
  109. --rm \
  110. --dns 127.0.0.1 \
  111. gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) \
  112. /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig etcd.local"
  113. docker-dns-test-push:
  114. gcloud docker -- push gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION)
  115. docker-dns-test-pull:
  116. docker pull gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION)
  117. # run DNS tests inside container
  118. docker-dns-test-run:
  119. docker run \
  120. --rm \
  121. --tty \
  122. --dns 127.0.0.1 \
  123. --volume=`pwd`/bin:/etcd \
  124. --volume=`pwd`/integration/fixtures:/certs \
  125. gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) \
  126. /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd"
  127. # build base container image for DNS/SRV testing
  128. docker-dns-srv-test-build:
  129. docker build \
  130. --tag gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) \
  131. --file ./e2e/docker-dns-srv/Dockerfile \
  132. ./e2e/docker-dns-srv
  133. docker run \
  134. --rm \
  135. --dns 127.0.0.1 \
  136. gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) \
  137. /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"
  138. docker-dns-srv-test-push:
  139. gcloud docker -- push gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION)
  140. docker-dns-srv-test-pull:
  141. docker pull gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION)
  142. # run DNS/SRV tests inside container
  143. docker-dns-srv-test-run:
  144. docker run \
  145. --rm \
  146. --tty \
  147. --dns 127.0.0.1 \
  148. --volume=`pwd`/bin:/etcd \
  149. --volume=`pwd`/integration/fixtures:/certs \
  150. gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) \
  151. /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd"
  152. # TODO: add DNS integration tests