From 25104a6e0df97785b4cf5ec597f9858100850055 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 24 Sep 2026 06:45:35 +0000 Subject: [PATCH] test(sync): correlate live coverage readiness by relay The live metrics test timed out although its captured log showed full-repo coverage installed. A subsequent update for the local relay moved rfind past that installation, so the helper could never observe readiness. Track full-repo updates by relay while scanning the log and accept a later installation only for that relay. Preserve the existing bounded deadline. This assumes the current structured log fields remain available and checks initial installation, not continued liveness. Production behavior is unchanged. Validation: a regression covers unrelated installation, a later local-relay update, and installation preceding promotion. The full sync suite passes 114 tests with one ignored; strict all-target Clippy and formatting pass. The original failed-test log is retained with the investigation evidence. Assisted-by: GPT-6 --- tests/common/sync_helpers.rs | 24 +++++++++++++++++++++--- tests/sync/metrics.rs | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/tests/common/sync_helpers.rs b/tests/common/sync_helpers.rs index 53b398e..51ed5f2 100644 --- a/tests/common/sync_helpers.rs +++ b/tests/common/sync_helpers.rs @@ -45,13 +45,31 @@ pub async fn wait_for_new_descendant_live_generation( } } +/// Correlate installed coverage with the relay whose repository was promoted. +pub fn has_full_repo_live_coverage(log: &str) -> bool { + let mut pending = std::collections::HashSet::new(); + for line in log.lines() { + let Some(relay) = line + .split_whitespace() + .find_map(|field| field.strip_prefix("relay=")) + else { + continue; + }; + if line.contains("new_full_repos=1") { + pending.insert(relay); + } + if line.contains("Extended core live coverage") && pending.contains(relay) { + return true; + } + } + false +} + pub async fn wait_for_full_repo_live_coverage(relay: &TestRelay, timeout: Duration) { let deadline = tokio::time::Instant::now() + timeout; loop { let log = std::fs::read_to_string(relay.log_path()).unwrap_or_default(); - let installed = log - .rfind("new_full_repos=1") - .is_some_and(|offset| log[offset..].contains("Extended core live coverage")); + let installed = has_full_repo_live_coverage(&log); if installed { return; } diff --git a/tests/sync/metrics.rs b/tests/sync/metrics.rs index 936d5ed..885b203 100644 --- a/tests/sync/metrics.rs +++ b/tests/sync/metrics.rs @@ -679,3 +679,21 @@ async fn test_multi_source_aggregate_counts() { harness.stop_all().await; } + +#[test] +fn full_repo_readiness_correlates_installation_with_its_relay() { + use crate::common::sync_helpers::has_full_repo_live_coverage; + + let pending = "Processing AddFilters relay=ws://source new_full_repos=1\n"; + assert!(!has_full_repo_live_coverage(&format!( + "{pending}Extended core live coverage relay=ws://unrelated\n" + ))); + assert!(has_full_repo_live_coverage(&format!( + "{pending}Extended core live coverage relay=ws://source\n\ + Processing AddFilters relay=ws://self new_full_repos=1\n" + ))); + assert!(!has_full_repo_live_coverage( + "Extended core live coverage relay=ws://source\n\ + Processing AddFilters relay=ws://source new_full_repos=1\n" + )); +}