Browse code

remove per-test -timeout logic because it does not work

Signed-off-by: Tibor Vass <tibor@docker.com>

Tibor Vass authored on 2019/08/31 06:07:17
Showing 4 changed files
... ...
@@ -804,7 +804,6 @@ Try {
804 804
                 Write-Host -ForegroundColor Magenta "WARN: Only running integration tests matching $env:INTEGRATION_TEST_NAME"
805 805
             }
806 806
             $c += "`"-tags`" " + "`"autogen`" "
807
-            $c += "`"-timeout`" " + "`"10m`" "
808 807
             $c += "`"-test.timeout`" " + "`"200m`" "
809 808
     
810 809
             if ($null -ne $env:INTEGRATION_IN_CONTAINER) {
... ...
@@ -899,7 +898,6 @@ Try {
899 899
                     Write-Host -ForegroundColor Magenta "WARN: Only running LCOW integration tests matching $env:INTEGRATION_TEST_NAME"
900 900
                 }
901 901
                 $c += "`"-tags`" " + "`"autogen`" "
902
-                $c += "`"-timeout`" " + "`"10m`" "
903 902
                 $c += "`"-test.timeout`" " + "`"200m`" "
904 903
 
905 904
                 Write-Host -ForegroundColor Green "INFO: LCOW Integration tests being run from the host:"
... ...
@@ -23,9 +23,10 @@ setup_integration_test_filter() {
23 23
 	fi
24 24
 	TESTFLAGS+="-test.run ${TEST_FILTER}"
25 25
 
26
-	local dirs=$(grep -rIlE --include '*_test.go' "func .*${TEST_FILTER}.*\(. \*testing\.T\)" ./integration*/ | xargs -I file dirname file | uniq)
26
+	local dirs
27
+	dirs=$(grep -rIlE --include '*_test.go' "func .*${TEST_FILTER}.*\(. \*testing\.T\)" ./integration*/ | xargs -I file dirname file | uniq)
27 28
 	if [ -z "${TEST_SKIP_INTEGRATION}" ]; then
28
-		: "${TEST_INTEGRATION_DIR:=$(echo "$dirs" | grep -v '^\./integration-cli$')"
29
+		: "${TEST_INTEGRATION_DIR:=$(echo "$dirs" | grep -v '^\./integration-cli$')}"
29 30
 		if [ -z "${TEST_INTEGRATION_DIR}" ]; then
30 31
 			echo "Skipping integration tests since the supplied filter \"${TEST_FILTER}\" omits all integration tests"
31 32
 			TEST_SKIP_INTEGRATION=1
... ...
@@ -67,7 +68,7 @@ run_test_integration_suites() {
67 67
 
68 68
 run_test_integration_legacy_suites() {
69 69
 	(
70
-		flags="-test.v -timeout=${TIMEOUT} $TESTFLAGS"
70
+		flags="-test.v -test.timeout=360m $TESTFLAGS"
71 71
 		cd integration-cli
72 72
 		echo "Running $PWD flags=${flags}"
73 73
 		# shellcheck disable=SC2086
... ...
@@ -35,7 +35,7 @@ run_test_integration_suites() {
35 35
 
36 36
 run_test_integration_legacy_suites() {
37 37
 	(
38
-		flags="-test.v -timeout=${TIMEOUT:-10m} -test.timeout=360m $TESTFLAGS"
38
+		flags="-test.v -test.timeout=360m $TESTFLAGS"
39 39
 		cd /tests/integration-cli
40 40
 		echo "Running $PWD"
41 41
 		test_env ./test.main $flags
... ...
@@ -4,16 +4,14 @@ package suite
4 4
 
5 5
 import (
6 6
 	"flag"
7
-	"fmt"
8 7
 	"reflect"
9 8
 	"runtime/debug"
10 9
 	"strings"
11 10
 	"testing"
12
-	"time"
13 11
 )
14 12
 
15 13
 // TimeoutFlag is the flag to set a per-test timeout when running tests. Defaults to `-timeout`.
16
-var TimeoutFlag = flag.Duration("timeout", 0, "per-test panic after duration `d` (default 0, timeout disabled)")
14
+var TimeoutFlag = flag.Duration("timeout", 0, "DO NOT USE")
17 15
 
18 16
 var typTestingT = reflect.TypeOf(new(testing.T))
19 17
 
... ...
@@ -53,32 +51,7 @@ func Run(t *testing.T, suite interface{}) {
53 53
 				}
54 54
 			}()
55 55
 
56
-			var timeout <-chan time.Time
57
-			if *TimeoutFlag > 0 {
58
-				timeout = time.After(*TimeoutFlag)
59
-			}
60
-			panicCh := make(chan error)
61
-			go func() {
62
-				defer func() {
63
-					if r := recover(); r != nil {
64
-						panicCh <- fmt.Errorf("test panicked: %v\n%s", r, debug.Stack())
65
-					} else {
66
-						close(panicCh)
67
-					}
68
-				}()
69
-				method.Func.Call([]reflect.Value{reflect.ValueOf(suite), reflect.ValueOf(t)})
70
-			}()
71
-			select {
72
-			case err := <-panicCh:
73
-				if err != nil {
74
-					t.Fatal(err.Error())
75
-				}
76
-			case <-timeout:
77
-				if timeoutSuite, ok := suite.(TimeoutTestSuite); ok {
78
-					timeoutSuite.OnTimeout()
79
-				}
80
-				t.Fatalf("timeout: test timed out after %s since start of test", *TimeoutFlag)
81
-			}
56
+			method.Func.Call([]reflect.Value{reflect.ValueOf(suite), reflect.ValueOf(t)})
82 57
 		})
83 58
 	}
84 59
 }