From b35de78f74045f42ced124770a35ad3e61e64281 Mon Sep 17 00:00:00 2001
From: Dave Long <dave@longwaveconsulting.com>
Date: Fri, 2 Feb 2024 14:22:05 +0000
Subject: [PATCH] Issue #3415296 by catch, sudhakartag1, smustgrave: Use a
 dedicated runner for performance tests

---
 .gitlab-ci/pipeline.yml                                     | 6 +++++-
 core/phpstan-baseline.neon                                  | 5 -----
 .../FunctionalJavascriptTests/WebDriverCurlService.php      | 6 +++++-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci/pipeline.yml b/.gitlab-ci/pipeline.yml
index 74bf88bd23d9..b609b10441d8 100644
--- a/.gitlab-ci/pipeline.yml
+++ b/.gitlab-ci/pipeline.yml
@@ -83,6 +83,7 @@ variables:
     - "--no-sandbox"
     - "--log-path=/builds/chromedriver.log"
     - "--whitelisted-ips="
+    - "--allowed-origins=*"
 
 .run-tests: &run-tests
   script:
@@ -221,6 +222,9 @@ variables:
     - if: $PERFORMANCE_TEST == "1"
   variables:
     KUBERNETES_CPU_REQUEST: "24"
+    MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-dev-shm-usage","--disable-gpu","--headless","--no-sandbox"]}}, "http://chrome:9515"]'
+  tags:
+    - performance-test-runner
   services:
     - <<: *with-database
     - <<: *with-chrome
@@ -235,4 +239,4 @@ variables:
     - mkdir -p ./sites/simpletest ./sites/default/files ./build/logs/junit /var/www/.composer
     - chown -R www-data:www-data ./sites ./build/logs/junit ./vendor /var/www/
     - sudo -u www-data git config --global --add safe.directory $CI_PROJECT_DIR
-    - for run in {1..3}; do sudo SIMPLETEST_BASE_URL="$SIMPLETEST_BASE_URL" SIMPLETEST_DB="$SIMPLETEST_DB" MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" OTEL_COLLECTOR="$OTEL_COLLECTOR" -u www-data ./vendor/bin/phpunit -c core --group OpenTelemetry --log-junit=./sites/default/files/simpletest/phpunit-performance.xml; done
+    - for run in {1..3}; do sudo SIMPLETEST_BASE_URL="http://$HOSTNAME/subdirectory" SIMPLETEST_DB="$SIMPLETEST_DB" MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" OTEL_COLLECTOR="$OTEL_COLLECTOR" -u www-data ./vendor/bin/phpunit --verbose -c core --group OpenTelemetry --log-junit=./sites/default/files/simpletest/phpunit-performance.xml; done
diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index f46a34e445f6..93168f109e6b 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -2970,11 +2970,6 @@ parameters:
 			count: 1
 			path: tests/Drupal/BuildTests/Framework/Tests/ExternalCommandRequirementTest.php
 
-		-
-			message: "#^Variable \\$rawResult on left side of \\?\\? always exists and is not nullable\\.$#"
-			count: 1
-			path: tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
-
 		-
 			message: "#^Variable \\$found might not be defined\\.$#"
 			count: 1
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
index acd66c5e185c..861aa7da2f6d 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
@@ -117,7 +117,11 @@ public function execute($requestMethod, $url, $parameters = NULL, $extraOptions
 
         curl_setopt($curl, CURLOPT_HTTPHEADER, $customHeaders);
 
-        $rawResult = trim(curl_exec($curl));
+        $result = curl_exec($curl);
+        $rawResult = NULL;
+        if ($result !== FALSE) {
+          $rawResult = trim($result);
+        }
 
         $info = curl_getinfo($curl);
         $info['request_method'] = $requestMethod;
-- 
GitLab