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
This commit is contained in:
DanConwayDev
2026-09-24 06:50:16 +00:00
parent dbdb6edf4a
commit 25104a6e0d
2 changed files with 39 additions and 3 deletions
+21 -3
View File
@@ -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;
}
+18
View File
@@ -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"
));
}