From 038bab88547c6dbde4fc4fa94001161e8d67a786 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Fri, 1 Apr 2022 19:31:00 +0200
Subject: [PATCH] [BUGFIX] Align functional splitting to chunk execution
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The check for doing the functional test splitting
script and running the selected chunk used similar
but different minimum chunk value to check against.
Thus the splitting script has not been executed in
all chunk execution contexts.

This patch uses now exactly the same check in the
'Build/Scripts/runTests.sh' like it is defined in
the corresponding docker-compose service config.

Furthermore all previous created functional split
files are now removed to avoid leftovers, which
occured if re-run has lower chunksize defined.

Example which is now properly fixed:

> Build/Scripts/runTests.sh -s functional -c 1/1

Example with partial part files from previous run:

> Build/Scripts/runTests.sh -s functional -c 1/10
> Build/Scripts/runTests.sh -s functional -c 1/8

Resolves: #97283
Releases: main, 11.5, 10.4
Change-Id: Id3a0d1c85540b4e7e46aaea69cf2d96839e8e72e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74194
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 Build/Scripts/runTests.sh                     | 2 +-
 Build/testing-docker/local/docker-compose.yml | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh
index 1fc57c9a2881..691c45dbe33d 100755
--- a/Build/Scripts/runTests.sh
+++ b/Build/Scripts/runTests.sh
@@ -566,7 +566,7 @@ case ${TEST_SUITE} in
     functional)
         handleDbmsAndDriverOptions
         setUpDockerComposeDotEnv
-        if [ "${CHUNKS}" -gt 1 ]; then
+        if [ "${CHUNKS}" -gt 0 ]; then
             docker-compose run functional_split
         fi
         case ${DBMS} in
diff --git a/Build/testing-docker/local/docker-compose.yml b/Build/testing-docker/local/docker-compose.yml
index 047e6ffe7292..dfa9f3e06ff6 100644
--- a/Build/testing-docker/local/docker-compose.yml
+++ b/Build/testing-docker/local/docker-compose.yml
@@ -712,7 +712,11 @@ services:
     volumes:
       - ${CORE_ROOT}:${CORE_ROOT}
     working_dir: ${CORE_ROOT}
-    command: php -dxdebug.mode=off Build/Scripts/splitFunctionalTests.php -v ${CHUNKS}
+    command: >
+      /bin/sh -c "
+        rm -rf Build/FunctionalTests-Job-*.xml
+        php -dxdebug.mode=off Build/Scripts/splitFunctionalTests.php -v ${CHUNKS}
+      "
 
   prepare_functional_mariadb:
     image: alpine:3.8
-- 
GitLab