From 42b318a0a9112121189db3c7fa371b64b328efb1 Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Aug 16 2016 10:45:13 +0000 Subject: Hack test to provide ability to run unit-tests and integration tests Still, keeping it disabled by default as it keeps failing - related: #1351818 --- diff --git a/e2e-sleep-for-a-while-to-let-etcd-procs-start.patch b/e2e-sleep-for-a-while-to-let-etcd-procs-start.patch deleted file mode 100644 index f4953a0..0000000 --- a/e2e-sleep-for-a-while-to-let-etcd-procs-start.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 1724bd58d14d9bb86553d06f7e90f6ee88f557e2 Mon Sep 17 00:00:00 2001 -From: Jan Chaloupka -Date: Wed, 23 Mar 2016 14:10:29 +0100 -Subject: [PATCH] e2e: sleep for a while to let etcd procs start - ---- - e2e/etcd_test.go | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/e2e/etcd_test.go b/e2e/etcd_test.go -index 5fde84e..41a5095 100644 ---- a/e2e/etcd_test.go -+++ b/e2e/etcd_test.go -@@ -23,6 +23,7 @@ import ( - "path" - "strings" - "testing" -+ "time" - - "github.com/coreos/etcd/pkg/fileutil" - "github.com/coreos/etcd/pkg/testutil" -@@ -197,6 +198,9 @@ func newEtcdProcessCluster(cfg *etcdProcessClusterConfig) (*etcdProcessCluster, - epc.procs[i] = proc - } - -+ // Give it some time for etcd procs to start -+ time.Sleep(2 * time.Second) -+ - // wait for cluster to start - readyC := make(chan error, cfg.clusterSize+cfg.proxySize) - readyStr := "etcdserver: set the initial cluster version to" --- -1.9.3 - diff --git a/etcd.spec b/etcd.spec index 89be303..b650376 100644 --- a/etcd.spec +++ b/etcd.spec @@ -36,15 +36,13 @@ Name: %{repo} Version: 3.0.4 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A highly-available key value store for shared configuration License: ASL 2.0 URL: https://%{provider_prefix} Source0: https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz Source1: %{name}.service Source2: %{name}.conf -Patch0: make-etcd-bin-path-configurable.patch -Patch1: e2e-sleep-for-a-while-to-let-etcd-procs-start.patch Patch2: 0001-change-import-paths.patch # e.g. el6 has ppc64 arch without gcc-go, so EA tag is required @@ -339,6 +337,14 @@ for file in $(find . -iname "*_test.go"); do cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list done + +install -dp %{buildroot}/%{gopath}/src/%{import_path}/integration/ +cp -rpav integration/fixtures %{buildroot}/%{gopath}/src/%{import_path}/integration/. +echo "%%{gopath}/src/%%{import_path}/integration/fixtures" >> unit-test.file-list + +install -dp %{buildroot}/%{gopath}/src/%{import_path}/etcdserver/api/v2http/testdata +cp -rpav etcdserver/api/v2http/testdata %{buildroot}/%{gopath}/src/%{import_path}/etcdserver/api/v2http/. +echo "%%{gopath}/src/%%{import_path}/etcdserver/api/v2http/testdata" >> unit-test.file-list %endif %if 0%{?with_devel} @@ -357,52 +363,25 @@ export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath} %global gotest go test %endif -export BIN_PATH="$(pwd)/bin" - -%gotest %{import_path}/client -%gotest %{import_path}/clientv3 -%gotest %{import_path}/clientv3/integration -%gotest %{import_path}/compactor -%gotest %{import_path}/contrib/raftexample -%gotest %{import_path}/discovery -#%%gotest %%{import_path}/e2e -%gotest %{import_path}/error -%gotest %{import_path}/etcdctl/command -%gotest %{import_path}/etcdmain -%gotest %{import_path}/etcdserver -%gotest %{import_path}/etcdserver/auth -#%gotest %{import_path}/etcdserver/etcdhttp -#%gotest %{import_path}/etcdserver/etcdhttp/httptypes -#%%gotest %%{import_path}/integration -%gotest %{import_path}/lease -%gotest %{import_path}/pkg/adt -%gotest %{import_path}/pkg/cors -%gotest %{import_path}/pkg/crc -%gotest %{import_path}/pkg/fileutil -%gotest %{import_path}/pkg/flags -%gotest %{import_path}/pkg/idutil -%gotest %{import_path}/pkg/ioutil -%gotest %{import_path}/pkg/logutil -%gotest %{import_path}/pkg/netutil -%gotest %{import_path}/pkg/osutil -%gotest %{import_path}/pkg/pathutil -%gotest %{import_path}/pkg/pbutil -%gotest %{import_path}/pkg/schedule -%gotest %{import_path}/pkg/testutil -%gotest %{import_path}/pkg/transport -%gotest %{import_path}/pkg/types -%gotest %{import_path}/pkg/wait -%gotest %{import_path}/proxy -%gotest %{import_path}/raft -%gotest %{import_path}/raft/rafttest -%gotest %{import_path}/rafthttp -%gotest %{import_path}/snap -%gotest %{import_path}/storage -%gotest %{import_path}/storage/backend -%gotest %{import_path}/store -%gotest %{import_path}/tools/functional-tester/etcd-agent -%gotest %{import_path}/version -%gotest %{import_path}/wal +%ifarch x86_64 +RACE="--race" +%else +RACE="" +%endif + +# unit-tests +# TODO(jchaloup): read all the envs from test file +export IGNORE_PKGS="(cmd|vendor|etcdserverpb|rafttest)" +export INTEGRATION_PKGS="(integration|e2e|contrib|functional-tester)" +export TEST_PKGS=`find . -name \*_test.go | while read a; do dirname $a; done | sort | uniq | egrep -v "$IGNORE_PKGS" | sed "s|\./||g"` +export TESTS=`echo "$TEST_PKGS" | egrep -v "$INTEGRATION_PKGS"` + +for test in ${TESTS}; do +%gotest -timeout 3m -cover ${RACE} -cpu 1,2,4 -run=Test github.com/coreos/etcd/${test} +done + +./test + %endif %pre @@ -448,6 +427,11 @@ getent passwd %{name} >/dev/null || useradd -r -g %{name} -d %{_sharedstatedir}/ %endif %changelog +* Tue Aug 16 2016 jchaloup - 3.0.4-2 +- Hack test to provide ability to run unit-tests and integration tests + Still, keeping it disabled by default as it keeps failing + related: #1351818 + * Tue Aug 02 2016 jchaloup - 3.0.4-1 - Update to 3.0.4 related: #1351818 diff --git a/hack-test.patch b/hack-test.patch new file mode 100644 index 0000000..a6402b3 --- /dev/null +++ b/hack-test.patch @@ -0,0 +1,73 @@ +From a144093e502d4529d598ecf997fea9e261ac595d Mon Sep 17 00:00:00 2001 +From: Jan Chaloupka +Date: Mon, 15 Aug 2016 16:09:52 +0200 +Subject: [PATCH] hack test + +--- + test | 26 +++++++++++++------------- + 1 file changed, 13 insertions(+), 13 deletions(-) + +diff --git a/test b/test +index 4f24606..deaa527 100755 +--- a/test ++++ b/test +@@ -53,7 +53,7 @@ fi + function unit_tests { + echo "Running tests..." + # only -run=Test so examples can run in integration tests +- go test -timeout 3m ${COVER} ${RACE} -cpu 1,2,4 -run=Test $@ ${TEST} ++ ${GOTEST:-go test} -timeout 3m ${COVER} ${RACE} -cpu 1,2,4 -run=Test $@ ${TEST} + } + + function integration_tests { +@@ -69,16 +69,16 @@ function integration_tests { + mv /tmp/etcd ./bin/etcd-last-release + fi; + +- go test -timeout 10m -v -cpu 1,2,4 $@ ${REPO_PATH}/e2e & ++ ${GOTEST:-go test} -timeout 10m -v -cpu 1,2,4 $@ ${REPO_PATH}/e2e & + e2epid="$!" +- go test -timeout 15m -v -cpu 1,2,4 $@ ${REPO_PATH}/integration & ++ ${GOTEST:-go test} -timeout 15m -v -cpu 1,2,4 $@ ${REPO_PATH}/integration & + intpid="$!" + wait $e2epid + wait $intpid +- go test -timeout 1m -v ${RACE} -cpu 1,2,4 $@ ${REPO_PATH}/client/integration +- go test -timeout 10m -v ${RACE} -cpu 1,2,4 $@ ${REPO_PATH}/clientv3/integration +- go test -timeout 1m -v -cpu 1,2,4 $@ ${REPO_PATH}/contrib/raftexample +- go test -timeout 1m -v ${RACE} -cpu 1,2,4 -run=Example $@ ${TEST} ++ ${GOTEST:-go test} -timeout 1m -v ${RACE} -cpu 1,2,4 $@ ${REPO_PATH}/client/integration ++ ${GOTEST:-go test} -timeout 10m -v ${RACE} -cpu 1,2,4 $@ ${REPO_PATH}/clientv3/integration ++ ${GOTEST:-go test} -timeout 1m -v -cpu 1,2,4 $@ ${REPO_PATH}/contrib/raftexample ++ ${GOTEST:-go test} -timeout 1m -v ${RACE} -cpu 1,2,4 -run=Example $@ ${TEST} + } + + function fmt_tests { +@@ -197,18 +197,18 @@ function dep_tests { + } + + # Set up gopath so tests use vendored dependencies +-export GOPATH=${PWD}/gopath +-rm -rf $GOPATH/src +-mkdir -p $GOPATH +-ln -s ${PWD}/cmd/vendor $GOPATH/src ++#export GOPATH=${PWD}/Godeps/_workspace ++#rm -rf $GOPATH/src ++#mkdir -p $GOPATH ++#ln -s ${PWD}/cmd/vendor $GOPATH/src + + # fail fast on static tests + toggle_failpoints disable +-fmt_tests ++#fmt_tests + dep_tests + + # fail fast on static tests +-GO_BUILD_FLAGS="-a -v" etcd_build ++#GO_BUILD_FLAGS="-a -v" etcd_build + + unit_tests + if [ -n "$INTEGRATION" ]; then +-- +1.9.3 + diff --git a/make-etcd-bin-path-configurable.patch b/make-etcd-bin-path-configurable.patch deleted file mode 100644 index b3214f5..0000000 --- a/make-etcd-bin-path-configurable.patch +++ /dev/null @@ -1,54 +0,0 @@ -From bedf2363bccc8e466e2ca20e8dbc678c036ca1b4 Mon Sep 17 00:00:00 2001 -From: Jan Chaloupka -Date: Wed, 23 Mar 2016 13:42:00 +0100 -Subject: [PATCH] make etcd bin path configurable - ---- - e2e/etcd_test.go | 14 +++++++++++--- - 1 file changed, 11 insertions(+), 3 deletions(-) - -diff --git a/e2e/etcd_test.go b/e2e/etcd_test.go -index 05410bd..5fde84e 100644 ---- a/e2e/etcd_test.go -+++ b/e2e/etcd_test.go -@@ -20,12 +20,13 @@ import ( - "math/rand" - "net/url" - "os" -+ "path" - "strings" - "testing" - -- "github.com/coreos/gexpect" - "github.com/coreos/etcd/pkg/fileutil" - "github.com/coreos/etcd/pkg/testutil" -+ "github.com/coreos/gexpect" - ) - - const ( -@@ -230,13 +231,20 @@ func newEtcdProcessCluster(cfg *etcdProcessClusterConfig) (*etcdProcessCluster, - } - - func newEtcdProcess(cfg *etcdProcessConfig) (*etcdProcess, error) { -- if fileutil.Exist("../bin/etcd") == false { -+ binPath := os.Getenv("BIN_PATH") -+ if binPath == "" { -+ binPath = "../bin" -+ } -+ -+ etcdBinPath := path.Join(binPath, "etcd") -+ -+ if fileutil.Exist(etcdBinPath) == false { - return nil, fmt.Errorf("could not find etcd binary") - } - if err := os.RemoveAll(cfg.dataDirPath); err != nil { - return nil, err - } -- child, err := spawnCmd(append([]string{"../bin/etcd"}, cfg.args...)) -+ child, err := spawnCmd(append([]string{etcdBinPath}, cfg.args...)) - if err != nil { - return nil, err - } --- -1.9.3 -