Browse code

Set TIMEOUT according to os/arch.

Signed-off-by: Michael Zhao <michael.zhao@arm.com>
(cherry picked from commit 790da6c22327f5c920258ee83126ef4b842e3cbb)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Michael Zhao authored on 2019/07/17 14:05:35
Showing 4 changed files
... ...
@@ -150,15 +150,6 @@ ORIG_BUILDFLAGS=( -tags "autogen netgo osusergo static_build $DOCKER_BUILDTAGS"
150 150
 
151 151
 BUILDFLAGS=( ${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}" )
152 152
 
153
-# Test timeout.
154
-if [ "${DOCKER_ENGINE_GOARCH}" == "arm64" ] || [ "${DOCKER_ENGINE_GOARCH}" == "arm" ]; then
155
-	: ${TIMEOUT:=10m}
156
-elif [ "${DOCKER_ENGINE_GOARCH}" == "windows" ]; then
157
-	: ${TIMEOUT:=8m}
158
-else
159
-	: ${TIMEOUT:=5m}
160
-fi
161
-
162 153
 LDFLAGS_STATIC_DOCKER="
163 154
 	$LDFLAGS_STATIC
164 155
 	-extldflags \"$EXTLDFLAGS_STATIC\"
... ...
@@ -20,6 +20,7 @@ integration_api_dirs=${TEST_INTEGRATION_DIR:-"$(
20 20
 	grep -vE '(^./integration($|/internal)|/testdata)')"}
21 21
 
22 22
 run_test_integration() {
23
+	set_platform_timeout
23 24
 	if [[ "$TESTFLAGS" != *-check.f* ]]; then
24 25
 		run_test_integration_suites
25 26
 	fi
... ...
@@ -108,10 +109,9 @@ test_env() {
108 108
 			"$@"
109 109
 	)
110 110
 }
111
-   
112 111
 
113 112
 error_on_leaked_containerd_shims() {
114
-	if [ "$(go env GOOS)" == 'windows' ]; then
113
+	if [ "$(go env GOOS)" = 'windows' ]; then
115 114
 		return
116 115
 	fi
117 116
 
... ...
@@ -124,3 +124,23 @@ error_on_leaked_containerd_shims() {
124 124
 		exit 1
125 125
 	fi
126 126
 }
127
+
128
+set_platform_timeout() {
129
+	# Test timeout.
130
+	if [ "${DOCKER_ENGINE_GOARCH}" = "arm64" ] || [ "${DOCKER_ENGINE_GOARCH}" = "arm" ]; then
131
+		: ${TIMEOUT:=10m}
132
+	elif [ "${DOCKER_ENGINE_GOARCH}" = "windows" ]; then
133
+		: ${TIMEOUT:=8m}
134
+	else
135
+		: ${TIMEOUT:=5m}
136
+	fi
137
+
138
+	if [ "${TEST_REPEAT}" -gt 1 ]; then
139
+		# TIMEOUT needs to take TEST_REPEAT into account, or a premature time out may happen.
140
+		# The following ugliness will:
141
+		# - remove last character (usually 'm' from '10m')
142
+		# - multiply by testcount
143
+		# - add last character back
144
+		TIMEOUT=$((${TIMEOUT::-1} * ${TEST_REPEAT}))${TIMEOUT:$((${#TIMEOUT}-1)):1}
145
+	fi
146
+}
... ...
@@ -20,18 +20,10 @@ echo "Running stress test for them."
20 20
 (
21 21
     TESTARRAY=$(echo "$new_tests" | sed 's/+func //' | awk -F'\\(' '{print $1}' | tr '\n' '|')
22 22
     # Note: TEST_REPEAT will make the test suite run 5 times, restarting the daemon
23
-    # whereas testcount will make each test run 5 times in a row under the same daemon.
23
+    # and each test will run 5 times in a row under the same daemon.
24 24
     # This will make a total of 25 runs for each test in TESTARRAY.
25 25
     export TEST_REPEAT=5
26
-    local testcount=5
27
-    # However, TIMEOUT needs to take testcount into account, or a premature time out may happen.
28
-    # The following ugliness will:
29
-    # - remove last character (usually 'm' from '10m')
30
-    # - multiply by testcount
31
-    # - add last character back
32
-    export TIMEOUT=$((${TIMEOUT::-1} * $testcount))${TIMEOUT:$((${#TIMEOUT}-1)):1}
33
-
34
-    export TESTFLAGS="-test.count $testcount -test.run ${TESTARRAY%?}"
26
+    export TESTFLAGS="-test.count ${TEST_REPEAT} -test.run ${TESTARRAY%?}"
35 27
     echo "Using test flags: $TESTFLAGS"
36 28
     source hack/make/test-integration
37 29
 )
... ...
@@ -2,7 +2,7 @@
2 2
 set -e -u -o pipefail
3 3
 
4 4
 ARCH=$(uname -m)
5
-if [ "$ARCH" == "x86_64" ]; then
5
+if [ "$ARCH" = "x86_64" ]; then
6 6
   ARCH="amd64"
7 7
 fi
8 8
 
... ...
@@ -17,6 +17,7 @@ integration_api_dirs=${TEST_INTEGRATION_DIR:-"$(
17 17
 	grep -vE '(^/tests/integration($|/internal)|/testdata)')"}
18 18
 
19 19
 run_test_integration() {
20
+	set_platform_timeout
20 21
 	if [[ "$TESTFLAGS" != *-check.f* ]]; then
21 22
 		run_test_integration_suites
22 23
 	fi
... ...
@@ -72,5 +73,16 @@ test_env() {
72 72
 	)
73 73
 }
74 74
 
75
+set_platform_timeout() {
76
+	# Test timeout.
77
+	if [ "${DOCKER_ENGINE_GOARCH}" = "arm64" ] || [ "${DOCKER_ENGINE_GOARCH}" = "arm" ]; then
78
+		: ${TIMEOUT:=10m}
79
+	elif [ "${DOCKER_ENGINE_GOARCH}" = "windows" ]; then
80
+		: ${TIMEOUT:=8m}
81
+	else
82
+		: ${TIMEOUT:=5m}
83
+	fi
84
+}
85
+
75 86
 sh /scripts/ensure-emptyfs.sh
76 87
 run_test_integration