Browse code

Improve integration test detecetor

The "new test" detector in test-integration-flaky was a bit flaky since
it would detect function signatures that are not new tests.

In addition, the test calls `return` outside of a function which is not
allowed.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit e2b24490e45fb1e024c0b1594bf978573b91271c)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Brian Goff authored on 2019/08/07 11:28:07
Showing 1 changed files
... ...
@@ -2,28 +2,34 @@
2 2
 set -e -o pipefail
3 3
 
4 4
 source hack/validate/.validate
5
-new_tests=$(
6
-	validate_diff --diff-filter=ACMR --unified=0 -- 'integration/*_test.go' |
7
-	grep -E '^(\+func )(.*)(\*testing)' || true
8
-)
9 5
 
10
-if [ -z "$new_tests" ]; then
11
-	echo 'No new tests added to integration.'
12
-	return
13
-fi
14 6
 
15
-echo
16
-echo "Found new integrations tests:"
17
-echo "$new_tests"
18
-echo "Running stress test for them."
7
+run_integration_flaky() {
8
+	new_tests=$(
9
+		validate_diff --diff-filter=ACMR --unified=0 -- 'integration/*_test.go' |
10
+			grep -E '^(\+func Test)(.*)(\*testing\.T\))' || true
11
+	)
19 12
 
20
-(
21
-	TESTARRAY=$(echo "$new_tests" | sed 's/+func //' | awk -F'\\(' '{print $1}' | tr '\n' '|')
22
-	# Note: TEST_REPEAT will make the test suite run 5 times, restarting the daemon
23
-	# and each test will run 5 times in a row under the same daemon.
24
-	# This will make a total of 25 runs for each test in TESTARRAY.
25
-	export TEST_REPEAT=5
26
-	export TESTFLAGS="-test.count ${TEST_REPEAT} -test.run ${TESTARRAY%?}"
27
-	echo "Using test flags: $TESTFLAGS"
28
-	source hack/make/test-integration
29
-)
13
+	if [ -z "$new_tests" ]; then
14
+		echo 'No new tests added to integration.'
15
+		return
16
+	fi
17
+
18
+	echo
19
+	echo "Found new integrations tests:"
20
+	echo "$new_tests"
21
+	echo "Running stress test for them."
22
+
23
+	(
24
+		TESTARRAY=$(echo "$new_tests" | sed 's/+func //' | awk -F'\\(' '{print $1}' | tr '\n' '|')
25
+		# Note: TEST_REPEAT will make the test suite run 5 times, restarting the daemon
26
+		# and each test will run 5 times in a row under the same daemon.
27
+		# This will make a total of 25 runs for each test in TESTARRAY.
28
+		export TEST_REPEAT=5
29
+		export TESTFLAGS="-test.count ${TEST_REPEAT} -test.run ${TESTARRAY%?}"
30
+		echo "Using test flags: $TESTFLAGS"
31
+		source hack/make/test-integration
32
+	)
33
+}
34
+
35
+run_integration_flaky