Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .gitlab/generate-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,27 @@ 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
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
Expand Down
17 changes: 15 additions & 2 deletions .gitlab/generate-package.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
- |
# 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
Expand Down Expand Up @@ -1168,7 +1181,6 @@
- job: "prepare code"
artifacts: true
before_script:
<?php dockerhub_login() ?>
- |
# Setup cache dirs
mkdir -p $PIP_CACHE_DIR
Expand All @@ -1187,6 +1199,7 @@

# Install Python dependencies
pip install -U pip virtualenv
<?php dockerhub_login() ?>
- 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
Expand Down
10 changes: 9 additions & 1 deletion .gitlab/wait-for-service-ready.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" ;;
Expand Down Expand Up @@ -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
echo "Kafka is ready"
return 0
fi
Expand All @@ -69,6 +70,13 @@ wait_for_single_service() {
return 0
fi
;;
zookeeper)
# Zookeeper readiness via "ruok" four-letter-word command
if echo "ruok" | nc -w1 -q1 "${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
Expand Down
10 changes: 7 additions & 3 deletions dockerfiles/verify_packages/centos/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 2 additions & 0 deletions profiling/tests/phpt/allocation_jit_01.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ where we assume we are hooked into, while we are not.
<?php
if (!extension_loaded('datadog-profiling'))
echo "skip: test requires datadog-profiling", PHP_EOL;
if (PHP_VERSION_ID < 80000)
echo "skip: JIT requires PHP >= 8.0", PHP_EOL;
?>
--ENV--
USE_ZEND_ALLOC=0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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',
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
42 changes: 33 additions & 9 deletions tests/Integrations/SQLSRV/SQLSRVTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading