From e3cc6a83f6426b9a31b6e4009d9f18597b4fe3be Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Tue, 24 Feb 2026 14:08:32 -0500 Subject: [PATCH 01/15] attempt to fix flaky test_asm_standalone.py tests --- tests/appsec/test_asm_standalone.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index be41d0ccd94..394c6399e39 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -190,9 +190,11 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self "x-datadog-tags": "_dd.p.other=1", }, ) + time.sleep(2) # Allow tracer to flush trace before scenario stops def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self): self.assert_product_is_enabled(self.check_r, self.tested_product) + interfaces.library.assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x < 2} From 3f1ba2e3a7289633f2c53e14d5524cf2db1e1631 Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Tue, 24 Feb 2026 14:51:15 -0500 Subject: [PATCH 02/15] apply flake fix to 'iast_standalone' scenario only --- tests/appsec/test_asm_standalone.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index 394c6399e39..7f4e8d1da50 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -190,11 +190,13 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self "x-datadog-tags": "_dd.p.other=1", }, ) - time.sleep(2) # Allow tracer to flush trace before scenario stops + if context.scenario == scenarios.iast_standalone: + time.sleep(2) # Allow tracer to flush trace before scenario stops def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self): self.assert_product_is_enabled(self.check_r, self.tested_product) - interfaces.library.assert_trace_exists(self.r) + if context.scenario == scenarios.iast_standalone: + interfaces.library.assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x < 2} From 626e309f9028e62924f43e64748dab4e5490a7c0 Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Tue, 24 Feb 2026 16:26:50 -0500 Subject: [PATCH 03/15] apply flake fix to the rest of IAST tests --- tests/appsec/test_asm_standalone.py | 31 +++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index 7f4e8d1da50..3ad21ce954c 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -112,6 +112,16 @@ def propagated_tag_value(self) -> str: def propagated_tag_and_value(self): return self.propagated_tag() + "=" + self.propagated_tag_value() + def _iast_standalone_wait_for_trace(self) -> None: + """Allow tracer to flush when in iast_standalone scenario (reduces flakiness).""" + if context.scenario == scenarios.iast_standalone: + time.sleep(2) + + def _iast_standalone_assert_trace_exists(self, request: HttpResponse) -> None: + """Assert trace exists when in iast_standalone scenario (clearer error messages).""" + if context.scenario == scenarios.iast_standalone: + interfaces.library.assert_trace_exists(request) + def setup_product_is_enabled(self, session: _Weblog): headers = {} if self.tested_product == "appsec": @@ -135,6 +145,7 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_minus_ "x-datadog-tags": "_dd.p.other=1", }, ) + self._iast_standalone_wait_for_trace() def fix_priority_lambda( self, span: DataDogLibrarySpan, default_checks: dict[str, str | Callable | None] @@ -148,6 +159,7 @@ def fix_priority_lambda( def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_minus_1(self): self.assert_product_is_enabled(self.check_r, self.tested_product) + self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x < 2} @@ -190,13 +202,11 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self "x-datadog-tags": "_dd.p.other=1", }, ) - if context.scenario == scenarios.iast_standalone: - time.sleep(2) # Allow tracer to flush trace before scenario stops + self._iast_standalone_wait_for_trace() def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self): self.assert_product_is_enabled(self.check_r, self.tested_product) - if context.scenario == scenarios.iast_standalone: - interfaces.library.assert_trace_exists(self.r) + self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x < 2} @@ -239,9 +249,11 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self "x-datadog-tags": "_dd.p.other=1", }, ) + self._iast_standalone_wait_for_trace() def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self): self.assert_product_is_enabled(self.check_r, self.tested_product) + self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x < 2} @@ -284,9 +296,11 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self "x-datadog-tags": "_dd.p.other=1", }, ) + self._iast_standalone_wait_for_trace() def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self): self.assert_product_is_enabled(self.check_r, self.tested_product) + self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x < 2} @@ -459,9 +473,11 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ "x-datadog-tags": self.propagated_tag_and_value(), }, ) + self._iast_standalone_wait_for_trace() def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_1(self): self.assert_product_is_enabled(self.check_r, self.tested_product) + self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x in [1, 2]} @@ -503,9 +519,11 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ "x-datadog-tags": self.propagated_tag_and_value(), }, ) + self._iast_standalone_wait_for_trace() def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_2(self): self.assert_product_is_enabled(self.check_r, self.tested_product) + self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -545,8 +563,10 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_m "User-Agent": "Arachni/v1", # attack if APPSEC enabled }, ) + self._iast_standalone_wait_for_trace() def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_minus_1(self): + self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -586,6 +606,7 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0 "User-Agent": "Arachni/v1", }, ) + self._iast_standalone_wait_for_trace() def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0(self): spans_checked = 0 @@ -627,8 +648,10 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1 "User-Agent": "Arachni/v1", # attack if APPSEC enabled }, ) + self._iast_standalone_wait_for_trace() def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1(self): + self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} From a51b836b309db432ae7f3355ab488bc14cf01e51 Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Tue, 24 Feb 2026 17:41:52 -0500 Subject: [PATCH 04/15] use deterministic polliing instead of a random sleep interval --- tests/appsec/test_asm_standalone.py | 46 +++++++++++++---------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index 3ad21ce954c..ed98d33b9b4 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -112,15 +112,17 @@ def propagated_tag_value(self) -> str: def propagated_tag_and_value(self): return self.propagated_tag() + "=" + self.propagated_tag_value() - def _iast_standalone_wait_for_trace(self) -> None: - """Allow tracer to flush when in iast_standalone scenario (reduces flakiness).""" - if context.scenario == scenarios.iast_standalone: - time.sleep(2) - - def _iast_standalone_assert_trace_exists(self, request: HttpResponse) -> None: - """Assert trace exists when in iast_standalone scenario (clearer error messages).""" - if context.scenario == scenarios.iast_standalone: - interfaces.library.assert_trace_exists(request) + def _iast_standalone_wait_for_trace(self, request: HttpResponse, timeout: float = 5.0) -> None: + """Wait until trace is captured (iast_standalone only). Reduces flakiness.""" + if context.scenario != scenarios.iast_standalone: + return + poll_interval = 0.5 + deadline = time.monotonic() + timeout + while time.monotonic() < deadline: + if list(interfaces.library.get_spans(request=request)): + return + time.sleep(poll_interval) + interfaces.library.assert_trace_exists(request) # Fails with clear error def setup_product_is_enabled(self, session: _Weblog): headers = {} @@ -145,7 +147,7 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_minus_ "x-datadog-tags": "_dd.p.other=1", }, ) - self._iast_standalone_wait_for_trace() + self._iast_standalone_wait_for_trace(self.r) def fix_priority_lambda( self, span: DataDogLibrarySpan, default_checks: dict[str, str | Callable | None] @@ -159,7 +161,6 @@ def fix_priority_lambda( def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_minus_1(self): self.assert_product_is_enabled(self.check_r, self.tested_product) - self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x < 2} @@ -202,11 +203,10 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self "x-datadog-tags": "_dd.p.other=1", }, ) - self._iast_standalone_wait_for_trace() + self._iast_standalone_wait_for_trace(self.r) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self): self.assert_product_is_enabled(self.check_r, self.tested_product) - self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x < 2} @@ -249,11 +249,10 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self "x-datadog-tags": "_dd.p.other=1", }, ) - self._iast_standalone_wait_for_trace() + self._iast_standalone_wait_for_trace(self.r) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self): self.assert_product_is_enabled(self.check_r, self.tested_product) - self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x < 2} @@ -296,11 +295,10 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self "x-datadog-tags": "_dd.p.other=1", }, ) - self._iast_standalone_wait_for_trace() + self._iast_standalone_wait_for_trace(self.r) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self): self.assert_product_is_enabled(self.check_r, self.tested_product) - self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x < 2} @@ -473,11 +471,10 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ "x-datadog-tags": self.propagated_tag_and_value(), }, ) - self._iast_standalone_wait_for_trace() + self._iast_standalone_wait_for_trace(self.r) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_1(self): self.assert_product_is_enabled(self.check_r, self.tested_product) - self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x in [1, 2]} @@ -519,11 +516,10 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ "x-datadog-tags": self.propagated_tag_and_value(), }, ) - self._iast_standalone_wait_for_trace() + self._iast_standalone_wait_for_trace(self.r) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_2(self): self.assert_product_is_enabled(self.check_r, self.tested_product) - self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -563,10 +559,9 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_m "User-Agent": "Arachni/v1", # attack if APPSEC enabled }, ) - self._iast_standalone_wait_for_trace() + self._iast_standalone_wait_for_trace(self.r) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_minus_1(self): - self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -606,7 +601,7 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0 "User-Agent": "Arachni/v1", }, ) - self._iast_standalone_wait_for_trace() + self._iast_standalone_wait_for_trace(self.r) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0(self): spans_checked = 0 @@ -648,10 +643,9 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1 "User-Agent": "Arachni/v1", # attack if APPSEC enabled }, ) - self._iast_standalone_wait_for_trace() + self._iast_standalone_wait_for_trace(self.r) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1(self): - self._iast_standalone_assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} From cfe879a8dada2c95627884c906207a7644466f32 Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Wed, 25 Feb 2026 12:55:01 -0500 Subject: [PATCH 05/15] types, rebase --- tests/appsec/test_asm_standalone.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index ed98d33b9b4..75f006033ce 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -116,8 +116,8 @@ def _iast_standalone_wait_for_trace(self, request: HttpResponse, timeout: float """Wait until trace is captured (iast_standalone only). Reduces flakiness.""" if context.scenario != scenarios.iast_standalone: return - poll_interval = 0.5 - deadline = time.monotonic() + timeout + poll_interval: float = 0.5 + deadline: float = time.monotonic() + timeout while time.monotonic() < deadline: if list(interfaces.library.get_spans(request=request)): return From d4f69239a18236c23dc7f2175b45da476dc90c17 Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Wed, 25 Feb 2026 15:02:18 -0500 Subject: [PATCH 06/15] unify approach, take 2 --- tests/appsec/test_asm_standalone.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index 75f006033ce..fbedc6ab03f 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -112,16 +112,38 @@ def propagated_tag_value(self) -> str: def propagated_tag_and_value(self): return self.propagated_tag() + "=" + self.propagated_tag_value() - def _iast_standalone_wait_for_trace(self, request: HttpResponse, timeout: float = 5.0) -> None: + def _iast_standalone_wait_for_trace(self, request: HttpResponse, timeout: float = 15.0) -> None: """Wait until trace is captured (iast_standalone only). Reduces flakiness.""" if context.scenario != scenarios.iast_standalone: return - poll_interval: float = 0.5 + rid: str = request.get_rid() + logger.info("IAST_STANDALONE: waiting for trace rid=%s (timeout=%.1fs)", rid, timeout) + poll_interval: float = 0.2 + time.sleep(0.5) # Give tracer time to flush before first poll deadline: float = time.monotonic() + timeout + poll_count: int = 0 while time.monotonic() < deadline: - if list(interfaces.library.get_spans(request=request)): + spans: list = list(interfaces.library.get_spans(request=request)) + if spans: + logger.info("IAST_STANDALONE: trace found for rid=%s after %d polls", rid, poll_count) return + poll_count += 1 + if poll_count <= 3 or poll_count % 25 == 0: # Log first 3 and every 5s + elapsed: float = time.monotonic() - (deadline - timeout) + logger.debug( + "IAST_STANDALONE: poll %d rid=%s after %.1fs, no spans yet", + poll_count, + rid, + elapsed, + ) time.sleep(poll_interval) + all_spans_count: int = len(list(interfaces.library.get_spans(request=None))) + logger.error( + "IAST_STANDALONE: timeout after %.1fs for rid=%s (total spans in library: %d)", + timeout, + rid, + all_spans_count, + ) interfaces.library.assert_trace_exists(request) # Fails with clear error def setup_product_is_enabled(self, session: _Weblog): From 89775d8c83fc37dfae50b496d4e8a38e91f9fb3b Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Wed, 25 Feb 2026 20:53:42 -0500 Subject: [PATCH 07/15] change comment to trigger CI --- tests/appsec/test_asm_standalone.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index fbedc6ab03f..e705f528919 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -113,7 +113,7 @@ def propagated_tag_and_value(self): return self.propagated_tag() + "=" + self.propagated_tag_value() def _iast_standalone_wait_for_trace(self, request: HttpResponse, timeout: float = 15.0) -> None: - """Wait until trace is captured (iast_standalone only). Reduces flakiness.""" + """Wait until trace is captured (iast_standalone only) to reduce flakiness.""" if context.scenario != scenarios.iast_standalone: return rid: str = request.get_rid() From 3631653c2ce4a88561c68df38c895777b212ac5d Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Thu, 26 Feb 2026 09:36:50 -0500 Subject: [PATCH 08/15] move interfaces.library.assert_trace_exists(request) to individual tests from their setup funcs --- tests/appsec/test_asm_standalone.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index e705f528919..24f77e5531a 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -144,7 +144,6 @@ def _iast_standalone_wait_for_trace(self, request: HttpResponse, timeout: float rid, all_spans_count, ) - interfaces.library.assert_trace_exists(request) # Fails with clear error def setup_product_is_enabled(self, session: _Weblog): headers = {} @@ -182,6 +181,7 @@ def fix_priority_lambda( return default_checks def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_minus_1(self): + interfaces.library.assert_trace_exists(self.r) self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -228,6 +228,7 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self self._iast_standalone_wait_for_trace(self.r) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self): + interfaces.library.assert_trace_exists(self.r) self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -274,6 +275,7 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self self._iast_standalone_wait_for_trace(self.r) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self): + interfaces.library.assert_trace_exists(self.r) self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -320,6 +322,7 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self self._iast_standalone_wait_for_trace(self.r) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self): + interfaces.library.assert_trace_exists(self.r) self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -496,6 +499,7 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ self._iast_standalone_wait_for_trace(self.r) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_1(self): + interfaces.library.assert_trace_exists(self.r) self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} @@ -541,6 +545,7 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ self._iast_standalone_wait_for_trace(self.r) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_2(self): + interfaces.library.assert_trace_exists(self.r) self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} @@ -584,6 +589,7 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_m self._iast_standalone_wait_for_trace(self.r) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_minus_1(self): + interfaces.library.assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -626,6 +632,7 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0 self._iast_standalone_wait_for_trace(self.r) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0(self): + interfaces.library.assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -668,6 +675,7 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1 self._iast_standalone_wait_for_trace(self.r) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1(self): + interfaces.library.assert_trace_exists(self.r) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} From 9b60e2ff0d3d1f308826bedfc9ffb798c354f181 Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Thu, 26 Feb 2026 11:28:01 -0500 Subject: [PATCH 09/15] gate trace assertion for IAST scenarios only --- tests/appsec/test_asm_standalone.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index 24f77e5531a..3afb0650b8a 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -145,6 +145,10 @@ def _iast_standalone_wait_for_trace(self, request: HttpResponse, timeout: float all_spans_count, ) + def _iast_assert_trace_exists(self) -> None: + if context.scenario == scenarios.iast_standalone: + interfaces.library.assert_trace_exists(self.r) + def setup_product_is_enabled(self, session: _Weblog): headers = {} if self.tested_product == "appsec": @@ -181,7 +185,7 @@ def fix_priority_lambda( return default_checks def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_minus_1(self): - interfaces.library.assert_trace_exists(self.r) + self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -228,7 +232,7 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self self._iast_standalone_wait_for_trace(self.r) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self): - interfaces.library.assert_trace_exists(self.r) + self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -275,7 +279,7 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self self._iast_standalone_wait_for_trace(self.r) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self): - interfaces.library.assert_trace_exists(self.r) + self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -322,7 +326,7 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self self._iast_standalone_wait_for_trace(self.r) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self): - interfaces.library.assert_trace_exists(self.r) + self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -499,7 +503,7 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ self._iast_standalone_wait_for_trace(self.r) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_1(self): - interfaces.library.assert_trace_exists(self.r) + self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} @@ -545,7 +549,7 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ self._iast_standalone_wait_for_trace(self.r) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_2(self): - interfaces.library.assert_trace_exists(self.r) + self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} @@ -589,7 +593,7 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_m self._iast_standalone_wait_for_trace(self.r) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_minus_1(self): - interfaces.library.assert_trace_exists(self.r) + self._iast_assert_trace_exists() spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -632,7 +636,7 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0 self._iast_standalone_wait_for_trace(self.r) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0(self): - interfaces.library.assert_trace_exists(self.r) + self._iast_assert_trace_exists() spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -675,7 +679,7 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1 self._iast_standalone_wait_for_trace(self.r) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1(self): - interfaces.library.assert_trace_exists(self.r) + self._iast_assert_trace_exists() spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} From 973e2815f5b507fae74efcb704351532e0879988 Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Fri, 27 Feb 2026 08:58:23 -0500 Subject: [PATCH 10/15] Replace custom 'wait_for' function with a global interface timeout --- tests/appsec/test_asm_standalone.py | 42 --------------------------- utils/_context/_scenarios/__init__.py | 1 + 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index 3afb0650b8a..32fb1302869 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -112,39 +112,6 @@ def propagated_tag_value(self) -> str: def propagated_tag_and_value(self): return self.propagated_tag() + "=" + self.propagated_tag_value() - def _iast_standalone_wait_for_trace(self, request: HttpResponse, timeout: float = 15.0) -> None: - """Wait until trace is captured (iast_standalone only) to reduce flakiness.""" - if context.scenario != scenarios.iast_standalone: - return - rid: str = request.get_rid() - logger.info("IAST_STANDALONE: waiting for trace rid=%s (timeout=%.1fs)", rid, timeout) - poll_interval: float = 0.2 - time.sleep(0.5) # Give tracer time to flush before first poll - deadline: float = time.monotonic() + timeout - poll_count: int = 0 - while time.monotonic() < deadline: - spans: list = list(interfaces.library.get_spans(request=request)) - if spans: - logger.info("IAST_STANDALONE: trace found for rid=%s after %d polls", rid, poll_count) - return - poll_count += 1 - if poll_count <= 3 or poll_count % 25 == 0: # Log first 3 and every 5s - elapsed: float = time.monotonic() - (deadline - timeout) - logger.debug( - "IAST_STANDALONE: poll %d rid=%s after %.1fs, no spans yet", - poll_count, - rid, - elapsed, - ) - time.sleep(poll_interval) - all_spans_count: int = len(list(interfaces.library.get_spans(request=None))) - logger.error( - "IAST_STANDALONE: timeout after %.1fs for rid=%s (total spans in library: %d)", - timeout, - rid, - all_spans_count, - ) - def _iast_assert_trace_exists(self) -> None: if context.scenario == scenarios.iast_standalone: interfaces.library.assert_trace_exists(self.r) @@ -172,7 +139,6 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_minus_ "x-datadog-tags": "_dd.p.other=1", }, ) - self._iast_standalone_wait_for_trace(self.r) def fix_priority_lambda( self, span: DataDogLibrarySpan, default_checks: dict[str, str | Callable | None] @@ -229,7 +195,6 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self "x-datadog-tags": "_dd.p.other=1", }, ) - self._iast_standalone_wait_for_trace(self.r) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self): self._iast_assert_trace_exists() @@ -276,7 +241,6 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self "x-datadog-tags": "_dd.p.other=1", }, ) - self._iast_standalone_wait_for_trace(self.r) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self): self._iast_assert_trace_exists() @@ -323,7 +287,6 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self "x-datadog-tags": "_dd.p.other=1", }, ) - self._iast_standalone_wait_for_trace(self.r) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self): self._iast_assert_trace_exists() @@ -500,7 +463,6 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ "x-datadog-tags": self.propagated_tag_and_value(), }, ) - self._iast_standalone_wait_for_trace(self.r) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_1(self): self._iast_assert_trace_exists() @@ -546,7 +508,6 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ "x-datadog-tags": self.propagated_tag_and_value(), }, ) - self._iast_standalone_wait_for_trace(self.r) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_2(self): self._iast_assert_trace_exists() @@ -590,7 +551,6 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_m "User-Agent": "Arachni/v1", # attack if APPSEC enabled }, ) - self._iast_standalone_wait_for_trace(self.r) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_minus_1(self): self._iast_assert_trace_exists() @@ -633,7 +593,6 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0 "User-Agent": "Arachni/v1", }, ) - self._iast_standalone_wait_for_trace(self.r) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0(self): self._iast_assert_trace_exists() @@ -676,7 +635,6 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1 "User-Agent": "Arachni/v1", # attack if APPSEC enabled }, ) - self._iast_standalone_wait_for_trace(self.r) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1(self): self._iast_assert_trace_exists() diff --git a/utils/_context/_scenarios/__init__.py b/utils/_context/_scenarios/__init__.py index ca1e06a7e9b..a3bc38f0bf4 100644 --- a/utils/_context/_scenarios/__init__.py +++ b/utils/_context/_scenarios/__init__.py @@ -450,6 +450,7 @@ class _Scenarios: }, doc="Source code vulnerability standalone mode (APM opt out)", scenario_groups=[scenario_groups.appsec], + library_interface_timeout=15, # 15 sec: time for tracer to flush traces before weblog shutdown ) sca_standalone = EndToEndScenario( From f5497b3e1e1a414ba1dce280753a1a92e1ab988b Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Fri, 27 Feb 2026 10:14:50 -0500 Subject: [PATCH 11/15] Increase timeout for a DOTNET test --- tests/debugger/test_debugger_telemetry.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/debugger/test_debugger_telemetry.py b/tests/debugger/test_debugger_telemetry.py index d3605db9473..756b71f60a7 100644 --- a/tests/debugger/test_debugger_telemetry.py +++ b/tests/debugger/test_debugger_telemetry.py @@ -24,11 +24,14 @@ def _setup(self): if not Test_Debugger_Telemetry.telemetry_data: telemetry_type = "app-started" + timeout = 5 if self.get_tracer()["language"] == "dotnet": telemetry_type = "app-client-configuration-change" + # Dotnet needs more time: RC fetch + apply + send app-client-configuration-change + timeout = 15 - Test_Debugger_Telemetry.telemetry_data = self.wait_for_telemetry(telemetry_type) + Test_Debugger_Telemetry.telemetry_data = self.wait_for_telemetry(telemetry_type, timeout=timeout) self.telemetry = Test_Debugger_Telemetry.telemetry_data From 1d9d07446c229022224ae2e552ce3368d2650393 Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Fri, 27 Feb 2026 12:29:08 -0500 Subject: [PATCH 12/15] Increase timeout from 15 to 25 sec --- utils/_context/_scenarios/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/_context/_scenarios/__init__.py b/utils/_context/_scenarios/__init__.py index a3bc38f0bf4..527c94b282a 100644 --- a/utils/_context/_scenarios/__init__.py +++ b/utils/_context/_scenarios/__init__.py @@ -450,7 +450,7 @@ class _Scenarios: }, doc="Source code vulnerability standalone mode (APM opt out)", scenario_groups=[scenario_groups.appsec], - library_interface_timeout=15, # 15 sec: time for tracer to flush traces before weblog shutdown + library_interface_timeout=25, # 25 sec: time for tracer to flush traces before weblog shutdown (reduced flakes) ) sca_standalone = EndToEndScenario( From 3184b1c99432c86bc3a2b0bf00e7fab67d580085 Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Fri, 27 Feb 2026 16:50:40 -0500 Subject: [PATCH 13/15] removed non-waiting IAST trace pre-check --- tests/appsec/test_asm_standalone.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index 32fb1302869..be41d0ccd94 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -112,10 +112,6 @@ def propagated_tag_value(self) -> str: def propagated_tag_and_value(self): return self.propagated_tag() + "=" + self.propagated_tag_value() - def _iast_assert_trace_exists(self) -> None: - if context.scenario == scenarios.iast_standalone: - interfaces.library.assert_trace_exists(self.r) - def setup_product_is_enabled(self, session: _Weblog): headers = {} if self.tested_product == "appsec": @@ -151,7 +147,6 @@ def fix_priority_lambda( return default_checks def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_minus_1(self): - self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -197,7 +192,6 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self ) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self): - self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -243,7 +237,6 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self ) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self): - self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -289,7 +282,6 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self ) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self): - self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -465,7 +457,6 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ ) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_1(self): - self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} @@ -510,7 +501,6 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ ) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_2(self): - self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} @@ -553,7 +543,6 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_m ) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_minus_1(self): - self._iast_assert_trace_exists() spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -595,7 +584,6 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0 ) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0(self): - self._iast_assert_trace_exists() spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -637,7 +625,6 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1 ) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1(self): - self._iast_assert_trace_exists() spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} From 4b11b29967d46212ea9f10281b69b020429fa163 Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Thu, 5 Mar 2026 12:10:02 -0500 Subject: [PATCH 14/15] Fix mixed up changes --- tests/appsec/test_asm_standalone.py | 13 +++++++++++++ tests/debugger/test_debugger_telemetry.py | 5 +---- utils/_context/_scenarios/__init__.py | 1 - 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index be41d0ccd94..32fb1302869 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -112,6 +112,10 @@ def propagated_tag_value(self) -> str: def propagated_tag_and_value(self): return self.propagated_tag() + "=" + self.propagated_tag_value() + def _iast_assert_trace_exists(self) -> None: + if context.scenario == scenarios.iast_standalone: + interfaces.library.assert_trace_exists(self.r) + def setup_product_is_enabled(self, session: _Weblog): headers = {} if self.tested_product == "appsec": @@ -147,6 +151,7 @@ def fix_priority_lambda( return default_checks def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_minus_1(self): + self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -192,6 +197,7 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self ) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self): + self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -237,6 +243,7 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self ) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self): + self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -282,6 +289,7 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self ) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self): + self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -457,6 +465,7 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ ) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_1(self): + self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} @@ -501,6 +510,7 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ ) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_2(self): + self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} @@ -543,6 +553,7 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_m ) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_minus_1(self): + self._iast_assert_trace_exists() spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -584,6 +595,7 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0 ) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0(self): + self._iast_assert_trace_exists() spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -625,6 +637,7 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1 ) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1(self): + self._iast_assert_trace_exists() spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} diff --git a/tests/debugger/test_debugger_telemetry.py b/tests/debugger/test_debugger_telemetry.py index 756b71f60a7..d3605db9473 100644 --- a/tests/debugger/test_debugger_telemetry.py +++ b/tests/debugger/test_debugger_telemetry.py @@ -24,14 +24,11 @@ def _setup(self): if not Test_Debugger_Telemetry.telemetry_data: telemetry_type = "app-started" - timeout = 5 if self.get_tracer()["language"] == "dotnet": telemetry_type = "app-client-configuration-change" - # Dotnet needs more time: RC fetch + apply + send app-client-configuration-change - timeout = 15 - Test_Debugger_Telemetry.telemetry_data = self.wait_for_telemetry(telemetry_type, timeout=timeout) + Test_Debugger_Telemetry.telemetry_data = self.wait_for_telemetry(telemetry_type) self.telemetry = Test_Debugger_Telemetry.telemetry_data diff --git a/utils/_context/_scenarios/__init__.py b/utils/_context/_scenarios/__init__.py index 527c94b282a..ca1e06a7e9b 100644 --- a/utils/_context/_scenarios/__init__.py +++ b/utils/_context/_scenarios/__init__.py @@ -450,7 +450,6 @@ class _Scenarios: }, doc="Source code vulnerability standalone mode (APM opt out)", scenario_groups=[scenario_groups.appsec], - library_interface_timeout=25, # 25 sec: time for tracer to flush traces before weblog shutdown (reduced flakes) ) sca_standalone = EndToEndScenario( From 3ee5156acbe33624a80e30dfc37f9b12bfb9eac7 Mon Sep 17 00:00:00 2001 From: Vlad Scherbich Date: Thu, 5 Mar 2026 12:15:02 -0500 Subject: [PATCH 15/15] Restore proper fix for these tests --- tests/appsec/test_asm_standalone.py | 13 ------------- utils/_context/_scenarios/__init__.py | 1 + 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/tests/appsec/test_asm_standalone.py b/tests/appsec/test_asm_standalone.py index 32fb1302869..be41d0ccd94 100644 --- a/tests/appsec/test_asm_standalone.py +++ b/tests/appsec/test_asm_standalone.py @@ -112,10 +112,6 @@ def propagated_tag_value(self) -> str: def propagated_tag_and_value(self): return self.propagated_tag() + "=" + self.propagated_tag_value() - def _iast_assert_trace_exists(self) -> None: - if context.scenario == scenarios.iast_standalone: - interfaces.library.assert_trace_exists(self.r) - def setup_product_is_enabled(self, session: _Weblog): headers = {} if self.tested_product == "appsec": @@ -151,7 +147,6 @@ def fix_priority_lambda( return default_checks def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_minus_1(self): - self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -197,7 +192,6 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self ) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_0(self): - self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -243,7 +237,6 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self ) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_1(self): - self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -289,7 +282,6 @@ def setup_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self ) def test_no_appsec_upstream__no_asm_event__is_kept_with_priority_1__from_2(self): - self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): None, "_dd.p.other": "1"} @@ -465,7 +457,6 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ ) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_1(self): - self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} @@ -510,7 +501,6 @@ def setup_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_ ) def test_upstream_appsec_propagation__no_asm_event__is_propagated_as_is__being_2(self): - self._iast_assert_trace_exists() self.assert_product_is_enabled(self.check_r, self.tested_product) spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} @@ -553,7 +543,6 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_m ) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_minus_1(self): - self._iast_assert_trace_exists() spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -595,7 +584,6 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0 ) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_0(self): - self._iast_assert_trace_exists() spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} @@ -637,7 +625,6 @@ def setup_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1 ) def test_any_upstream_propagation__with_asm_event__raises_priority_to_2__from_1(self): - self._iast_assert_trace_exists() spans_checked = 0 tested_meta: dict[str, str | Callable | None] = {self.propagated_tag(): self.propagated_tag_value()} tested_metrics: dict[str, str | Callable | None] = {SAMPLING_PRIORITY_KEY: lambda x: x == 2} diff --git a/utils/_context/_scenarios/__init__.py b/utils/_context/_scenarios/__init__.py index ca1e06a7e9b..527c94b282a 100644 --- a/utils/_context/_scenarios/__init__.py +++ b/utils/_context/_scenarios/__init__.py @@ -450,6 +450,7 @@ class _Scenarios: }, doc="Source code vulnerability standalone mode (APM opt out)", scenario_groups=[scenario_groups.appsec], + library_interface_timeout=25, # 25 sec: time for tracer to flush traces before weblog shutdown (reduced flakes) ) sca_standalone = EndToEndScenario(