浏览代码

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 6 年之前
父节点
当前提交
0b274cf18f
共有 4 个文件被更改,包括 37 次插入22 次删除
  1. 0 9
      hack/make.sh
  2. 22 2
      hack/make/.integration-test-helpers
  3. 2 10
      hack/make/test-integration-flaky
  4. 13 1
      hack/test/e2e-run.sh

+ 0 - 9
hack/make.sh

@@ -150,15 +150,6 @@ ORIG_BUILDFLAGS=( -tags "autogen netgo osusergo static_build $DOCKER_BUILDTAGS"
 
 BUILDFLAGS=( ${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}" )
 
-# Test timeout.
-if [ "${DOCKER_ENGINE_GOARCH}" == "arm64" ] || [ "${DOCKER_ENGINE_GOARCH}" == "arm" ]; then
-	: ${TIMEOUT:=10m}
-elif [ "${DOCKER_ENGINE_GOARCH}" == "windows" ]; then
-	: ${TIMEOUT:=8m}
-else
-	: ${TIMEOUT:=5m}
-fi
-
 LDFLAGS_STATIC_DOCKER="
 	$LDFLAGS_STATIC
 	-extldflags \"$EXTLDFLAGS_STATIC\"

+ 22 - 2
hack/make/.integration-test-helpers

@@ -20,6 +20,7 @@ integration_api_dirs=${TEST_INTEGRATION_DIR:-"$(
 	grep -vE '(^./integration($|/internal)|/testdata)')"}
 
 run_test_integration() {
+	set_platform_timeout
 	if [[ "$TESTFLAGS" != *-check.f* ]]; then
 		run_test_integration_suites
 	fi
@@ -108,10 +109,9 @@ test_env() {
 			"$@"
 	)
 }
-   
 
 error_on_leaked_containerd_shims() {
-	if [ "$(go env GOOS)" == 'windows' ]; then
+	if [ "$(go env GOOS)" = 'windows' ]; then
 		return
 	fi
 
@@ -124,3 +124,23 @@ error_on_leaked_containerd_shims() {
 		exit 1
 	fi
 }
+
+set_platform_timeout() {
+	# Test timeout.
+	if [ "${DOCKER_ENGINE_GOARCH}" = "arm64" ] || [ "${DOCKER_ENGINE_GOARCH}" = "arm" ]; then
+		: ${TIMEOUT:=10m}
+	elif [ "${DOCKER_ENGINE_GOARCH}" = "windows" ]; then
+		: ${TIMEOUT:=8m}
+	else
+		: ${TIMEOUT:=5m}
+	fi
+
+	if [ "${TEST_REPEAT}" -gt 1 ]; then
+		# TIMEOUT needs to take TEST_REPEAT into account, or a premature time out may happen.
+		# The following ugliness will:
+		# - remove last character (usually 'm' from '10m')
+		# - multiply by testcount
+		# - add last character back
+		TIMEOUT=$((${TIMEOUT::-1} * ${TEST_REPEAT}))${TIMEOUT:$((${#TIMEOUT}-1)):1}
+	fi
+}

+ 2 - 10
hack/make/test-integration-flaky

@@ -20,18 +20,10 @@ echo "Running stress test for them."
 (
     TESTARRAY=$(echo "$new_tests" | sed 's/+func //' | awk -F'\\(' '{print $1}' | tr '\n' '|')
     # Note: TEST_REPEAT will make the test suite run 5 times, restarting the daemon
-    # whereas testcount will make each test run 5 times in a row under the same daemon.
+    # and each test will run 5 times in a row under the same daemon.
     # This will make a total of 25 runs for each test in TESTARRAY.
     export TEST_REPEAT=5
-    local testcount=5
-    # However, TIMEOUT needs to take testcount into account, or a premature time out may happen.
-    # The following ugliness will:
-    # - remove last character (usually 'm' from '10m')
-    # - multiply by testcount
-    # - add last character back
-    export TIMEOUT=$((${TIMEOUT::-1} * $testcount))${TIMEOUT:$((${#TIMEOUT}-1)):1}
-
-    export TESTFLAGS="-test.count $testcount -test.run ${TESTARRAY%?}"
+    export TESTFLAGS="-test.count ${TEST_REPEAT} -test.run ${TESTARRAY%?}"
     echo "Using test flags: $TESTFLAGS"
     source hack/make/test-integration
 )

+ 13 - 1
hack/test/e2e-run.sh

@@ -2,7 +2,7 @@
 set -e -u -o pipefail
 
 ARCH=$(uname -m)
-if [ "$ARCH" == "x86_64" ]; then
+if [ "$ARCH" = "x86_64" ]; then
   ARCH="amd64"
 fi
 
@@ -17,6 +17,7 @@ integration_api_dirs=${TEST_INTEGRATION_DIR:-"$(
 	grep -vE '(^/tests/integration($|/internal)|/testdata)')"}
 
 run_test_integration() {
+	set_platform_timeout
 	if [[ "$TESTFLAGS" != *-check.f* ]]; then
 		run_test_integration_suites
 	fi
@@ -72,5 +73,16 @@ test_env() {
 	)
 }
 
+set_platform_timeout() {
+	# Test timeout.
+	if [ "${DOCKER_ENGINE_GOARCH}" = "arm64" ] || [ "${DOCKER_ENGINE_GOARCH}" = "arm" ]; then
+		: ${TIMEOUT:=10m}
+	elif [ "${DOCKER_ENGINE_GOARCH}" = "windows" ]; then
+		: ${TIMEOUT:=8m}
+	else
+		: ${TIMEOUT:=5m}
+	fi
+}
+
 sh /scripts/ensure-emptyfs.sh
 run_test_integration