Browse code

CI: Introduce flaky test finder

comparing PR commit(s) to HEAD of moby/moby master branch and if founds
new (or renamed) integration tests will run stress tests for them.

Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>

Olli Janatuinen authored on 2019/01/08 02:05:54
Showing 3 changed files
... ...
@@ -165,6 +165,9 @@ test-integration-cli: test-integration ## (DEPRECATED) use test-integration
165 165
 test-integration: build ## run the integration tests
166 166
 	$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-integration
167 167
 
168
+test-integration-flaky: build ## run the stress test for all new integration tests
169
+	$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-integration-flaky
170
+
168 171
 test-unit: build ## run the unit tests
169 172
 	$(DOCKER_RUN_DOCKER) hack/test/unit
170 173
 
... ...
@@ -13,5 +13,6 @@ hack/make.sh \
13 13
 	binary-daemon \
14 14
 	dynbinary \
15 15
 	test-docker-py \
16
+	test-integration-flaky \
16 17
 	test-integration \
17 18
 	cross
18 19
new file mode 100644
... ...
@@ -0,0 +1,26 @@
0
+#!/usr/bin/env bash
1
+set -e -o pipefail
2
+
3
+source hack/validate/.validate
4
+new_tests=$(
5
+    validate_diff --diff-filter=ACMR --unified=0 -- 'integration/*_test.go' |
6
+    grep -E '^(\+func )(.*)(\*testing)' || true
7
+)
8
+
9
+if [ -z "$new_tests" ]; then
10
+    echo 'No new tests added to integration.'
11
+    return
12
+fi
13
+
14
+echo
15
+echo "Found new integrations tests:"
16
+echo "$new_tests"
17
+echo "Running stress test for them."
18
+
19
+(
20
+    TESTARRAY=$(echo "$new_tests" | sed 's/+func //' | awk -F'\\(' '{print $1}' | tr '\n' '|')
21
+    export TESTFLAGS="-test.count 5 -test.run ${TESTARRAY%?}"
22
+    export TEST_REPEAT=5
23
+    echo "Using test flags: $TESTFLAGS"
24
+    source hack/make/test-integration
25
+)