diff --git a/.gitlab/generate-tracer.php b/.gitlab/generate-tracer.php index 42510ff8ce..ad0b8df75d 100644 --- a/.gitlab/generate-tracer.php +++ b/.gitlab/generate-tracer.php @@ -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 @@ -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: "" @@ -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: "" diff --git a/.gitlab/wait-for-service-ready.sh b/.gitlab/wait-for-service-ready.sh index 45ee96399d..2359920632 100755 --- a/.gitlab/wait-for-service-ready.sh +++ b/.gitlab/wait-for-service-ready.sh @@ -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" ;; @@ -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" diff --git a/Makefile b/Makefile index 1d017c7308..a3758cf921 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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 diff --git a/tests/ext/remote_config/dynamic_config_update.phpt b/tests/ext/remote_config/dynamic_config_update.phpt index 48be3ca6ad..ed7902f5db 100644 --- a/tests/ext/remote_config/dynamic_config_update.phpt +++ b/tests/ext/remote_config/dynamic_config_update.phpt @@ -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")); diff --git a/tests/ext/request-replayer/dd_trace_agent_env.phpt b/tests/ext/request-replayer/dd_trace_agent_env.phpt index 50de644e70..036d09f8f3 100644 --- a/tests/ext/request-replayer/dd_trace_agent_env.phpt +++ b/tests/ext/request-replayer/dd_trace_agent_env.phpt @@ -30,19 +30,10 @@ datadog.trace.agent_test_session_token=dd_trace_agent_env --FILE-- waitForDataAndReplay(); -usleep(floor(microtime(true) - $start) * 100000); - \DDTrace\close_span(); var_dump($span->env); diff --git a/tests/ext/telemetry/integration.phpt b/tests/ext/telemetry/integration.phpt index 8e74be2293..b5ee5aea92 100644 --- a/tests/ext/telemetry/integration.phpt +++ b/tests/ext/telemetry/integration.phpt @@ -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; + } } } }