Browse Source

Merge pull request #8749 from gyuho/docker-test

*: fix test docker images, switch travis to docker
Gyu-Ho Lee 8 years ago
parent
commit
fdaa04e95f

+ 39 - 37
.travis.yml

@@ -1,11 +1,13 @@
-dist: trusty
 language: go
 language: go
 go_import_path: github.com/coreos/etcd
 go_import_path: github.com/coreos/etcd
-sudo: false
+
+sudo: required
+
+services: docker
 
 
 go:
 go:
-  - 1.9.1
-  - tip
+- 1.9.1
+- tip
 
 
 notifications:
 notifications:
   on_success: never
   on_success: never
@@ -13,19 +15,25 @@ notifications:
 
 
 env:
 env:
   matrix:
   matrix:
-   - TARGET=amd64
-   - TARGET=darwin-amd64
-   - TARGET=windows-amd64
-   - TARGET=arm64
-   - TARGET=arm
-   - TARGET=386
-   - TARGET=ppc64le
+  - TARGET=amd64
+  - TARGET=amd64-go-tip
+  - TARGET=darwin-amd64
+  - TARGET=windows-amd64
+  - TARGET=arm64
+  - TARGET=arm
+  - TARGET=386
+  - TARGET=ppc64le
 
 
 matrix:
 matrix:
   fast_finish: true
   fast_finish: true
   allow_failures:
   allow_failures:
-    - go: tip
+  - go: tip
+    env: TARGET=amd64-go-tip
   exclude:
   exclude:
+  - go: 1.9.1
+    env: TARGET=amd64-go-tip
+  - go: tip
+    env: TARGET=amd64
   - go: tip
   - go: tip
     env: TARGET=darwin-amd64
     env: TARGET=darwin-amd64
   - go: tip
   - go: tip
@@ -39,48 +47,42 @@ matrix:
   - go: tip
   - go: tip
     env: TARGET=ppc64le
     env: TARGET=ppc64le
 
 
-addons:
-  apt:
-    sources:
-    - debian-sid
-    packages:
-    - libaspell-dev
-    - libhunspell-dev
-    - hunspell-en-us
-    - aspell-en
-    - shellcheck
-
 before_install:
 before_install:
- - go get -v -u -tags spell github.com/chzchzchz/goword
- - go get -v -u github.com/coreos/license-bill-of-materials
- - go get -v -u honnef.co/go/tools/cmd/gosimple
- - go get -v -u honnef.co/go/tools/cmd/unused
- - go get -v -u honnef.co/go/tools/cmd/staticcheck
- - go get -v -u github.com/gordonklaus/ineffassign
- - ./scripts/install-marker.sh amd64
- - export GOROOT=$(go env GOROOT)
+- docker pull gcr.io/etcd-development/etcd-test:go1.9.1
 
 
-# disable godep restore override
 install:
 install:
- - pushd cmd/etcd && go get -t -v ./... && popd
+- pushd cmd/etcd && go get -t -v ./... && popd
 
 
 script:
 script:
  - >
  - >
     case "${TARGET}" in
     case "${TARGET}" in
       amd64)
       amd64)
+        docker run --rm \
+          --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go1.9.1 \
+          /bin/bash -c "GOARCH=amd64 ./test"
+        ;;
+      amd64-go-tip)
         GOARCH=amd64 ./test
         GOARCH=amd64 ./test
         ;;
         ;;
       darwin-amd64)
       darwin-amd64)
-        GO_BUILD_FLAGS="-a -v"  GOPATH="" GOOS=darwin GOARCH=amd64 ./build
+        docker run --rm \
+          --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go1.9.1 \
+          /bin/bash -c "GO_BUILD_FLAGS='-a -v' GOOS=darwin GOARCH=amd64 ./build"
         ;;
         ;;
       windows-amd64)
       windows-amd64)
-        GO_BUILD_FLAGS="-a -v"  GOPATH="" GOOS=windows GOARCH=amd64 ./build
+        docker run --rm \
+          --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go1.9.1 \
+          /bin/bash -c "GO_BUILD_FLAGS='-a -v' GOOS=windows GOARCH=amd64 ./build"
         ;;
         ;;
       386)
       386)
-        GOARCH=386 PASSES="build unit" ./test
+        docker run --rm \
+          --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go1.9.1 \
+          /bin/bash -c "GOARCH=386 PASSES='build unit' ./test"
         ;;
         ;;
       *)
       *)
         # test building out of gopath
         # test building out of gopath
-        GO_BUILD_FLAGS="-a -v" GOPATH="" GOARCH="${TARGET}" ./build
+        docker run --rm \
+          --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go1.9.1 \
+          /bin/bash -c "GO_BUILD_FLAGS='-a -v' GOARCH='${TARGET}' ./build"
         ;;
         ;;
     esac
     esac

+ 3 - 0
.words

@@ -1,8 +1,11 @@
 ErrCodeEnhanceYourCalm
 ErrCodeEnhanceYourCalm
+ErrTimeout
 GoAway
 GoAway
 RPC
 RPC
 RPCs
 RPCs
+TODO
 backoff
 backoff
+blackhole
 blackholed
 blackholed
 cancelable
 cancelable
 cancelation
 cancelation

+ 37 - 12
Dockerfile-test

@@ -1,18 +1,48 @@
-FROM golang:1.9.1-stretch
+FROM ubuntu:16.10
 
 
-RUN apt-get -y update
-RUN apt-get -y install \
+RUN rm /bin/sh && ln -s /bin/bash /bin/sh
+RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
+
+RUN apt-get -y update \
+  && apt-get -y install \
+  build-essential \
+  gcc \
+  apt-utils \
+  pkg-config \
+  software-properties-common \
+  apt-transport-https \
+  libssl-dev \
+  sudo \
+  bash \
+  curl \
+  wget \
+  tar \
+  git \
   netcat \
   netcat \
   libaspell-dev \
   libaspell-dev \
   libhunspell-dev \
   libhunspell-dev \
   hunspell-en-us \
   hunspell-en-us \
   aspell-en \
   aspell-en \
-  shellcheck
+  shellcheck \
+  && apt-get -y update \
+  && apt-get -y upgrade \
+  && apt-get -y autoremove \
+  && apt-get -y autoclean
+
+ENV GOROOT /usr/local/go
+ENV GOPATH /go
+ENV PATH ${GOPATH}/bin:${GOROOT}/bin:${PATH}
+ENV GO_VERSION 1.9.1
+ENV GO_DOWNLOAD_URL https://storage.googleapis.com/golang
+RUN rm -rf ${GOROOT} \
+  && curl -s ${GO_DOWNLOAD_URL}/go${GO_VERSION}.linux-amd64.tar.gz | tar -v -C /usr/local/ -xz \
+  && mkdir -p ${GOPATH}/src ${GOPATH}/bin \
+  && go version
 
 
 RUN mkdir -p ${GOPATH}/src/github.com/coreos/etcd
 RUN mkdir -p ${GOPATH}/src/github.com/coreos/etcd
 WORKDIR ${GOPATH}/src/github.com/coreos/etcd
 WORKDIR ${GOPATH}/src/github.com/coreos/etcd
 
 
-ADD ./scripts/install-marker.sh ./scripts/install-marker.sh
+ADD ./scripts/install-marker.sh /tmp/install-marker.sh
 
 
 RUN go get -v -u -tags spell github.com/chzchzchz/goword \
 RUN go get -v -u -tags spell github.com/chzchzchz/goword \
   && go get -v -u github.com/coreos/license-bill-of-materials \
   && go get -v -u github.com/coreos/license-bill-of-materials \
@@ -21,12 +51,7 @@ RUN go get -v -u -tags spell github.com/chzchzchz/goword \
   && go get -v -u honnef.co/go/tools/cmd/staticcheck \
   && go get -v -u honnef.co/go/tools/cmd/staticcheck \
   && go get -v -u github.com/wadey/gocovmerge \
   && go get -v -u github.com/wadey/gocovmerge \
   && go get -v -u github.com/gordonklaus/ineffassign \
   && go get -v -u github.com/gordonklaus/ineffassign \
-  && ./scripts/install-marker.sh amd64 \
+  && /tmp/install-marker.sh amd64 \
+  && rm -f /tmp/install-marker.sh \
   && curl -s https://codecov.io/bash >/codecov \
   && curl -s https://codecov.io/bash >/codecov \
   && chmod 700 /codecov
   && chmod 700 /codecov
-
-# e.g.
-# docker build --tag etcd-test --file ./Dockerfile-test .
-# docker run --volume=`pwd`:/go/src/github.com/coreos/etcd etcd-test \
-#  /bin/sh -c "INTEGRATION=y PASSES='build integration_e2e' ./test"
-

+ 2 - 2
clientv3/integration/network_partition_test.go

@@ -80,8 +80,8 @@ func testNetworkPartitionBalancer(t *testing.T, op func(*clientv3.Client, contex
 		if err == nil {
 		if err == nil {
 			break
 			break
 		}
 		}
-		// todo: separate put and get test for error checking.
-		// we do not really expect errTimeout on get.
+		// TODO: separate put and get test for error checking.
+		// we do not really expect ErrTimeout on get.
 		if err != context.DeadlineExceeded && err != rpctypes.ErrTimeout {
 		if err != context.DeadlineExceeded && err != rpctypes.ErrTimeout {
 			t.Errorf("#%d: expected %v or %v, got %v", i, context.DeadlineExceeded, rpctypes.ErrTimeout, err)
 			t.Errorf("#%d: expected %v or %v, got %v", i, context.DeadlineExceeded, rpctypes.ErrTimeout, err)
 		}
 		}

+ 1 - 1
clientv3/integration/watch_keepalive_test.go

@@ -46,7 +46,7 @@ func TestWatchKeepAlive(t *testing.T) {
 		DialKeepAliveTimeout: 500 * time.Millisecond,
 		DialKeepAliveTimeout: 500 * time.Millisecond,
 	}
 	}
 
 
-	// gRPC internal implmentation related.
+	// gRPC internal implementation related.
 	pingInterval := ccfg.DialKeepAliveTime + ccfg.DialKeepAliveTimeout
 	pingInterval := ccfg.DialKeepAliveTime + ccfg.DialKeepAliveTimeout
 	timeout := pingInterval + 2*time.Second // 2s for slow machine to process watch and reset connections
 	timeout := pingInterval + 2*time.Second // 2s for slow machine to process watch and reset connections