Skip to content

Commit 92d3d15

Browse files
committed
Propagate agent configured timeout to sidecar
And make two RC tests more resilient to race conditions
1 parent bffd346 commit 92d3d15

7 files changed

Lines changed: 16 additions & 9 deletions

File tree

Cargo.lock

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ TRACER_SOURCES_INI := -d datadog.trace.sources_path=$(TRACER_SOURCE_DIR)
4444
RUN_TESTS_IS_PARALLEL ?= $(shell test $(PHP_MAJOR_MINOR) -ge 74 && echo 1)
4545

4646
# shuffle parallel tests to evenly distribute test load, avoiding a batch of 32 tests being request-replayer tests
47-
RUN_TESTS_CMD := DD_SERVICE= DD_ENV= DD_TRACE_RETRY_INTERVAL=1 REPORT_EXIT_STATUS=1 TEST_PHP_SRCDIR=$(PROJECT_ROOT) USE_TRACKED_ALLOC=1 php -n -d 'memory_limit=-1' $(BUILD_DIR)/run-tests.php $(if $(QUIET_TESTS),,-g FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP) $(if $(ASAN), --asan) --show-diff -n -p $(shell which php) -q $(if $(RUN_TESTS_IS_PARALLEL), --shuffle -j$(MAX_TEST_PARALLELISM))
47+
RUN_TESTS_CMD := DD_SERVICE= DD_ENV= DD_TRACE_RETRY_INTERVAL=1 DD_TRACE_AGENT_TIMEOUT=5000 REPORT_EXIT_STATUS=1 TEST_PHP_SRCDIR=$(PROJECT_ROOT) USE_TRACKED_ALLOC=1 php -n -d 'memory_limit=-1' $(BUILD_DIR)/run-tests.php $(if $(QUIET_TESTS),,-g FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP) $(if $(ASAN), --asan) --show-diff -n -p $(shell which php) -q $(if $(RUN_TESTS_IS_PARALLEL), --shuffle -j$(MAX_TEST_PARALLELISM))
4848

4949
C_FILES = $(shell find components components-rs ext src/dogstatsd tracer zend_abstract_interface -name '*.c' -o -name '*.h' | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' )
5050
TEST_FILES = $(shell find tests/ext -name '*.php*' -o -name '*.inc' -o -name '*.json' -o -name '*.yaml' -o -name 'CONFLICTS' | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' )

ext/sidecar.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ ddog_Endpoint *datadog_sidecar_agent_endpoint(void) {
616616

617617
if (agent_endpoint) {
618618
dd_set_endpoint_test_token(agent_endpoint);
619+
ddog_endpoint_set_timeout(agent_endpoint, get_global_DD_TRACE_AGENT_TIMEOUT());
619620
}
620621

621622
return agent_endpoint;

tests/ext/remote_config/dynamic_config_multiconfig.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ $specific_path = put_dynamic_config_file([
3232
]);
3333

3434
dd_trace_internal_fn("await_remote_config");
35+
if (ini_get("datadog.trace.sample_rate") == "0.3") { // possible race condition, just re-poll
36+
dd_trace_internal_fn("await_remote_config");
37+
}
3538

3639
// Specific config wins for sample_rate; org-level provides log_injection.
3740
print "After both configs:\n";

tests/ext/remote_config/rc_fork_notify.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ DD_TRACE_AGENT_TEST_SESSION_TOKEN=remote-config/rc_fork_notify
1515
--FILE--
1616
<?php
1717

18-
if (!pcntl_fork()) {
18+
if ($child = !pcntl_fork()) {
1919
require __DIR__ . "/remote_config.inc";
2020
put_dynamic_config_file(["tracing_enabled" => true]);
2121
}
@@ -24,6 +24,10 @@ if (!ini_get("datadog.trace.enabled")) {
2424
dd_trace_internal_fn("await_remote_config");
2525
}
2626

27+
if (!$child) {
28+
pcntl_wait($status);
29+
}
30+
2731
print ini_get("datadog.trace.enabled");
2832

2933
?>

tests/ext/request-replayer/dd_trace_agent_env.phpt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ $rr = new RequestReplayer();
3737
$span = \DDTrace\start_span();
3838

3939
// make sure sidecar keeps up with us
40-
$start = microtime(true);
41-
\DDTrace\start_trace_span();
42-
\DDTrace\close_span();
43-
$rr->waitForDataAndReplay();
44-
usleep(floor(microtime(true) - $start) * 100000);
40+
dd_trace_internal_fn('await_agent_info');
4541

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

tests/ext/telemetry/config.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ DD_TRACE_AUTOFINISH_SPANS=1
1919
DD_INSTRUMENTATION_TELEMETRY_ENABLED=1
2020
DD_AGENT_HOST=
2121
DD_AUTOLOAD_NO_COMPILE=
22+
DD_TRACE_AGENT_TIMEOUT=
2223
DD_TRACE_RETRY_INTERVAL=
2324
DD_TRACE_GIT_METADATA_ENABLED=0
2425
DD_TRACE_IGNORE_AGENT_SAMPLING_RATES=1

0 commit comments

Comments
 (0)