From 7886ec85744ea3886714920dd1b42707a206da8f Mon Sep 17 00:00:00 2001 From: Piotr Tabor Date: Mon, 28 Sep 2020 17:56:07 +0200 Subject: [PATCH] test: Modules: PASSES="integration" ./test understand new file locations --- .travis.yml | 1 + scripts/test_lib.sh | 4 ---- test | 55 ++++++++++++++++++++++++--------------------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 830d89bac..ce44e8082 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,6 +67,7 @@ before_install: install: - go get -t -v -d ./... + - (cd tests && go get -t -v -d ./...) script: - echo "TRAVIS_GO_VERSION=${TRAVIS_GO_VERSION}" diff --git a/scripts/test_lib.sh b/scripts/test_lib.sh index 8c6a6e2d7..dce890f72 100644 --- a/scripts/test_lib.sh +++ b/scripts/test_lib.sh @@ -51,10 +51,6 @@ function pkgs_in_module { go list -mod=mod "${1:-./...}"; } -function filter_out_integration_style_tests { - grep -Ev '/(tests/e2e|integration|functional)(/|$)' -} - #### Running actions against multiple modules #### # run [command...] - runs given command, printing it first and diff --git a/test b/test index 5f47e4af3..db4367e7e 100755 --- a/test +++ b/test @@ -73,6 +73,7 @@ fi function build_pass { log_callout "Building etcd" + run_for_modules run go build "${@}" || return 2 GO_BUILD_FLAGS="-v" etcd_build "${@}" GO_BUILD_FLAGS="-v" tools_build "${@}" } @@ -94,18 +95,18 @@ function unit_pass { function integration_extra { if [ -z "${PKG}" ] ; then if [[ -z "${RUN_ARG[*]}" ]]; then - go_test "./client/... ./clientv3/..." "parallel" : -timeout="${TIMEOUT:-5m}" "${COMMON_TEST_FLAGS[@]}" --run=Example "$@" || return $? + run_for_module "tests" go_test "./integration/..." "keep_going" : -timeout="${TIMEOUT:-5m}" "${COMMON_TEST_FLAGS[@]}" --run=Example "$@" || return $? fi - - go_test "./etcdserver/api/v2store/..." "parallel" : -tags v2v3 -timeout="${TIMEOUT:-5m}" "${RUN_ARG[@]}" "${COMMON_TEST_FLAGS[@]}" "$@" || return $? + run_for_module "." go_test "./contrib/raftexample" "keep_going" : -timeout="${TIMEOUT:-5m}" "${RUN_ARG[@]}" "${COMMON_TEST_FLAGS[@]}" "$@" || return $? + run_for_module "tests" go_test "./integration/v2store/..." "keep_going" : -tags v2v3 -timeout="${TIMEOUT:-5m}" "${RUN_ARG[@]}" "${COMMON_TEST_FLAGS[@]}" "$@" || return $? else log_warning "integration_extra ignored when PKG is specified" fi } function integration_pass { - local pkgs=${USERPKG:-"./integration/... ./clientv3/snapshot/... ./client/integration/... ./clientv3/integration/... ./contrib/raftexample"} - go_test "${pkgs}" "keep_going" : -timeout="${TIMEOUT:-30m}" "${COMMON_TEST_FLAGS[@]}" "${RUN_ARG[@]}" "$@" || return $? + local pkgs=${USERPKG:-"./integration/..."} + run_for_module "tests" go_test "${pkgs}" "keep_going" : -timeout="${TIMEOUT:-30m}" "${COMMON_TEST_FLAGS[@]}" "${RUN_ARG[@]}" "$@" || return $? integration_extra "$@" } @@ -144,7 +145,7 @@ function functional_pass { # TODO: These ports should be dynamically allocated instead of hard-coded. for a in 1 2 3; do - ./bin/etcd-agent --network tcp --address 127.0.0.1:${a}9027 & + ./bin/etcd-agent --network tcp --address 127.0.0.1:${a}9027 < /dev/null & pid="$!" agent_pids="${agent_pids} $pid" done @@ -185,7 +186,7 @@ function functional_pass { } function grpcproxy_pass { - go_test "./integration ./clientv3/integration ./tests/e2e" "fail_fast" : \ + run_for_module "tests" go_test "./integration/... ./e2e" "fail_fast" : \ -timeout=30m -tags cluster_proxy "${COMMON_TEST_FLAGS[@]}" "$@" } @@ -232,7 +233,7 @@ function cov_pass { rm -f "${coverdir}/*.coverprofile" "${coverdir}/cover.*" local covpkgs - covpkgs=$(pkgs_in_module "./..." | filter_out_integration_style_tests) + covpkgs=$(pkgs_in_module "./...") local coverpkg_comma coverpkg_comma=$(echo "${covpkgs[@]}" | xargs | tr ' ' ',') local gocov_build_flags=("-covermode=set" "-coverpkg=$coverpkg_comma") @@ -244,25 +245,22 @@ function cov_pass { "${gocov_build_flags[@]}" "$@" || failed="$failed unit" log_callout "Collecting coverage from integration tests ..." - go_test "./integration ./clientv3/integration ./client/integration" "keep_going" "pkg_to_coverprofileflag integration" \ + run_for_module "tests" go_test "./integration/..." "keep_going" "pkg_to_coverprofileflag integration" \ -timeout=30m "${gocov_build_flags[@]}" "$@" || failed="$failed integration" - # integration-extra - go_test "./client/... ./clientv3/..." "keep_going" "pkg_to_coverprofileflag integration_example" \ - -timeout=5m --run=Example "${gocov_build_flags[@]}" "$@" || failed="$failed integration-examples" # integration-store-v2 - go_test "./etcdserver/api/v2store/..." "keep_going" "pkg_to_coverprofileflag store_v2" \ - -tags v2v3 -timeout=5m "${gocov_build_flags[@]}" "$@" || failed="$failed etcdserver_api_v2store" + run_for_module "tests" go_test "./integration/v2store/..." "keep_going" "pkg_to_coverprofileflag store_v2" \ + -tags v2v3 -timeout=5m "${gocov_build_flags[@]}" "$@" || failed="$failed integration_v2v3" # integration_cluster_proxy - go_test "./clientv3/... ./client/integration/... ./clientv3/snapshot/... ./integration/..." "keep_going" "pkg_to_coverprofileflag integration_cluster_proxy" \ + run_for_module "tests" go_test "./integration/..." "keep_going" "pkg_to_coverprofileflag integration_cluster_proxy" \ -tags cluster_proxy -timeout=5m "${gocov_build_flags[@]}" || failed="$failed integration_cluster_proxy" log_callout "Collecting coverage from e2e tests ..." # We don't pass 'gocov_build_flags' nor 'pkg_to_coverprofileflag' here, # as the coverage is colleced from the ./bin/etcd_test & ./bin/etcdctl_test internally spawned. - go_test "./tests/e2e/..." "keep_going" : -tags=cov -timeout 30m "$@" || failed="$failed tests_e2e" + run_for_module "tests" go_test "./e2e/..." "keep_going" : -tags=cov -timeout 30m "$@" || failed="$failed tests_e2e" log_callout "Collecting coverage from e2e tests with proxy ..." - go_test "./tests/e2e/..." "keep_going" : -tags="cov cluster_proxy" -timeout 30m "$@" || failed="$failed tests_e2e_proxy" + run_for_module "tests" go_test "./e2e/..." "keep_going" : -tags="cov cluster_proxy" -timeout 30m "$@" || failed="$failed tests_e2e_proxy" log_callout "Merging coverage results ..." local cover_out_file="${coverdir}/cover.out" @@ -449,13 +447,7 @@ function commit_title_pass { function goword_for_package { mapfile -t gofiles < <(go_srcs_in_module "$1") # only check for broke exported godocs - gowordRes=$(goword -use-spell=false "${gofiles[@]}" | grep godoc-export | sort) - if [ -n "$gowordRes" ]; then - log_error -e "goword checking failed:\\n${gowordRes}" - return 255 - fi - # check some spelling - gowordRes=$(goword -ignore-file=.words clientv3/{*,*/*}.go 2>&1 | grep spell | sort) + gowordRes=$(run goword -use-spell=false "${gofiles[@]}" | grep godoc-export | sort) if [ -n "$gowordRes" ]; then log_error -e "goword checking failed:\\n${gowordRes}" return 255 @@ -466,6 +458,13 @@ function goword_pass { if tool_exists "goword" "./scripts_install_tool.sh github.com/chzchzchz/goword"; then run_for_modules goword_for_package fi + + # check some spelling + gowordRes=$(run goword -ignore-file=.words clientv3/{*,*/*}.go | grep spell | sort) + if [ -n "$gowordRes" ]; then + log_error -e "goword checking failed:\\n${gowordRes}" + return 255 + fi } function go_fmt_for_package { @@ -543,7 +542,7 @@ function release_pass { mv /tmp/etcd ./bin/etcd-last-release } -function mod_tidy_pass { +function mod_tidy_for_module { # Watch for upstream solution: https://github.com/golang/go/issues/27005 local tmpModDir tmpModDir=$(mktemp -d --suffix "etcd-mod") @@ -553,7 +552,7 @@ function mod_tidy_pass { # If this is causing too much problems, we should # stop controlling go.sum at all. rm go.sum - go mod tidy + run go mod tidy set +e local tmpFileGoModInSync @@ -579,6 +578,10 @@ function mod_tidy_pass { fi } +function mod_tidy_pass { + run_for_modules mod_tidy_for_module +} + ########### MAIN ############################################################### function run_pass {