From d8bde852908319f95b156eb79c0bd817d0cb1784 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= <pawel.gronowski@docker.com>
Date: Tue, 8 Aug 2023 12:52:28 +0200
Subject: [PATCH] hack/test: Don't fail-fast before integration-cli
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If TEST_INTEGRATION_FAIL_FAST is not set, run the integration-cli tests
even if integration tests failed.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 6841a53d1764bd65d08fe655a147ae3c24c977c1)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
---
 hack/make/.integration-test-helpers | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/hack/make/.integration-test-helpers b/hack/make/.integration-test-helpers
index ded310cf6c..4a8c7202f3 100644
--- a/hack/make/.integration-test-helpers
+++ b/hack/make/.integration-test-helpers
@@ -55,11 +55,23 @@ fi
 
 run_test_integration() {
 	set_platform_timeout
+	local failed=0
 	if [ -z "${TEST_SKIP_INTEGRATION}" ]; then
-		run_test_integration_suites "${integration_api_dirs}"
+		if ! run_test_integration_suites "${integration_api_dirs}"; then
+			if [ -n "${TEST_INTEGRATION_FAIL_FAST}" ]; then
+				return 1
+			fi
+			failed=1
+		fi
 	fi
 	if [ -z "${TEST_SKIP_INTEGRATION_CLI}" ]; then
-		TIMEOUT=360m run_test_integration_suites integration-cli
+		if ! TIMEOUT=360m run_test_integration_suites integration-cli; then
+			return 1
+		fi
+	fi
+
+	if [ $failed -eq 1 ]; then
+		return 1
 	fi
 }
 
@@ -99,13 +111,13 @@ run_test_integration_suites() {
 				-- go tool test2json -p "${pkgname}" -t ./test.main ${pkgtestflags}
 		); then
 			if [ -n "${TEST_INTEGRATION_FAIL_FAST}" ]; then
-				exit 1
+				return 1
 			fi
 			failed=1
 		fi
 	done
 	if [ $failed -eq 1 ]; then
-		exit 1
+		return 1
 	fi
 }