From 8bffe9524daacf84815d4dc7777b1cbd58d13718 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Fri, 30 Aug 2019 21:07:17 +0000 Subject: [PATCH] remove per-test -timeout logic because it does not work Signed-off-by: Tibor Vass --- hack/ci/windows.ps1 | 2 -- hack/make/.integration-test-helpers | 7 ++++--- hack/test/e2e-run.sh | 2 +- internal/test/suite/suite.go | 31 ++--------------------------- 4 files changed, 7 insertions(+), 35 deletions(-) diff --git a/hack/ci/windows.ps1 b/hack/ci/windows.ps1 index 8f2aa2d0a3..2516b61188 100644 --- a/hack/ci/windows.ps1 +++ b/hack/ci/windows.ps1 @@ -804,7 +804,6 @@ Try { Write-Host -ForegroundColor Magenta "WARN: Only running integration tests matching $env:INTEGRATION_TEST_NAME" } $c += "`"-tags`" " + "`"autogen`" " - $c += "`"-timeout`" " + "`"10m`" " $c += "`"-test.timeout`" " + "`"200m`" " if ($null -ne $env:INTEGRATION_IN_CONTAINER) { @@ -899,7 +898,6 @@ Try { Write-Host -ForegroundColor Magenta "WARN: Only running LCOW integration tests matching $env:INTEGRATION_TEST_NAME" } $c += "`"-tags`" " + "`"autogen`" " - $c += "`"-timeout`" " + "`"10m`" " $c += "`"-test.timeout`" " + "`"200m`" " Write-Host -ForegroundColor Green "INFO: LCOW Integration tests being run from the host:" diff --git a/hack/make/.integration-test-helpers b/hack/make/.integration-test-helpers index 61aa5c7e72..76101bbefe 100644 --- a/hack/make/.integration-test-helpers +++ b/hack/make/.integration-test-helpers @@ -23,9 +23,10 @@ setup_integration_test_filter() { fi TESTFLAGS+="-test.run ${TEST_FILTER}" - local dirs=$(grep -rIlE --include '*_test.go' "func .*${TEST_FILTER}.*\(. \*testing\.T\)" ./integration*/ | xargs -I file dirname file | uniq) + local dirs + dirs=$(grep -rIlE --include '*_test.go' "func .*${TEST_FILTER}.*\(. \*testing\.T\)" ./integration*/ | xargs -I file dirname file | uniq) if [ -z "${TEST_SKIP_INTEGRATION}" ]; then - : "${TEST_INTEGRATION_DIR:=$(echo "$dirs" | grep -v '^\./integration-cli$')" + : "${TEST_INTEGRATION_DIR:=$(echo "$dirs" | grep -v '^\./integration-cli$')}" if [ -z "${TEST_INTEGRATION_DIR}" ]; then echo "Skipping integration tests since the supplied filter \"${TEST_FILTER}\" omits all integration tests" TEST_SKIP_INTEGRATION=1 @@ -67,7 +68,7 @@ run_test_integration_suites() { run_test_integration_legacy_suites() { ( - flags="-test.v -timeout=${TIMEOUT} $TESTFLAGS" + flags="-test.v -test.timeout=360m $TESTFLAGS" cd integration-cli echo "Running $PWD flags=${flags}" # shellcheck disable=SC2086 diff --git a/hack/test/e2e-run.sh b/hack/test/e2e-run.sh index 94e770ef0c..4ca1d35289 100755 --- a/hack/test/e2e-run.sh +++ b/hack/test/e2e-run.sh @@ -35,7 +35,7 @@ run_test_integration_suites() { run_test_integration_legacy_suites() { ( - flags="-test.v -timeout=${TIMEOUT:-10m} -test.timeout=360m $TESTFLAGS" + flags="-test.v -test.timeout=360m $TESTFLAGS" cd /tests/integration-cli echo "Running $PWD" test_env ./test.main $flags diff --git a/internal/test/suite/suite.go b/internal/test/suite/suite.go index 7bfebcb59b..cd00de4e54 100644 --- a/internal/test/suite/suite.go +++ b/internal/test/suite/suite.go @@ -4,16 +4,14 @@ package suite import ( "flag" - "fmt" "reflect" "runtime/debug" "strings" "testing" - "time" ) // TimeoutFlag is the flag to set a per-test timeout when running tests. Defaults to `-timeout`. -var TimeoutFlag = flag.Duration("timeout", 0, "per-test panic after duration `d` (default 0, timeout disabled)") +var TimeoutFlag = flag.Duration("timeout", 0, "DO NOT USE") var typTestingT = reflect.TypeOf(new(testing.T)) @@ -53,32 +51,7 @@ func Run(t *testing.T, suite interface{}) { } }() - var timeout <-chan time.Time - if *TimeoutFlag > 0 { - timeout = time.After(*TimeoutFlag) - } - panicCh := make(chan error) - go func() { - defer func() { - if r := recover(); r != nil { - panicCh <- fmt.Errorf("test panicked: %v\n%s", r, debug.Stack()) - } else { - close(panicCh) - } - }() - method.Func.Call([]reflect.Value{reflect.ValueOf(suite), reflect.ValueOf(t)}) - }() - select { - case err := <-panicCh: - if err != nil { - t.Fatal(err.Error()) - } - case <-timeout: - if timeoutSuite, ok := suite.(TimeoutTestSuite); ok { - timeoutSuite.OnTimeout() - } - t.Fatalf("timeout: test timed out after %s since start of test", *TimeoutFlag) - } + method.Func.Call([]reflect.Value{reflect.ValueOf(suite), reflect.ValueOf(t)}) }) } }