From ad872669e127bd5c2b87d969be64acb198940df5 Mon Sep 17 00:00:00 2001 From: Alexandre Rulleau Date: Thu, 8 Jan 2026 14:39:00 +0100 Subject: [PATCH 1/6] fix(test_integrations_kafka): properly wait for zookeeper to be ready before starting kafka Signed-off-by: Alexandre Rulleau --- .gitlab/generate-common.php | 16 ++++++++++++++++ .gitlab/wait-for-service-ready.sh | 10 +++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.gitlab/generate-common.php b/.gitlab/generate-common.php index 127add4e1ec..27d4b8c46d8 100644 --- a/.gitlab/generate-common.php +++ b/.gitlab/generate-common.php @@ -147,6 +147,22 @@ function dockerhub_login() { kafka: name: registry.ddbuild.io/images/mirror/confluentinc/cp-kafka:7.8.0 alias: kafka-integration + entrypoint: ["/bin/bash"] + command: + - -c + - | + # Wait for Zookeeper to be ready before starting Kafka + echo "Waiting for Zookeeper to be ready..." + for i in $(seq 1 30); do + if echo "ruok" | nc zookeeper 2181 2>/dev/null | grep -q "imok"; then + echo "Zookeeper is ready, starting Kafka..." + break + fi + echo "Waiting for Zookeeper... attempt $i/30" + sleep 2 + done + # Start Kafka with original entrypoint + exec /etc/confluent/docker/run variables: KAFKA_BROKER_ID: 111 KAFKA_CREATE_TOPICS: test-lowlevel:1:1,test-highlevel:1:1 diff --git a/.gitlab/wait-for-service-ready.sh b/.gitlab/wait-for-service-ready.sh index bd1eb2669d0..80e3b1a8a89 100755 --- a/.gitlab/wait-for-service-ready.sh +++ b/.gitlab/wait-for-service-ready.sh @@ -8,6 +8,7 @@ detect_service_type() { test-agent) echo "test-agent" ;; mysql-integration) echo "mysql" ;; elasticsearch*) echo "elasticsearch" ;; + zookeeper*) echo "zookeeper" ;; kafka*) echo "kafka" ;; redis*) echo "redis" ;; httpbin*) echo "httpbin" ;; @@ -51,7 +52,7 @@ wait_for_single_service() { kafka) # Kafka readiness via nc check + settle time if timeout 5 nc -z "${HOST}" "${PORT}" 2>/dev/null; then - sleep 2 # Additional settle time for Kafka + sleep 5 # Additional settle time for Kafka to fully connect to Zookeeper echo "Kafka is ready" return 0 fi @@ -69,6 +70,13 @@ wait_for_single_service() { return 0 fi ;; + zookeeper) + # Zookeeper readiness via "ruok" four-letter-word command + if echo "ruok" | nc "${HOST}" "${PORT}" 2>/dev/null | grep -q "imok"; then + echo "Zookeeper is ready" + return 0 + fi + ;; generic|*) # For generic services, just verify port + HTTP 200/health endpoint if curl -sf "http://${HOST}:${PORT}/" > /dev/null 2>&1 || curl -sf "http://${HOST}:${PORT}/health" > /dev/null 2>&1; then From 4f86ee481cdf90348d38e53543cfaebfa43adb92 Mon Sep 17 00:00:00 2001 From: Alexandre Rulleau Date: Thu, 8 Jan 2026 15:22:19 +0100 Subject: [PATCH 2/6] fix(verify_centos): increase timeout to avoid failure Signed-off-by: Alexandre Rulleau --- dockerfiles/verify_packages/centos/install.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dockerfiles/verify_packages/centos/install.sh b/dockerfiles/verify_packages/centos/install.sh index 7fb3cc12106..a37bff6a451 100644 --- a/dockerfiles/verify_packages/centos/install.sh +++ b/dockerfiles/verify_packages/centos/install.sh @@ -6,26 +6,30 @@ OS_VERSION=$(source /etc/os-release; echo $VERSION_ID) function do_retry() { RETRIES=3 + ATTEMPT=1 while ! "$@" do if ! ((--RETRIES)); then return 1 fi + echo "Retry attempt $ATTEMPT failed, waiting 5 seconds before retry $((ATTEMPT + 1))..." + sleep 5 + ATTEMPT=$((ATTEMPT + 1)) done } # Enable epel repo -do_retry yum install -y epel-release +do_retry yum install -y --setopt=timeout=300 epel-release # Installing pre-requisites -do_retry yum install -y wget nginx httpd +do_retry yum install -y --setopt=timeout=300 wget nginx httpd # Nginx listens on 8080, apache on 8081 sed -i "s/Listen 80/Listen 127.0.0.1:8081/" /etc/httpd/conf/httpd.conf # Installing php do_retry rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-${OS_VERSION}.rpm -do_retry yum --enablerepo=remi-php${PHP_MINOR_MAJOR} install -y \ +do_retry yum --enablerepo=remi-php${PHP_MINOR_MAJOR} install -y --setopt=timeout=300 \ php-cli \ php-fpm \ php-opcache \ From a95b1ff0db09733f42d7a98a4369f4a67fae39cd Mon Sep 17 00:00:00 2001 From: Alexandre Rulleau Date: Thu, 8 Jan 2026 15:29:25 +0100 Subject: [PATCH 3/6] fix(profiling_test): skip jit related test on 7.X Signed-off-by: Alexandre Rulleau --- profiling/tests/phpt/allocation_jit_01.phpt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/profiling/tests/phpt/allocation_jit_01.phpt b/profiling/tests/phpt/allocation_jit_01.phpt index 916b83a65f0..47b8a8f80a4 100644 --- a/profiling/tests/phpt/allocation_jit_01.phpt +++ b/profiling/tests/phpt/allocation_jit_01.phpt @@ -11,6 +11,8 @@ where we assume we are hooked into, while we are not. = 8.0", PHP_EOL; ?> --ENV-- USE_ZEND_ALLOC=0 From 9c58f4db885dfefd52672de99d27e75c92358021 Mon Sep 17 00:00:00 2001 From: Alexandre Rulleau Date: Thu, 8 Jan 2026 15:47:32 +0100 Subject: [PATCH 4/6] fix(test_extension_ci): increase timeout for valgrind runs Signed-off-by: Alexandre Rulleau --- .gitlab/generate-common.php | 1 + .gitlab/generate-package.php | 2 +- .gitlab/wait-for-service-ready.sh | 4 ++-- .../background-sender/agent_sampling-standalone-asm_01.phpt | 4 +++- .../background-sender/agent_sampling-standalone-asm_02.phpt | 1 + .../background-sender/agent_sampling-standalone-asm_03.phpt | 1 + 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitlab/generate-common.php b/.gitlab/generate-common.php index 27d4b8c46d8..37aba561fd5 100644 --- a/.gitlab/generate-common.php +++ b/.gitlab/generate-common.php @@ -143,6 +143,7 @@ function dockerhub_login() { ZOOKEEPER_TICK_TIME: 2000 ALLOW_ANONYMOUS_LOGIN: "yes" ZOOKEEPER_ADMIN_ENABLE_SERVER: "false" + KAFKA_OPTS: "-Dzookeeper.4lw.commands.whitelist=srvr,ruok" kafka: name: registry.ddbuild.io/images/mirror/confluentinc/cp-kafka:7.8.0 diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index 99adc2848a8..9b1d766f998 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -1168,7 +1168,6 @@ - job: "prepare code" artifacts: true before_script: - - | # Setup cache dirs mkdir -p $PIP_CACHE_DIR @@ -1187,6 +1186,7 @@ # Install Python dependencies pip install -U pip virtualenv + - git clone https://github.com/DataDog/system-tests.git - mv packages/{datadog-setup.php,dd-library-php-*x86_64-linux-gnu.tar.gz} system-tests/binaries - cd system-tests diff --git a/.gitlab/wait-for-service-ready.sh b/.gitlab/wait-for-service-ready.sh index 80e3b1a8a89..469b3f91b37 100755 --- a/.gitlab/wait-for-service-ready.sh +++ b/.gitlab/wait-for-service-ready.sh @@ -52,7 +52,7 @@ wait_for_single_service() { kafka) # Kafka readiness via nc check + settle time if timeout 5 nc -z "${HOST}" "${PORT}" 2>/dev/null; then - sleep 5 # Additional settle time for Kafka to fully connect to Zookeeper + sleep 5 # Additional settle time for Kafka echo "Kafka is ready" return 0 fi @@ -72,7 +72,7 @@ wait_for_single_service() { ;; zookeeper) # Zookeeper readiness via "ruok" four-letter-word command - if echo "ruok" | nc "${HOST}" "${PORT}" 2>/dev/null | grep -q "imok"; then + if echo "ruok" | nc -w1 -q1 "${HOST}" "${PORT}" 2>/dev/null | grep -q "imok"; then echo "Zookeeper is ready" return 0 fi diff --git a/tests/ext/background-sender/agent_sampling-standalone-asm_01.phpt b/tests/ext/background-sender/agent_sampling-standalone-asm_01.phpt index 126eeb59258..b162f6fb05c 100644 --- a/tests/ext/background-sender/agent_sampling-standalone-asm_01.phpt +++ b/tests/ext/background-sender/agent_sampling-standalone-asm_01.phpt @@ -17,10 +17,12 @@ datadog.trace.agent_test_session_token=background-sender/agent_samplingc include __DIR__ . '/../includes/request_replayer.inc'; $rr = new RequestReplayer(); +$rr->maxIteration = 2000; $picked = 0; $notPicked = 0; -for ($i = 0; $i < 5; $i++) +$maxIterations = 10; +for ($i = 0; $i < $maxIterations; $i++) { //Do call and get sampling \DDTrace\start_span(); diff --git a/tests/ext/background-sender/agent_sampling-standalone-asm_02.phpt b/tests/ext/background-sender/agent_sampling-standalone-asm_02.phpt index 37b0c14a5bf..2770e878289 100644 --- a/tests/ext/background-sender/agent_sampling-standalone-asm_02.phpt +++ b/tests/ext/background-sender/agent_sampling-standalone-asm_02.phpt @@ -17,6 +17,7 @@ datadog.trace.agent_test_session_token=background-sender/agent_samplingb include __DIR__ . '/../includes/request_replayer.inc'; $rr = new RequestReplayer(); +$rr->maxIteration = 2000; $get_sampling = function() use ($rr) { $root = json_decode($rr->waitForDataAndReplay()["body"], true); diff --git a/tests/ext/background-sender/agent_sampling-standalone-asm_03.phpt b/tests/ext/background-sender/agent_sampling-standalone-asm_03.phpt index 8338f4b9e4b..50edd06b452 100644 --- a/tests/ext/background-sender/agent_sampling-standalone-asm_03.phpt +++ b/tests/ext/background-sender/agent_sampling-standalone-asm_03.phpt @@ -22,6 +22,7 @@ datadog.trace.agent_test_session_token=background-sender/agent_samplinga include __DIR__ . '/../includes/request_replayer.inc'; $rr = new RequestReplayer(); +$rr->maxIteration = 2000; $get_sampling = function() use ($rr) { $root = json_decode($rr->waitForDataAndReplay()["body"], true); From 0333ed02d61feef384b14a8f5d96c2588905d7b0 Mon Sep 17 00:00:00 2001 From: Alexandre Rulleau Date: Thu, 8 Jan 2026 15:47:32 +0100 Subject: [PATCH 5/6] fix(test_extension_ci): increase timeout for valgrind runs Signed-off-by: Alexandre Rulleau --- .gitlab/generate-package.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index 9b1d766f998..eb71fa7fd00 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -998,7 +998,7 @@ - sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo - sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo - sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo - - yum update -y + - yum update -y --nogpgcheck "verify debian": extends: .verify_job From 65e56374e3eb87c3a5fe0f0c855cd914687fc486 Mon Sep 17 00:00:00 2001 From: Alexandre Rulleau Date: Tue, 13 Jan 2026 15:30:19 +0100 Subject: [PATCH 6/6] feat(tracer): implement proper SQL connection retry logic Signed-off-by: Alexandre Rulleau --- .gitlab/generate-package.php | 15 +++++- .../Octane/Latest/CommonScenariosTest.php | 46 ++++++++++++++++++- tests/Integrations/SQLSRV/SQLSRVTest.php | 42 +++++++++++++---- 3 files changed, 91 insertions(+), 12 deletions(-) diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index eb71fa7fd00..0a22c9e4d76 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -998,7 +998,20 @@ - sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo - sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo - sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo - - yum update -y --nogpgcheck + - | + # Retry yum update as vault.centos.org can be slow/unreliable + for i in 1 2 3; do + if yum update -y; then + echo "yum update succeeded on attempt $i" + break + fi + echo "yum update failed (attempt $i/3), retrying in 5 seconds..." + sleep 5 + if [ $i -eq 3 ]; then + echo "yum update failed after 3 attempts, exiting" + exit 1 + fi + done "verify debian": extends: .verify_job diff --git a/tests/Integrations/Laravel/Octane/Latest/CommonScenariosTest.php b/tests/Integrations/Laravel/Octane/Latest/CommonScenariosTest.php index 13b66e2a4ba..1a404d9abf7 100644 --- a/tests/Integrations/Laravel/Octane/Latest/CommonScenariosTest.php +++ b/tests/Integrations/Laravel/Octane/Latest/CommonScenariosTest.php @@ -92,6 +92,14 @@ public function testScenarioGetReturnString() } } + $this->assertNotNull( + $webRequestTrace, + 'Expected to find a laravel.request trace with App\\Http\\Controllers in resource, but none was found. ' + . 'Available traces: ' . json_encode(array_map(function($t) { + return ['name' => $t[0]['name'] ?? 'N/A', 'resource' => $t[0]['resource'] ?? 'N/A']; + }, $traces)) + ); + $this->assertFlameGraph([$webRequestTrace], [ SpanAssertion::build( 'laravel.request', @@ -134,7 +142,12 @@ public function testScenarioGetWithView() foreach ($traces as $trace) { foreach ($trace as $span) { - if ($span && isset($span["name"]) && $span["name"] === "laravel.request") { + if ($span + && isset($span["name"]) + && $span["name"] === "laravel.request" + && isset($span["resource"]) + && str_contains($span["resource"], 'App\\Http\\Controllers') + ) { return true; } } @@ -160,6 +173,14 @@ public function testScenarioGetWithView() } } + $this->assertNotNull( + $webRequestTrace, + 'Expected to find a laravel.request trace with App\\Http\\Controllers in resource, but none was found. ' + . 'Available traces: ' . json_encode(array_map(function($t) { + return ['name' => $t[0]['name'] ?? 'N/A', 'resource' => $t[0]['resource'] ?? 'N/A']; + }, $traces)) + ); + $this->assertFlameGraph([$webRequestTrace], [ SpanAssertion::build( 'laravel.request', @@ -219,7 +240,12 @@ public function testScenarioGetWithException() foreach ($traces as $trace) { foreach ($trace as $span) { - if ($span && isset($span["name"]) && $span["name"] === "laravel.request") { + if ($span + && isset($span["name"]) + && $span["name"] === "laravel.request" + && isset($span["resource"]) + && str_contains($span["resource"], 'App\\Http\\Controllers') + ) { return true; } } @@ -245,6 +271,14 @@ public function testScenarioGetWithException() } } + $this->assertNotNull( + $webRequestTrace, + 'Expected to find a laravel.request trace with App\\Http\\Controllers in resource, but none was found. ' + . 'Available traces: ' . json_encode(array_map(function($t) { + return ['name' => $t[0]['name'] ?? 'N/A', 'resource' => $t[0]['resource'] ?? 'N/A']; + }, $traces)) + ); + $this->assertFlameGraph([$webRequestTrace], [ SpanAssertion::build( 'laravel.request', @@ -312,6 +346,14 @@ public function testScenarioGetToMissingRoute() } } + $this->assertNotNull( + $webRequestTrace, + 'Expected to find a laravel.request trace, but none was found. ' + . 'Available traces: ' . json_encode(array_map(function($t) { + return ['name' => $t[0]['name'] ?? 'N/A', 'resource' => $t[0]['resource'] ?? 'N/A']; + }, $traces)) + ); + $this->assertFlameGraph([$webRequestTrace], [ SpanAssertion::build( 'laravel.request', diff --git a/tests/Integrations/SQLSRV/SQLSRVTest.php b/tests/Integrations/SQLSRV/SQLSRVTest.php index 8b5b6d101de..91d66e50140 100644 --- a/tests/Integrations/SQLSRV/SQLSRVTest.php +++ b/tests/Integrations/SQLSRV/SQLSRVTest.php @@ -502,15 +502,39 @@ public function testNoFakeServices() private function createConnection() { - $conn = sqlsrv_connect( - self::$host . ', ' . self::$port, - [ - 'PWD' => self::$password, - 'Database' => self::$db, - 'UID' => self::$user, - 'TrustServerCertificate' => true - ] - ); + // Retry connection to handle SQL Server container startup time + $maxAttempts = 30; + $attempt = 0; + $conn = false; + $lastError = null; + + while ($attempt < $maxAttempts && $conn === false) { + $attempt++; + $conn = sqlsrv_connect( + self::$host . ', ' . self::$port, + [ + 'PWD' => self::$password, + 'Database' => self::$db, + 'UID' => self::$user, + 'TrustServerCertificate' => true, + ] + ); + + if ($conn === false) { + $errors = sqlsrv_errors(); + $lastError = $errors ? json_encode($errors) : 'Unknown error'; + + if ($attempt < $maxAttempts) { + usleep(500000); + } + } + } + + if ($conn === false) { + throw new \RuntimeException( + "Failed to connect to SQL Server after {$maxAttempts} attempts. Last error: {$lastError}" + ); + } return $conn; }