Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/scripts/test_nightly_rust_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ def test_all_live_shards_have_stable_flags_and_owned_packages(self) -> None:
str(entry["name"] == "platform").lower(),
)

def test_target_dir_is_absolute_for_tests_that_run_in_crate_dirs(self) -> None:
# Cargo runs each test with its crate directory as the working
# directory, so a relative CARGO_TARGET_DIR points tests that create
# scratch space under it at a directory that does not exist.
workflow = WORKFLOW.read_text(encoding="utf-8")
target = re.search(r"^ CARGO_TARGET_DIR: (.+)$", workflow, re.M)
self.assertIsNotNone(target)
self.assertTrue(target.group(1).startswith("${{ github.workspace }}/"))

def test_plan_validates_locked_metadata_and_appends_github_output(self) -> None:
with tempfile.TemporaryDirectory() as directory:
output = Path(directory) / "output"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-rust-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
max-parallel: 4
matrix: ${{ fromJSON(needs.plan.outputs.matrix) }}
env:
CARGO_TARGET_DIR: target/nightly-rust-coverage
CARGO_TARGET_DIR: ${{ github.workspace }}/target/nightly-rust-coverage
COVERAGE_ALL_FEATURES: ${{ matrix.all_features }}
COVERAGE_FEATURES: ${{ matrix.features }}
COVERAGE_PACKAGES: ${{ matrix.packages }}
Expand Down
12 changes: 12 additions & 0 deletions crates/registry-breg/tests/postgres_record_timer_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,18 @@ async fn removed_timer_fences_predecessor_process(
harness
.wait_replica_unready(predecessor, Duration::from_secs(10))
.await?;
// Readiness already refuses once the successor is active, before the
// parked worker resumes. The worker writes its fenced-iteration warning
// only after it leaves the checkpoint, so wait for that line: it proves
// the predecessor resumed and was fenced before the unchanged-lease check
// below, and the crash cannot cut it off.
harness
.wait_for_log_code(
predecessor,
"record_timer.worker.iteration_failed",
Duration::from_secs(10),
)
.await?;
harness.expect_non_info_code_range(
predecessor,
"record_timer.worker.iteration_failed",
Expand Down
19 changes: 19 additions & 0 deletions crates/registry-breg/tests/postgres_record_timer_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,16 @@ async fn operator_retry_after_actual_exhaustion(
}
}
harness.expect_non_info_code(owner, "record_timer.worker.iteration_failed", 5)?;
// Each warning follows its attempt's commit, so the fifth attempt can be
// visible before its warning is written; the crash must not cut it off.
harness
.wait_for_log_code_count(
owner,
"record_timer.worker.iteration_failed",
5,
Duration::from_secs(5),
)
.await?;
harness.crash_all_replicas()?;

let operator_config = harness.write_operator_runtime_config("actual-retry")?;
Expand Down Expand Up @@ -1243,6 +1253,15 @@ async fn operator_retry_after_actual_exhaustion(
let blocked =
wait_for_technical_attempt_count(harness, &record_id, 6, Duration::from_secs(8)).await?;
harness.expect_non_info_code(retry_owner, "record_timer.worker.iteration_failed", 1)?;
// The warning follows the commit that made attempt six visible, and the
// replica stops at cleanup; wait so the stop cannot cut it off.
harness
.wait_for_log_code(
retry_owner,
"record_timer.worker.iteration_failed",
Duration::from_secs(5),
)
.await?;
if blocked.occurrence_id != occurrence_id
|| blocked.state != "blocked"
|| blocked.block_kind.as_deref() != Some("technical")
Expand Down
21 changes: 19 additions & 2 deletions crates/registry-breg/tests/support/record_timer_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2903,6 +2903,21 @@ impl NativeTimerHarness {
replica: usize,
code: &str,
timeout: Duration,
) -> Result<(), String> {
self.wait_for_log_code_count(replica, code, 1, timeout)
.await
}

/// Wait until one replica's log holds at least `count` lines carrying
/// `code`. A worker writes its iteration warning only after the step it
/// reports, so neither database evidence nor readiness proves the line
/// exists yet; stopping the replica first can cut it off.
pub async fn wait_for_log_code_count(
&self,
replica: usize,
code: &str,
count: usize,
timeout: Duration,
) -> Result<(), String> {
let replica = self
.replicas
Expand All @@ -2913,14 +2928,16 @@ impl NativeTimerHarness {
loop {
let rendered = fs::read_to_string(&replica.log_path)
.map_err(|_| "native timer process log could not be read".to_owned())?;
if rendered.contains(&needle) {
if rendered.matches(&needle).count() >= count {
return Ok(());
}
tokio::time::sleep(Duration::from_millis(25)).await;
}
})
.await
.map_err(|_| "native timer process did not emit the expected log code".to_owned())?
.map_err(|_| {
format!("native timer process did not emit {count} {code} log line(s) before the bound")
})?
}

/// Terminate only the PostgreSQL sessions owned by one native process.
Expand Down
Loading