Browse Source

Merge pull request #9560 from gyuho/ttt

*: parallelize tests, remove redundant tests, Phase 1
Gyuho Lee 7 years ago
parent
commit
f46368c6e9
7 changed files with 93 additions and 74 deletions
  1. 81 32
      .travis.yml
  2. 2 2
      Makefile
  3. 0 13
      bill-of-materials.json
  4. 0 8
      bill-of-materials.override.json
  5. 1 6
      etcdserver/v2_server.go
  6. 7 11
      test
  7. 2 2
      tests/semaphore.test.bash

+ 81 - 32
.travis.yml

@@ -15,75 +15,124 @@ notifications:
 
 env:
   matrix:
-  - TARGET=amd64
-  - TARGET=amd64-go-tip
-  - TARGET=darwin-amd64
-  - TARGET=windows-amd64
-  - TARGET=arm64
-  - TARGET=arm
-  - TARGET=386
-  - TARGET=ppc64le
+  - TARGET=linux-amd64-build
+  - TARGET=linux-amd64-unit
+  - TARGET=linux-amd64-fmt
+  - TARGET=linux-amd64-integration
+  - TARGET=linux-amd64-functional
+  - TARGET=linux-386-build
+  - TARGET=linux-386-unit
+  - TARGET=darwin-amd64-build
+  - TARGET=windows-amd64-build
+  - TARGET=linux-arm-build
+  - TARGET=linux-arm64-build
+  - TARGET=linux-ppc64le-build
+  - TARGET=linux-amd64-fmt-unit-go-tip
 
 matrix:
   fast_finish: true
   allow_failures:
   - go: tip
-    env: TARGET=amd64-go-tip
+    env: TARGET=linux-amd64-fmt-unit-go-tip
   exclude:
-  - go: 1.10.1
-    env: TARGET=amd64-go-tip
   - go: tip
-    env: TARGET=amd64
+    env: TARGET=linux-amd64-build
+  - go: tip
+    env: TARGET=linux-amd64-unit
+  - go: tip
+    env: TARGET=linux-amd64-fmt
+  - go: tip
+    env: TARGET=linux-amd64-integration
   - go: tip
-    env: TARGET=darwin-amd64
+    env: TARGET=linux-amd64-functional
   - go: tip
-    env: TARGET=windows-amd64
+    env: TARGET=linux-386-build
   - go: tip
-    env: TARGET=arm
+    env: TARGET=linux-386-unit
   - go: tip
-    env: TARGET=arm64
+    env: TARGET=darwin-amd64-build
   - go: tip
-    env: TARGET=386
+    env: TARGET=windows-amd64-build
   - go: tip
-    env: TARGET=ppc64le
+    env: TARGET=linux-arm-build
+  - go: tip
+    env: TARGET=linux-arm64-build
+  - go: tip
+    env: TARGET=linux-ppc64le-build
+  - go: 1.10.1
+    env: TARGET=linux-amd64-fmt-unit-go-tip
 
 before_install:
 - if [[ $TRAVIS_GO_VERSION == 1.* ]]; then docker pull gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION}; fi
 
 install:
-- go get -t -v ./...
+- go get -t -d ./...
 
 script:
  - echo "TRAVIS_GO_VERSION=${TRAVIS_GO_VERSION}"
  - >
     case "${TARGET}" in
-      amd64)
+      linux-amd64-build)
+        docker run --rm \
+          --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \
+          /bin/bash -c "GOARCH=amd64 PASSES='build' ./test"
+        ;;
+      linux-amd64-unit)
+        docker run --rm \
+          --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \
+          /bin/bash -c "GOARCH=amd64 PASSES='unit' ./test"
+        ;;
+      linux-amd64-fmt)
+        docker run --rm \
+          --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \
+          /bin/bash -c "GOARCH=amd64 PASSES='fmt bom dep' ./test"
+        ;;
+      linux-amd64-integration)
+        docker run --rm \
+          --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \
+          /bin/bash -c "GOARCH=amd64 PASSES='integration' ./test"
+        ;;
+      linux-amd64-functional)
+        docker run --rm \
+          --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \
+          /bin/bash -c "./build && GOARCH=amd64 PASSES='functional' ./test"
+        ;;
+      linux-386-build)
         docker run --rm \
           --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \
-          /bin/bash -c "GOARCH=amd64 ./test"
+          /bin/bash -c "GOARCH=386 PASSES='build' ./test"
         ;;
-      amd64-go-tip)
-        GOARCH=amd64 ./test
+      linux-386-unit)
+        docker run --rm \
+          --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \
+          /bin/bash -c "GOARCH=386 PASSES='unit' ./test"
         ;;
-      darwin-amd64)
+      darwin-amd64-build)
         docker run --rm \
           --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \
-          /bin/bash -c "GO_BUILD_FLAGS='-a -v' GOOS=darwin GOARCH=amd64 ./build"
+          /bin/bash -c "GO_BUILD_FLAGS='-v' GOOS=darwin GOARCH=amd64 ./build"
         ;;
-      windows-amd64)
+      windows-amd64-build)
         docker run --rm \
           --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \
-          /bin/bash -c "GO_BUILD_FLAGS='-a -v' GOOS=windows GOARCH=amd64 ./build"
+          /bin/bash -c "GO_BUILD_FLAGS='-v' GOOS=windows GOARCH=amd64 ./build"
         ;;
-      386)
+      linux-arm-build)
         docker run --rm \
           --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \
-          /bin/bash -c "GOARCH=386 PASSES='build unit' ./test"
+          /bin/bash -c "GO_BUILD_FLAGS='-v' GOARCH=arm ./build"
         ;;
-      *)
-        # test building out of gopath
+      linux-arm64-build)
         docker run --rm \
           --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \
-          /bin/bash -c "GO_BUILD_FLAGS='-a -v' GOARCH='${TARGET}' ./build"
+          /bin/bash -c "GO_BUILD_FLAGS='-v' GOARCH=arm64 ./build"
+        ;;
+      linux-ppc64le-build)
+        docker run --rm \
+          --volume=`pwd`:/go/src/github.com/coreos/etcd gcr.io/etcd-development/etcd-test:go${TRAVIS_GO_VERSION} \
+          /bin/bash -c "GO_BUILD_FLAGS='-v' GOARCH=ppc64le ./build"
+        ;;
+      linux-amd64-fmt-unit-go-tip)
+        GOARCH=amd64 PASSES='fmt unit' ./test
         ;;
     esac

+ 2 - 2
Makefile

@@ -118,7 +118,7 @@ compile-setup-gopath-with-docker-test:
 #
 # Local machine:
 #   TEST_OPTS="PASSES='fmt'" make test
-#   TEST_OPTS="PASSES='fmt bom dep compile build unit'" make test
+#   TEST_OPTS="PASSES='fmt bom dep build unit'" make test
 #   TEST_OPTS="PASSES='build unit release integration_e2e functional'" make test
 #   TEST_OPTS="PASSES='build grpcproxy'" make test
 #
@@ -128,7 +128,7 @@ compile-setup-gopath-with-docker-test:
 #   TEST_OPTS="VERBOSE=2 PASSES='unit'" make docker-test
 #
 # Travis CI (test with docker):
-#   TEST_OPTS="PASSES='fmt bom dep compile build unit'" make docker-test
+#   TEST_OPTS="PASSES='fmt bom dep build unit'" make docker-test
 #
 # Semaphore CI (test with docker):
 #   TEST_OPTS="PASSES='build unit release integration_e2e functional'" make docker-test

+ 0 - 13
bill-of-materials.json

@@ -1,17 +1,4 @@
 [
-	{
-		"project": "bitbucket.org/ww/goautoneg",
-		"licenses": [
-			{
-				"type": "Apache License 2.0",
-				"confidence": 1
-			},
-			{
-				"type": "BSD 3-clause \"New\" or \"Revised\" License",
-				"confidence": 1
-			}
-		]
-	},
 	{
 		"project": "github.com/beorn7/perks/quantile",
 		"licenses": [

+ 0 - 8
bill-of-materials.override.json

@@ -1,12 +1,4 @@
 [
-	{
-		"project": "bitbucket.org/ww/goautoneg",
-		"licenses": [
-			{
-				"type": "BSD 3-clause \"New\" or \"Revised\" License"
-			}
-		]
-	},
 	{
 		"project": "github.com/ghodss/yaml",
 		"licenses": [

+ 1 - 6
etcdserver/v2_server.go

@@ -101,12 +101,7 @@ func (a *reqV2HandlerEtcdServer) processRaftRequest(ctx context.Context, r *Requ
 	ch := a.s.w.Register(r.ID)
 
 	start := time.Now()
-	err = a.s.r.Propose(ctx, data)
-	if err != nil {
-		proposalsFailed.Inc()
-		a.s.w.Trigger(r.ID, nil)
-		return Response{}, err
-	}
+	a.s.r.Propose(ctx, data)
 	proposalsPending.Inc()
 	defer proposalsPending.Dec()
 

+ 7 - 11
test

@@ -41,7 +41,7 @@ if [[ "${PASSES}" == *"functional"* ]]; then
 fi
 
 if [ -z "$PASSES" ]; then
-	PASSES="fmt bom dep compile build unit"
+	PASSES="fmt bom dep build unit"
 fi
 
 USERPKG=${PKG:-}
@@ -195,21 +195,20 @@ function functional_pass {
 		done
 	done
 
-	echo "Starting 'etcd-tester'"
+	echo "functional test START!"
 	./bin/etcd-tester --config ./functional.yaml && echo "'etcd-tester' succeeded"
 	ETCD_TESTER_EXIT_CODE=$?
 	echo "ETCD_TESTER_EXIT_CODE:" ${ETCD_TESTER_EXIT_CODE}
 
-	echo "Waiting for processes to exit"
 	# shellcheck disable=SC2206
 	agent_pids=($agent_pids)
-	kill -s TERM "${agent_pids[@]}"
-	for a in "${agent_pids[@]}"; do wait "$a" || true; done
+	kill -s TERM "${agent_pids[@]}" || true
 
 	if [[ "${ETCD_TESTER_EXIT_CODE}" -ne "0" ]]; then
 		echo "--- FAIL: exit code" ${ETCD_TESTER_EXIT_CODE}
 		exit ${ETCD_TESTER_EXIT_CODE}
 	fi
+	echo "functional test PASS!"
 }
 
 function cov_pass {
@@ -551,7 +550,7 @@ function commit_title_pass {
 		spaceCommas=$(echo "$commitMsg" | sed 's/ /\n/g' | grep -c ',$' || echo 0)
 		commaSpaces=$(echo "$commitMsg" | sed 's/,/\n/g' | grep -c '^ ' || echo 0)
 		if [[ $(echo "$commitMsg" | grep -c ":..*") == 0 || "$commitMsg" == "$pkgPrefix" || "$spaceCommas" != "$commaSpaces" ]]; then
-    			echo "$l"...
+			echo "$l"...
 			echo "Expected commit title format '<package>{\", \"<package>}: <description>'"
 			echo "Got: $l"
 			exit 255
@@ -619,14 +618,11 @@ function build_cov_pass {
 	go test -tags cov -c -covermode=set -coverpkg="$PKGS_COMMA" -o "${out}/etcdctl_test" "${REPO_PATH}/etcdctl"
 }
 
-function compile_pass {
-	echo "Checking build..."
-	GO_BUILD_FLAGS="-a -v" tools_build
-}
-
 # fail fast on static tests
 function build_pass {
+	echo "Checking build..."
 	GO_BUILD_FLAGS="-a -v" etcd_build
+	GO_BUILD_FLAGS="-a -v" tools_build
 }
 
 for pass in $PASSES; do

+ 2 - 2
tests/semaphore.test.bash

@@ -7,9 +7,9 @@ fi
 
 TEST_SUFFIX=$(date +%s | base64 | head -c 15)
 
-TEST_OPTS="PASSES='build unit release integration_e2e functional' MANUAL_VER=v3.3.3"
+TEST_OPTS="PASSES='build release e2e' MANUAL_VER=v3.3.3"
 if [ "$TEST_ARCH" == "386" ]; then
-  TEST_OPTS="GOARCH=386 PASSES='build unit integration_e2e'"
+  TEST_OPTS="GOARCH=386 PASSES='build e2e'"
 fi
 
 docker run \