diff --git a/Dockerfile-test b/Dockerfile-test index 3762d2e6350..3995268f0a0 100644 --- a/Dockerfile-test +++ b/Dockerfile-test @@ -1,4 +1,4 @@ -FROM golang:1.9-stretch +FROM golang:1.9.1-stretch RUN apt-get -y update RUN apt-get -y install \ diff --git a/Makefile b/Makefile new file mode 100644 index 00000000000..077ce2de9f6 --- /dev/null +++ b/Makefile @@ -0,0 +1,147 @@ +# run makefile from repo root + +.PHONY: build +build: + GO_BUILD_FLAGS="-v" ./build + ./bin/etcd --version + ETCDCTL_API=3 ./bin/etcdctl version + +# run all tests +test-all: + RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional' ./test 2>&1 | tee test.log + +# clean up failed tests, logs, dependencies +clean: + rm -f ./*.log + rm -f ./bin/Dockerfile-release + rm -rf ./bin/*.etcd + rm -rf ./gopath + rm -rf ./release + rm -f ./integration/127.0.0.1:* ./integration/localhost:* + rm -f ./clientv3/integration/127.0.0.1:* ./clientv3/integration/localhost:* + rm -f ./clientv3/ordering/127.0.0.1:* ./clientv3/ordering/localhost:* + +# keep in-sync with 'Dockerfile-test', 'e2e/docker-dns/Dockerfile', +# 'e2e/docker-dns-srv/Dockerfile' +_GO_VERSION = go1.9.1 +ifdef GO_VERSION + _GO_VERSION = $(GO_VERSION) +endif + +# build base container image for testing on Linux +docker-test-build: + docker build --tag gcr.io/etcd-development/etcd-test:$(_GO_VERSION) --file ./Dockerfile-test . + +# e.g. +# gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io +docker-test-push: + gcloud docker -- push gcr.io/etcd-development/etcd-test:$(_GO_VERSION) + +docker-test-pull: + docker pull gcr.io/etcd-development/etcd-test:$(_GO_VERSION) + +# compile etcd and etcdctl with Linux +docker-test-compile: + docker run \ + --rm \ + --volume=`pwd`/:/etcd \ + gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \ + /bin/bash -c "cd /etcd && GO_BUILD_FLAGS=-v ./build && ./bin/etcd --version" + +# run tests inside container +docker-test: + docker run \ + --rm \ + --volume=`pwd`:/go/src/github.com/coreos/etcd \ + gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \ + /bin/bash -c "RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional' ./test 2>&1 | tee docker-test.log" + +docker-test-386: + docker run \ + --rm \ + --volume=`pwd`:/go/src/github.com/coreos/etcd \ + gcr.io/etcd-development/etcd-test:$(_GO_VERSION) \ + /bin/bash -c "GOARCH=386 PASSES='build unit integration_e2e' ./test 2>&1 | tee docker-test.log" + +# build release container image with Linux +_ETCD_VERSION ?= $(shell git rev-parse --short HEAD || echo "GitNotFound") +ifdef ETCD_VERSION + _ETCD_VERSION = $(ETCD_VERSION) +endif +docker-release-master-build: docker-test-compile + cp ./Dockerfile-release ./bin/Dockerfile-release + docker build \ + --tag gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \ + --file ./bin/Dockerfile-release \ + ./bin + rm -f ./bin/Dockerfile-release + + docker run \ + --rm \ + gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \ + /bin/sh -c "/usr/local/bin/etcd --version && ETCDCTL_API=3 /usr/local/bin/etcdctl version" + +docker-release-master-push: + gcloud docker -- push gcr.io/etcd-development/etcd:$(_ETCD_VERSION) + +# build base container image for DNS testing +docker-dns-test-build: + docker build \ + --tag gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) \ + --file ./e2e/docker-dns/Dockerfile \ + ./e2e/docker-dns + + docker run \ + --rm \ + --dns 127.0.0.1 \ + gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) \ + /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig etcd.local" + +docker-dns-test-push: + gcloud docker -- push gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) + +docker-dns-test-pull: + docker pull gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) + +# run DNS tests inside container +docker-dns-test-run: + docker run \ + --rm \ + --tty \ + --dns 127.0.0.1 \ + --volume=`pwd`/bin:/etcd \ + --volume=`pwd`/integration/fixtures:/certs \ + gcr.io/etcd-development/etcd-dns-test:$(_GO_VERSION) \ + /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd" + +# build base container image for DNS/SRV testing +docker-dns-srv-test-build: + docker build \ + --tag gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) \ + --file ./e2e/docker-dns-srv/Dockerfile \ + ./e2e/docker-dns-srv + + docker run \ + --rm \ + --dns 127.0.0.1 \ + gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) \ + /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" + +docker-dns-srv-test-push: + gcloud docker -- push gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) + +docker-dns-srv-test-pull: + docker pull gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) + +# run DNS/SRV tests inside container +docker-dns-srv-test-run: + docker run \ + --rm \ + --tty \ + --dns 127.0.0.1 \ + --volume=`pwd`/bin:/etcd \ + gcr.io/etcd-development/etcd-dns-srv-test:$(_GO_VERSION) \ + /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd" + +# TODO: run DNS/SRV with TLS +# TODO: add DNS integration tests diff --git a/e2e/docker-dns-srv/Dockerfile b/e2e/docker-dns-srv/Dockerfile new file mode 100644 index 00000000000..2d1f6f45334 --- /dev/null +++ b/e2e/docker-dns-srv/Dockerfile @@ -0,0 +1,18 @@ +FROM golang:1.9-stretch +LABEL Description="Image for etcd DNS SRV testing" + +RUN apt update -y \ + && apt install -y \ + bind9 \ + dnsutils + +RUN mkdir /var/bind +RUN chown bind /var/bind +ADD Procfile /Procfile +ADD run.sh /run.sh + +ADD etcd.zone named.conf /etc/bind/ +ADD resolv.conf /etc/resolv.conf + +RUN go get github.com/mattn/goreman +CMD ["/run.sh"] diff --git a/e2e/docker-dns-srv/Procfile b/e2e/docker-dns-srv/Procfile new file mode 100644 index 00000000000..c46ae7415ee --- /dev/null +++ b/e2e/docker-dns-srv/Procfile @@ -0,0 +1,5 @@ +etcd1: ./etcd --name m1 --listen-client-urls http://127.0.0.1:2379 --advertise-client-urls http://m1.etcd-srv.local:2379 --listen-peer-urls http://127.0.0.1:2380 --initial-advertise-peer-urls=http://m1.etcd-srv.local:2380 --initial-cluster-token tkn --discovery-srv=etcd-srv.local --initial-cluster-state new + +etcd2: ./etcd --name m2 --listen-client-urls http://127.0.0.1:22379 --advertise-client-urls http://m2.etcd-srv.local:22379 --listen-peer-urls http://127.0.0.1:22380 --initial-advertise-peer-urls=http://m2.etcd-srv.local:22380 --initial-cluster-token tkn --discovery-srv=etcd-srv.local --initial-cluster-state new + +etcd3: ./etcd --name m3 --listen-client-urls http://127.0.0.1:32379 --advertise-client-urls http://m3.etcd-srv.local:32379 --listen-peer-urls http://127.0.0.1:32380 --initial-advertise-peer-urls=http://m3.etcd-srv.local:32380 --initial-cluster-token tkn --discovery-srv=etcd-srv.local --initial-cluster-state new diff --git a/e2e/docker-dns-srv/etcd.zone b/e2e/docker-dns-srv/etcd.zone new file mode 100644 index 00000000000..dbf7cd0ffc3 --- /dev/null +++ b/e2e/docker-dns-srv/etcd.zone @@ -0,0 +1,22 @@ +etcd-srv.local. IN SOA bindhostname. admin.etcd-srv.local. ( +1452607488 +10800 +3600 +604800 +38400 ) +etcd-srv.local. IN NS bindhostname. +m1.etcd-srv.local. 300 IN A 127.0.0.1 +m2.etcd-srv.local. 300 IN A 127.0.0.1 +m3.etcd-srv.local. 300 IN A 127.0.0.1 +_etcd-client._tcp 300 IN SRV 0 0 2379 m1.etcd-srv.local. +_etcd-client._tcp 300 IN SRV 0 0 22379 m2.etcd-srv.local. +_etcd-client._tcp 300 IN SRV 0 0 32379 m3.etcd-srv.local. +_etcd-client-ssl._tcp 300 IN SRV 0 0 2379 m1.etcd-srv.local. +_etcd-client-ssl._tcp 300 IN SRV 0 0 22379 m2.etcd-srv.local. +_etcd-client-ssl._tcp 300 IN SRV 0 0 32379 m3.etcd-srv.local. +_etcd-server._tcp 300 IN SRV 0 0 2380 m1.etcd-srv.local. +_etcd-server._tcp 300 IN SRV 0 0 22380 m2.etcd-srv.local. +_etcd-server._tcp 300 IN SRV 0 0 32380 m3.etcd-srv.local. +_etcd-server-ssl._tcp 300 IN SRV 0 0 2380 m1.etcd-srv.local. +_etcd-server-ssl._tcp 300 IN SRV 0 0 22380 m2.etcd-srv.local. +_etcd-server-ssl._tcp 300 IN SRV 0 0 32380 m3.etcd-srv.local. diff --git a/e2e/docker-dns-srv/named.conf b/e2e/docker-dns-srv/named.conf new file mode 100644 index 00000000000..82397524950 --- /dev/null +++ b/e2e/docker-dns-srv/named.conf @@ -0,0 +1,18 @@ +options { + directory "/var/bind"; + listen-on { 127.0.0.1; }; + listen-on-v6 { none; }; + allow-transfer { + none; + }; + // If you have problems and are behind a firewall: + query-source address * port 53; + pid-file "/var/run/named/named.pid"; + allow-recursion { none; }; + recursion no; +}; + +zone "etcd-srv.local" IN { + type master; + file "/etc/bind/etcd.zone"; +}; diff --git a/e2e/docker/resolv.conf b/e2e/docker-dns-srv/resolv.conf similarity index 100% rename from e2e/docker/resolv.conf rename to e2e/docker-dns-srv/resolv.conf diff --git a/e2e/docker-dns-srv/run.sh b/e2e/docker-dns-srv/run.sh new file mode 100755 index 00000000000..251e09e60ad --- /dev/null +++ b/e2e/docker-dns-srv/run.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +/etc/init.d/bind9 start +# get rid of hosts so go lookup won't resolve 127.0.0.1 to localhost +cat /dev/null >/etc/hosts +goreman -f /Procfile start & +sleep 5s +./etcdctl --discovery-srv etcd-srv.local set foo bar +ETCDCTL_API=3 ./etcdctl --discovery-srv etcd-srv.local put foo bar diff --git a/e2e/docker/Dockerfile b/e2e/docker-dns/Dockerfile similarity index 74% rename from e2e/docker/Dockerfile rename to e2e/docker-dns/Dockerfile index 195bdd91a4f..9daf2b88881 100644 --- a/e2e/docker/Dockerfile +++ b/e2e/docker-dns/Dockerfile @@ -1,12 +1,18 @@ -FROM golang:1.9-stretch +FROM golang:1.9.1-stretch LABEL Description="Image for etcd DNS testing" -RUN apt update -y -RUN go get github.com/mattn/goreman -RUN apt install -y bind9 + +RUN apt update -y \ + && apt install -y \ + bind9 \ + dnsutils + RUN mkdir /var/bind RUN chown bind /var/bind ADD Procfile.tls /Procfile.tls ADD run.sh /run.sh + ADD named.conf etcd.zone rdns.zone /etc/bind/ ADD resolv.conf /etc/resolv.conf + +RUN go get github.com/mattn/goreman CMD ["/run.sh"] \ No newline at end of file diff --git a/e2e/docker-dns/Procfile.tls b/e2e/docker-dns/Procfile.tls new file mode 100644 index 00000000000..45e42012406 --- /dev/null +++ b/e2e/docker-dns/Procfile.tls @@ -0,0 +1,6 @@ +# Use goreman to run `go get github.com/mattn/goreman` +etcd1: ./etcd --name m1 --listen-client-urls https://127.0.0.1:2379 --advertise-client-urls https://m1.etcd.local:2379 --listen-peer-urls https://127.0.0.1:12380 --initial-advertise-peer-urls=https://m1.etcd.local:12380 --initial-cluster-token etcd-cluster-1 --initial-cluster=m1=https://m1.etcd.local:12380,m2=https://m2.etcd.local:22380,m3=https://m3.etcd.local:32380 --initial-cluster-state new --enable-pprof --peer-cert-file=/certs/server-wildcard.crt --peer-key-file=/certs/server-wildcard.key.insecure --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --trusted-ca-file=/certs/ca.crt + +etcd2: ./etcd --name m2 --listen-client-urls https://127.0.0.1:22379 --advertise-client-urls https://m2.etcd.local:22379 --listen-peer-urls https://127.0.0.1:22380 --initial-advertise-peer-urls=https://m2.etcd.local:22380 --initial-cluster-token etcd-cluster-1 --initial-cluster=m1=https://m1.etcd.local:12380,m2=https://m2.etcd.local:22380,m3=https://m3.etcd.local:32380 --initial-cluster-state new --enable-pprof --peer-cert-file=/certs/server-wildcard.crt -peer-key-file=/certs/server-wildcard.key.insecure --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --trusted-ca-file=/certs/ca.crt + +etcd3: ./etcd --name m3 --listen-client-urls https://127.0.0.1:32379 --advertise-client-urls https://m3.etcd.local:32379 --listen-peer-urls https://127.0.0.1:32380 --initial-advertise-peer-urls=https://m3.etcd.local:32380 --initial-cluster-token etcd-cluster-1 --initial-cluster=m1=https://m1.etcd.local:12380,m2=https://m2.etcd.local:22380,m3=https://m3.etcd.local:32380 --initial-cluster-state new --enable-pprof --peer-cert-file=/certs/server-wildcard.crt --peer-key-file=/certs/server-wildcard.key.insecure --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --trusted-ca-file=/certs/ca.crt diff --git a/e2e/docker/etcd.zone b/e2e/docker-dns/etcd.zone similarity index 100% rename from e2e/docker/etcd.zone rename to e2e/docker-dns/etcd.zone diff --git a/e2e/docker/named.conf b/e2e/docker-dns/named.conf similarity index 100% rename from e2e/docker/named.conf rename to e2e/docker-dns/named.conf diff --git a/e2e/docker/rdns.zone b/e2e/docker-dns/rdns.zone similarity index 100% rename from e2e/docker/rdns.zone rename to e2e/docker-dns/rdns.zone diff --git a/e2e/docker-dns/resolv.conf b/e2e/docker-dns/resolv.conf new file mode 100644 index 00000000000..bbc8559cd54 --- /dev/null +++ b/e2e/docker-dns/resolv.conf @@ -0,0 +1 @@ +nameserver 127.0.0.1 diff --git a/e2e/docker/run.sh b/e2e/docker-dns/run.sh similarity index 100% rename from e2e/docker/run.sh rename to e2e/docker-dns/run.sh diff --git a/e2e/docker/Makefile b/e2e/docker/Makefile deleted file mode 100644 index 7ec14d42cb1..00000000000 --- a/e2e/docker/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# run makefile from repo root - -docker-dns-build: - docker build -t etcd-dns e2e/docker/ - -docker-dns-test: docker-dns-build - docker run --dns 127.0.0.1 --rm -v `pwd`/bin/:/etcd -v `pwd`/integration/fixtures:/certs -w /etcd -t etcd-dns diff --git a/e2e/docker/Procfile.tls b/e2e/docker/Procfile.tls deleted file mode 100644 index d8b79020567..00000000000 --- a/e2e/docker/Procfile.tls +++ /dev/null @@ -1,6 +0,0 @@ -# Use goreman to run `go get github.com/mattn/goreman` -etcd1: ./etcd --name infra1 --listen-client-urls https://127.0.0.1:2379 --advertise-client-urls https://m1.etcd.local:2379 --listen-peer-urls https://127.0.0.1:12380 --initial-advertise-peer-urls=https://m1.etcd.local:12380 --initial-cluster-token etcd-cluster-1 --initial-cluster=infra1=https://m1.etcd.local:12380,infra2=https://m2.etcd.local:22380,infra3=https://m3.etcd.local:32380 --initial-cluster-state new --enable-pprof --peer-cert-file=/certs/server-wildcard.crt --peer-key-file=/certs/server-wildcard.key.insecure --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --trusted-ca-file=/certs/ca.crt - -etcd2: ./etcd --name infra2 --listen-client-urls https://127.0.0.1:22379 --advertise-client-urls https://m2.etcd.local:22379 --listen-peer-urls https://127.0.0.1:22380 --initial-advertise-peer-urls=https://m2.etcd.local:22380 --initial-cluster-token etcd-cluster-1 --initial-cluster=infra1=https://m1.etcd.local:12380,infra2=https://m2.etcd.local:22380,infra3=https://m3.etcd.local:32380 --initial-cluster-state new --enable-pprof --peer-cert-file=/certs/server-wildcard.crt -peer-key-file=/certs/server-wildcard.key.insecure --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --trusted-ca-file=/certs/ca.crt - -etcd3: ./etcd --name infra3 --listen-client-urls https://127.0.0.1:32379 --advertise-client-urls https://m3.etcd.local:32379 --listen-peer-urls https://127.0.0.1:32380 --initial-advertise-peer-urls=https://m3.etcd.local:32380 --initial-cluster-token etcd-cluster-1 --initial-cluster=infra1=https://m1.etcd.local:12380,infra2=https://m2.etcd.local:22380,infra3=https://m3.etcd.local:32380 --initial-cluster-state new --enable-pprof --peer-cert-file=/certs/server-wildcard.crt --peer-key-file=/certs/server-wildcard.key.insecure --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --trusted-ca-file=/certs/ca.crt