mirror of
https://relay.ngit.dev/npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit-grasp.git
synced 2026-10-05 15:08:24 +00:00
test(grasp06): run staging maintenance in streaming cleanup fixture
The standalone receive-pack streaming test expected synchronous directory removal and omitted the server's maintenance worker. Deferred staging cleanup therefore left the fixture waiting forever even though the production server starts that worker. Start the real worker with the handler's lock map and wait with a bounded deadline for empty-view removal. Also assert that the staging registry is empty. The fake Git writes no objects, so let its repack and prune commands complete as no-ops. Preserve the assertion that receive-pack streams progress while the repository remains available and the subprocess is still running. This changes test infrastructure only, not production cleanup or timeouts. Validation: all four streaming tests and the full ngit-grasp suite pass (3621 tests); formatting and diff checks pass. CI on the production parent identified the original immediate-removal assertion as its failing test. Assisted-by: GPT-6
This commit is contained in:
@@ -318,6 +318,10 @@ async fn prs_receive_pack_streams_stdout_before_cleanup_removes_empty_repo() {
|
|||||||
subpath: "git-receive-pack".to_string(),
|
subpath: "git-receive-pack".to_string(),
|
||||||
};
|
};
|
||||||
let repo_path = prs_repo_path(git_data.path(), &prs.submitter.to_hex(), &prs.identifier);
|
let repo_path = prs_repo_path(git_data.path(), &prs.submitter.to_hex(), &prs.identifier);
|
||||||
|
let maintenance = tokio::spawn(ngit_grasp::git::staging::run_worker(
|
||||||
|
ngit_grasp::git::storage::LocalGitStorage::new(git_data.path()),
|
||||||
|
repo_init_locks.clone(),
|
||||||
|
));
|
||||||
|
|
||||||
let response = handle_prs_receive_pack(
|
let response = handle_prs_receive_pack(
|
||||||
&prs,
|
&prs,
|
||||||
@@ -352,10 +356,22 @@ async fn prs_receive_pack_streams_stdout_before_cleanup_removes_empty_repo() {
|
|||||||
finish_body(&mut body, &mut streamed).await;
|
finish_body(&mut body, &mut streamed).await;
|
||||||
assert_eq!(streamed, expected_git_output());
|
assert_eq!(streamed, expected_git_output());
|
||||||
|
|
||||||
assert!(
|
timeout(Duration::from_secs(5), async {
|
||||||
!repo_path.exists(),
|
while repo_path.exists() {
|
||||||
"/prs/ cleanup should remove zero-ref repo after receive-pack exits"
|
tokio::task::yield_now().await;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.expect("/prs/ maintenance should remove zero-ref repo after receive-pack exits");
|
||||||
|
assert_eq!(
|
||||||
|
std::fs::read_dir(git_data.path().join(".grasp/staging"))
|
||||||
|
.expect("staging registry")
|
||||||
|
.count(),
|
||||||
|
0,
|
||||||
|
"cleanup must also remove the staging record"
|
||||||
);
|
);
|
||||||
|
maintenance.abort();
|
||||||
|
let _ = maintenance.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep the listener bound until Git has observed the parent's release.
|
// Keep the listener bound until Git has observed the parent's release.
|
||||||
@@ -553,6 +569,11 @@ if [ "$1" = "for-each-ref" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# This streaming fixture never writes Git objects, so maintenance is a no-op.
|
||||||
|
if [ "$1" = "repack" ] || [ "$1" = "prune" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
echo "unsupported fake git invocation: $*" >&2
|
echo "unsupported fake git invocation: $*" >&2
|
||||||
exit 1
|
exit 1
|
||||||
"#
|
"#
|
||||||
|
|||||||
Reference in New Issue
Block a user