Skip to content

Commit 88a859c

Browse files
authored
fix(CI): resolve flaky tests (#3560)
* fix(test_integrations_kafka): properly wait for zookeeper to be ready before starting kafka Signed-off-by: Alexandre Rulleau <[email protected]> * fix(verify_centos): increase timeout to avoid failure Signed-off-by: Alexandre Rulleau <[email protected]> * fix(profiling_test): skip jit related test on 7.X Signed-off-by: Alexandre Rulleau <[email protected]> * fix(test_extension_ci): increase timeout for valgrind runs Signed-off-by: Alexandre Rulleau <[email protected]> --------- Signed-off-by: Alexandre Rulleau <[email protected]>
1 parent a86ce97 commit 88a859c

8 files changed

Lines changed: 41 additions & 6 deletions

File tree

.gitlab/generate-common.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,27 @@ function dockerhub_login() {
143143
ZOOKEEPER_TICK_TIME: 2000
144144
ALLOW_ANONYMOUS_LOGIN: "yes"
145145
ZOOKEEPER_ADMIN_ENABLE_SERVER: "false"
146+
KAFKA_OPTS: "-Dzookeeper.4lw.commands.whitelist=srvr,ruok"
146147

147148
kafka:
148149
name: registry.ddbuild.io/images/mirror/confluentinc/cp-kafka:7.8.0
149150
alias: kafka-integration
151+
entrypoint: ["/bin/bash"]
152+
command:
153+
- -c
154+
- |
155+
# Wait for Zookeeper to be ready before starting Kafka
156+
echo "Waiting for Zookeeper to be ready..."
157+
for i in $(seq 1 30); do
158+
if echo "ruok" | nc zookeeper 2181 2>/dev/null | grep -q "imok"; then
159+
echo "Zookeeper is ready, starting Kafka..."
160+
break
161+
fi
162+
echo "Waiting for Zookeeper... attempt $i/30"
163+
sleep 2
164+
done
165+
# Start Kafka with original entrypoint
166+
exec /etc/confluent/docker/run
150167
variables:
151168
KAFKA_BROKER_ID: 111
152169
KAFKA_CREATE_TOPICS: test-lowlevel:1:1,test-highlevel:1:1

.gitlab/generate-package.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,6 @@
11681168
- job: "prepare code"
11691169
artifacts: true
11701170
before_script:
1171-
<?php dockerhub_login() ?>
11721171
- |
11731172
# Setup cache dirs
11741173
mkdir -p $PIP_CACHE_DIR
@@ -1187,6 +1186,7 @@
11871186

11881187
# Install Python dependencies
11891188
pip install -U pip virtualenv
1189+
<?php dockerhub_login() ?>
11901190
- git clone https://github.com/DataDog/system-tests.git
11911191
- mv packages/{datadog-setup.php,dd-library-php-*x86_64-linux-gnu.tar.gz} system-tests/binaries
11921192
- cd system-tests

.gitlab/wait-for-service-ready.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ detect_service_type() {
88
test-agent) echo "test-agent" ;;
99
mysql-integration) echo "mysql" ;;
1010
elasticsearch*) echo "elasticsearch" ;;
11+
zookeeper*) echo "zookeeper" ;;
1112
kafka*) echo "kafka" ;;
1213
redis*) echo "redis" ;;
1314
httpbin*) echo "httpbin" ;;
@@ -51,7 +52,7 @@ wait_for_single_service() {
5152
kafka)
5253
# Kafka readiness via nc check + settle time
5354
if timeout 5 nc -z "${HOST}" "${PORT}" 2>/dev/null; then
54-
sleep 2 # Additional settle time for Kafka
55+
sleep 5 # Additional settle time for Kafka
5556
echo "Kafka is ready"
5657
return 0
5758
fi
@@ -69,6 +70,13 @@ wait_for_single_service() {
6970
return 0
7071
fi
7172
;;
73+
zookeeper)
74+
# Zookeeper readiness via "ruok" four-letter-word command
75+
if echo "ruok" | nc -w1 -q1 "${HOST}" "${PORT}" 2>/dev/null | grep -q "imok"; then
76+
echo "Zookeeper is ready"
77+
return 0
78+
fi
79+
;;
7280
generic|*)
7381
# For generic services, just verify port + HTTP 200/health endpoint
7482
if curl -sf "http://${HOST}:${PORT}/" > /dev/null 2>&1 || curl -sf "http://${HOST}:${PORT}/health" > /dev/null 2>&1; then

dockerfiles/verify_packages/centos/install.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,30 @@ OS_VERSION=$(source /etc/os-release; echo $VERSION_ID)
66

77
function do_retry() {
88
RETRIES=3
9+
ATTEMPT=1
910
while
1011
! "$@"
1112
do
1213
if ! ((--RETRIES)); then
1314
return 1
1415
fi
16+
echo "Retry attempt $ATTEMPT failed, waiting 5 seconds before retry $((ATTEMPT + 1))..."
17+
sleep 5
18+
ATTEMPT=$((ATTEMPT + 1))
1519
done
1620
}
1721

1822
# Enable epel repo
19-
do_retry yum install -y epel-release
23+
do_retry yum install -y --setopt=timeout=300 epel-release
2024

2125
# Installing pre-requisites
22-
do_retry yum install -y wget nginx httpd
26+
do_retry yum install -y --setopt=timeout=300 wget nginx httpd
2327
# Nginx listens on 8080, apache on 8081
2428
sed -i "s/Listen 80/Listen 127.0.0.1:8081/" /etc/httpd/conf/httpd.conf
2529

2630
# Installing php
2731
do_retry rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-${OS_VERSION}.rpm
28-
do_retry yum --enablerepo=remi-php${PHP_MINOR_MAJOR} install -y \
32+
do_retry yum --enablerepo=remi-php${PHP_MINOR_MAJOR} install -y --setopt=timeout=300 \
2933
php-cli \
3034
php-fpm \
3135
php-opcache \

profiling/tests/phpt/allocation_jit_01.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ where we assume we are hooked into, while we are not.
1111
<?php
1212
if (!extension_loaded('datadog-profiling'))
1313
echo "skip: test requires datadog-profiling", PHP_EOL;
14+
if (PHP_VERSION_ID < 80000)
15+
echo "skip: JIT requires PHP >= 8.0", PHP_EOL;
1416
?>
1517
--ENV--
1618
USE_ZEND_ALLOC=0

tests/ext/background-sender/agent_sampling-standalone-asm_01.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ datadog.trace.agent_test_session_token=background-sender/agent_samplingc
1717
include __DIR__ . '/../includes/request_replayer.inc';
1818

1919
$rr = new RequestReplayer();
20+
$rr->maxIteration = 2000;
2021

2122
$picked = 0;
2223
$notPicked = 0;
23-
for ($i = 0; $i < 5; $i++)
24+
$maxIterations = 10;
25+
for ($i = 0; $i < $maxIterations; $i++)
2426
{
2527
//Do call and get sampling
2628
\DDTrace\start_span();

tests/ext/background-sender/agent_sampling-standalone-asm_02.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ datadog.trace.agent_test_session_token=background-sender/agent_samplingb
1717
include __DIR__ . '/../includes/request_replayer.inc';
1818

1919
$rr = new RequestReplayer();
20+
$rr->maxIteration = 2000;
2021

2122
$get_sampling = function() use ($rr) {
2223
$root = json_decode($rr->waitForDataAndReplay()["body"], true);

tests/ext/background-sender/agent_sampling-standalone-asm_03.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ datadog.trace.agent_test_session_token=background-sender/agent_samplinga
2222
include __DIR__ . '/../includes/request_replayer.inc';
2323

2424
$rr = new RequestReplayer();
25+
$rr->maxIteration = 2000;
2526

2627
$get_sampling = function() use ($rr) {
2728
$root = json_decode($rr->waitForDataAndReplay()["body"], true);

0 commit comments

Comments
 (0)