Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. # run makefile from repo root
  2. .PHONY: build
  3. build:
  4. GO_BUILD_FLAGS="-v" ./build
  5. ./bin/etcd --version
  6. ETCDCTL_API=3 ./bin/etcdctl version
  7. # run all tests
  8. test-all:
  9. RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional' ./test 2>&1 | tee test.log
  10. # clean up failed tests, logs, dependencies
  11. clean:
  12. rm -f ./*.log
  13. rm -f ./bin/Dockerfile-release
  14. rm -rf ./bin/*.etcd
  15. rm -rf ./gopath
  16. rm -rf ./release
  17. rm -f ./integration/127.0.0.1:* ./integration/localhost:*
  18. rm -f ./clientv3/integration/127.0.0.1:* ./clientv3/integration/localhost:*
  19. rm -f ./clientv3/ordering/127.0.0.1:* ./clientv3/ordering/localhost:*
  20. # keep in-sync with 'Dockerfile-test', 'e2e/docker-dns/Dockerfile',
  21. # 'e2e/docker-dns-srv/Dockerfile'
  22. _GO_VERSION = go1.9.1
  23. ifdef GO_VERSION
  24. _GO_VERSION = $(GO_VERSION)
  25. endif
  26. # build base container image for testing on Linux
  27. docker-test-build:
  28. docker build --tag gcr.io/etcd-development/etcd-test:$(_GO_VERSION) --file ./Dockerfile-test .
  29. # e.g.
  30. # gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io
  31. docker-test-push:
  32. gcloud docker -- push gcr.io/etcd-development/etcd-test:$(_GO_VERSION)
  33. docker-test-pull:
  34. docker pull gcr.io/etcd-development/etcd-test:$(_GO_VERSION)
  35. # compile etcd and etcdctl with Linux
  36. docker-test-compile:
  37. docker run \
  38. --rm \
  39. --volume=`pwd`/:/etcd \
  40. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  41. /bin/bash -c "cd /etcd && GO_BUILD_FLAGS=-v ./build && ./bin/etcd --version"
  42. # run tests inside container
  43. docker-test:
  44. docker run \
  45. --rm \
  46. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  47. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  48. /bin/bash -c "RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional' ./test 2>&1 | tee docker-test.log"
  49. docker-test-386:
  50. docker run \
  51. --rm \
  52. --volume=`pwd`:/go/src/github.com/coreos/etcd \
  53. gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \
  54. /bin/bash -c "GOARCH=386 PASSES='build unit integration_e2e' ./test 2>&1 | tee docker-test.log"
  55. # build release container image with Linux
  56. _ETCD_VERSION ?= $(shell git rev-parse --short HEAD || echo "GitNotFound")
  57. ifdef ETCD_VERSION
  58. _ETCD_VERSION = $(ETCD_VERSION)
  59. endif
  60. docker-release-master-build: docker-test-compile
  61. cp ./Dockerfile-release ./bin/Dockerfile-release
  62. docker build \
  63. --tag gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \
  64. --file ./bin/Dockerfile-release \
  65. ./bin
  66. rm -f ./bin/Dockerfile-release
  67. docker run \
  68. --rm \
  69. gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \
  70. /bin/sh -c "/usr/local/bin/etcd --version && ETCDCTL_API=3 /usr/local/bin/etcdctl version"
  71. docker-release-master-push:
  72. gcloud docker -- push gcr.io/etcd-development/etcd:$(_ETCD_VERSION)
  73. # build base container image for DNS testing
  74. docker-dns-test-build:
  75. docker build \
  76. --tag gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) \
  77. --file ./e2e/docker-dns/Dockerfile \
  78. ./e2e/docker-dns
  79. docker run \
  80. --rm \
  81. --dns 127.0.0.1 \
  82. gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) \
  83. /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig etcd.local"
  84. docker-dns-test-push:
  85. gcloud docker -- push gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION)
  86. docker-dns-test-pull:
  87. docker pull gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION)
  88. # run DNS tests inside container
  89. docker-dns-test-run:
  90. docker run \
  91. --rm \
  92. --tty \
  93. --dns 127.0.0.1 \
  94. --volume=`pwd`/bin:/etcd \
  95. --volume=`pwd`/integration/fixtures:/certs \
  96. gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) \
  97. /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd"
  98. # build base container image for DNS/SRV testing
  99. docker-dns-srv-test-build:
  100. docker build \
  101. --tag gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) \
  102. --file ./e2e/docker-dns-srv/Dockerfile \
  103. ./e2e/docker-dns-srv
  104. docker run \
  105. --rm \
  106. --dns 127.0.0.1 \
  107. gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) \
  108. /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig +noall +answer SRV _etcd-client._tcp.etcd-srv.local && dig +noall +answer SRV _etcd-client-ssl._tcp.etcd-srv.local && dig +noall +answer SRV _etcd-server._tcp.etcd-srv.local && dig +noall +answer SRV _etcd-server-ssl._tcp.etcd-srv.local && dig +noall +answer m1.etcd-srv.local m2.etcd-srv.local m3.etcd-srv.local"
  109. docker-dns-srv-test-push:
  110. gcloud docker -- push gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION)
  111. docker-dns-srv-test-pull:
  112. docker pull gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION)
  113. # run DNS/SRV tests inside container
  114. docker-dns-srv-test-run:
  115. docker run \
  116. --rm \
  117. --tty \
  118. --dns 127.0.0.1 \
  119. --volume=`pwd`/bin:/etcd \
  120. gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) \
  121. /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd"
  122. # TODO: run DNS/SRV with TLS
  123. # TODO: add DNS integration tests