Skip to content
Open
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
6 changes: 3 additions & 3 deletions .gitlab/generate-tracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function before_script_steps($with_docker_auth = false) {
artifacts: true
retry: 2
variables:
WAIT_FOR: test-agent:9126
WAIT_FOR: test-agent:9126 request-replayer:80
KUBERNETES_CPU_REQUEST: 6
KUBERNETES_CPU_LIMIT: 6
KUBERNETES_MEMORY_REQUEST: 4Gi
Expand Down Expand Up @@ -305,7 +305,7 @@ function before_script_steps($with_docker_auth = false) {
ARCH: "amd64"
artifacts: true
variables:
WAIT_FOR: test-agent:9126
WAIT_FOR: test-agent:9126 request-replayer:80
KUBERNETES_CPU_REQUEST: 12
MAX_TEST_PARALLELISM: 4
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
Expand Down Expand Up @@ -360,7 +360,7 @@ function before_script_steps($with_docker_auth = false) {
ARCH: "amd64"
artifacts: true
variables:
WAIT_FOR: test-agent:9126
WAIT_FOR: test-agent:9126 request-replayer:80
KUBERNETES_CPU_REQUEST: 12
MAX_TEST_PARALLELISM: 4
PHP_MAJOR_MINOR: "<?= $major_minor ?>"
Expand Down
9 changes: 9 additions & 0 deletions .gitlab/wait-for-service-ready.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ detect_service_type() {
local host=${1}
case ${host} in
test-agent) echo "test-agent" ;;
request-replayer) echo "request-replayer" ;;
mysql-integration) echo "mysql" ;;
elasticsearch*) echo "elasticsearch" ;;
zookeeper*) echo "zookeeper" ;;
Expand Down Expand Up @@ -38,6 +39,14 @@ wait_for_single_service() {
return 0
fi
;;
request-replayer)
# Any HTTP response (2xx/3xx/4xx/5xx) proves php -S is up and executing index.php.
# /replay may return 4xx when no data has been dumped yet, so do not use -f.
if curl -s -o /dev/null "http://${HOST}:${PORT}/replay"; then
echo "request-replayer is ready"
return 0
fi
;;
mysql)
if mysqladmin ping -h"${HOST}" --silent 2>/dev/null; then
echo "MySQL is ready"
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ $(BUILD_DIR)/configure: $(M4_FILES) $(BUILD_DIR)/ddtrace.sym $(BUILD_DIR)/VERSIO
$(BUILD_DIR)/run-tests.php: $(if $(ASSUME_COMPILED),, $(BUILD_DIR)/configure)
$(if $(ASSUME_COMPILED), cp $(shell dirname $(shell realpath $(shell which phpize)))/../lib/php/build/run-tests.php $(BUILD_DIR)/run-tests.php)
sed -i 's/\bdl(/(bool)(/' $(BUILD_DIR)/run-tests.php # this dl() stuff in run-tests.php is for --EXTENSIONS-- sections, which we don't use; just strip it away (see https://github.com/php/php-src/issues/15367)
sed -i 's/return number_format($$this->rootSuite/return round($$this->rootSuite/' $(BUILD_DIR)/run-tests.php # number_format returns a comma-formatted string for elapsed >= 1000s (e.g. "1,500.0000"), which is non-numeric and triggers E_WARNING in PHP 8.0+ when used in += arithmetic inside record()

# ensure list of rust files is up to date
$(BUILD_DIR)/.rust_files_list: $(RUST_FILES)
Expand Down Expand Up @@ -211,7 +212,8 @@ test_extension_ci: $(SO_FILE) $(TEST_FILES) $(TEST_STUB_FILES) $(BUILD_DIR)/run-
\
export TEST_PHP_JUNIT=$(JUNIT_RESULTS_DIR)/valgrind-extension-test.xml; \
export TEST_PHP_OUTPUT=$(JUNIT_RESULTS_DIR)/valgrind-run-tests.out; \
DD_SPAWN_WORKER_STABLE_TRAMPOLINE=1 $(ALL_TEST_ENV_OVERRIDE) $(RUN_TESTS_CMD) -d extension=$(SO_FILE) -m -s $$TEST_PHP_OUTPUT $(BUILD_DIR)/$(TESTS) && ! grep -e '^LEAKED TEST SUMMARY' $$TEST_PHP_OUTPUT; \
SHOW_SLOW=$$(php -r 'echo PHP_VERSION_ID >= 70200 ? "--show-slow 30000" : "";'); \
DD_SPAWN_WORKER_STABLE_TRAMPOLINE=1 $(ALL_TEST_ENV_OVERRIDE) $(RUN_TESTS_CMD) $$SHOW_SLOW -d extension=$(SO_FILE) -m -s $$TEST_PHP_OUTPUT $(BUILD_DIR)/$(TESTS) && ! grep -e '^LEAKED TEST SUMMARY' $$TEST_PHP_OUTPUT; \
)

build_tea: TEA_BUILD_TESTS=ON
Expand Down
10 changes: 8 additions & 2 deletions tests/ext/remote_config/dynamic_config_update.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ put_dynamic_config_file([
// submit span data
\DDTrace\start_span();

if (ini_get("datadog.trace.sample_rate") != 0.5) {
sleep(20); // signal interrupts interrupt the sleep().
// Poll until the dynamic config is applied. The wrapped sleep() blocks
// SIGVTALRM during the call, so a single sleep(20) can be cut short by
// unrelated signals (notably under valgrind, where signal traffic is heavier).
// Looping ensures we keep waiting up to ~20s total for the sidecar to fetch
// from the request-replayer and propagate the config to INI globals.
$deadline = microtime(true) + 20;
while (ini_get("datadog.trace.sample_rate") != 0.5 && microtime(true) < $deadline) {
usleep(100000);
}

var_dump(ini_get("datadog.trace.sample_rate"));
Expand Down
13 changes: 2 additions & 11 deletions tests/ext/request-replayer/dd_trace_agent_env.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,10 @@ datadog.trace.agent_test_session_token=dd_trace_agent_env
--FILE--
<?php

include __DIR__ . '/../includes/request_replayer.inc';

$rr = new RequestReplayer();
// Block until the sidecar has fetched /info from the agent so env is propagated
dd_trace_internal_fn('await_agent_info');

$span = \DDTrace\start_span();

// make sure sidecar keeps up with us
$start = microtime(true);
\DDTrace\start_trace_span();
\DDTrace\close_span();
$rr->waitForDataAndReplay();
usleep(floor(microtime(true) - $start) * 100000);

\DDTrace\close_span();
var_dump($span->env);

Expand Down
7 changes: 7 additions & 0 deletions tests/ext/telemetry/integration.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ namespace
var_dump($json["payload"]);
break 3;
}
// The integrations may also be bundled into the app-started payload
// depending on registration timing (see libdd-telemetry build_app_started).
if ($json["request_type"] == "app-started"
&& !empty($json["payload"]["integrations"])) {
var_dump(["integrations" => $json["payload"]["integrations"]]);
break 3;
}
}
}
}
Expand Down
Loading