From 82c28b323a613ed86425e9011117b2fa82581beb Mon Sep 17 00:00:00 2001 From: Rob Carlan Date: Tue, 24 Mar 2026 16:29:31 -0400 Subject: [PATCH 1/2] java(dsm): fix flaky Test_Dsm_Manual_Checkpoint_Inter_Process by waiting for DSM data The Java tracer does not flush DSM stats immediately (unlike Python which calls flush_dsm_checkpoints()), relying instead on periodic flush. The assert_checkpoint_presence helper did a single pass through collected data with no retry, so it would miss checkpoints that hadn't been flushed yet. Add wait_for() to assert_checkpoint_presence so it waits up to 30s for matching DSM data to arrive before asserting. This uses the existing event-driven wait mechanism in ProxyBasedInterfaceValidator. Remove the flaky marking from manifests/java.yml (DSMON-1257). Co-Authored-By: Claude Opus 4.6 (1M context) --- manifests/java.yml | 3 --- tests/integrations/test_dsm.py | 26 +++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/manifests/java.yml b/manifests/java.yml index 33321a6fdba..de25fa48001 100644 --- a/manifests/java.yml +++ b/manifests/java.yml @@ -3425,9 +3425,6 @@ manifest: - weblog_declaration: "*": irrelevant spring-boot: v1.60.1 - tests/integrations/test_dsm.py::Test_Dsm_Manual_Checkpoint_Inter_Process::test_dsm_manual_checkpoint_inter_process: - - weblog_declaration: - spring-boot: flaky (DSMON-1257) tests/integrations/test_dsm.py::Test_Dsm_Manual_Checkpoint_Intra_Process: - weblog_declaration: "*": irrelevant diff --git a/tests/integrations/test_dsm.py b/tests/integrations/test_dsm.py index 9253a5d6876..7a2765f14ff 100644 --- a/tests/integrations/test_dsm.py +++ b/tests/integrations/test_dsm.py @@ -616,11 +616,35 @@ def is_tags_included(actual_tags: tuple, expected_tags: tuple) -> bool: return all(expected_tag in actual_tags for expected_tag in expected_tags) @staticmethod - def assert_checkpoint_presence(hash_: int, parent_hash: int, tags: tuple) -> None: + def _data_contains_checkpoint(data: dict, hash_: int, parent_hash: int, tags: tuple) -> bool: + """Check if a single agent data payload contains the expected DSM checkpoint.""" + for stats_bucket in data.get("request", {}).get("content", {}).get("Stats", {}): + for stats_point in stats_bucket.get("Stats", {}): + if ( + stats_point["Hash"] == hash_ + and stats_point["ParentHash"] == parent_hash + and DsmHelper.is_tags_included(tuple(stats_point["EdgeTags"]), tags) + ): + return True + return False + + @staticmethod + def assert_checkpoint_presence(hash_: int, parent_hash: int, tags: tuple, timeout: int = 30) -> None: assert isinstance(tags, tuple) logger.info(f"Look for {hash_}, {parent_hash}, {tags}") + def _matches(data): + if data.get("path") != "/api/v0.1/pipeline_stats": + return False + return DsmHelper._data_contains_checkpoint(data, hash_, parent_hash, tags) + + # Wait for matching DSM data to arrive (checks existing data first, then + # listens for new data up to timeout). This is needed because some tracers + # (e.g. Java) do not flush DSM stats immediately and rely on periodic flush. + interfaces.agent.wait_for(_matches, timeout) + + # Final verification pass with detailed logging for data in interfaces.agent.get_dsm_data(): # some tracers may send separate payloads with stats # or backlogs so "Stats" may be empty From 5d0db5336d175523d9965ea824eca5c70e14c974 Mon Sep 17 00:00:00 2001 From: Rob Carlan Date: Tue, 24 Mar 2026 17:03:38 -0400 Subject: [PATCH 2/2] fix: add type annotation to _matches closure Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/integrations/test_dsm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integrations/test_dsm.py b/tests/integrations/test_dsm.py index 7a2765f14ff..1c533cd92e9 100644 --- a/tests/integrations/test_dsm.py +++ b/tests/integrations/test_dsm.py @@ -634,7 +634,7 @@ def assert_checkpoint_presence(hash_: int, parent_hash: int, tags: tuple, timeou logger.info(f"Look for {hash_}, {parent_hash}, {tags}") - def _matches(data): + def _matches(data: dict) -> bool: if data.get("path") != "/api/v0.1/pipeline_stats": return False return DsmHelper._data_contains_checkpoint(data, hash_, parent_hash, tags)