chadtmiller.com/knotless
git that lives in your Atmosphere account
1
10
Two serve tests wait for the index and the code shards to settle
crates/knotless-serve/tests/gateway.rs+9−6
| @@ -3259,26 +3259,29 @@ fn private_repositories_indexed_here() { | ||
// What is written since is read on from each member's oplog: what is | ||
// added, and what is taken back. | ||
let again = run(&owner, &["issue", "create", &url, "More trouble"]); | ||
// An issue just filed is no thread until the sync finds it: no comments | ||
// are listed, not even none. | ||
let comments = || { | ||
let shown = read("getThread", &thread(&again)); | ||
shown["comments"].as_array().unwrap().len() | ||
let (_, _, _, said) = looked(&xrpc("getThread", &thread(&again)), theirs); | ||
let shown: Value = serde_json::from_str(&said).unwrap(); | ||
shown["comments"].as_array().map(Vec::len) | ||
}; | ||
let said = run(&owner, &["comment", "add", &url, &again, "Noted"]); | ||
wait_until(|| comments() == 1); | ||
wait_until(|| comments() == Some(1)); | ||
run(&owner, &["comment", "delete", &url, &said]); | ||
wait_until(|| comments() == 0); | ||
wait_until(|| comments() == Some(0)); | ||
// A repo whose writes no longer check out against the commit its | ||
// server vouches for is read whole, and what it took back meanwhile | ||
// goes too. | ||
let said = run(&owner, &["comment", "add", &url, &again, "Noted again"]); | ||
wait_until(|| comments() == 1); | ||
wait_until(|| comments() == Some(1)); | ||
// Past any sync still writing where it got to. | ||
std::thread::sleep(Duration::from_secs(1)); | ||
let (rev, _) = index.space_writer(&space, &did).unwrap().unwrap(); | ||
let wrong = vec![0; knotless::space_sync::STATE_BYTES]; | ||
index.set_space_writer(&space, &did, &rev, &wrong).unwrap(); | ||
run(&owner, &["comment", "delete", &url, &said]); | ||
wait_until(|| comments() == 0); | ||
wait_until(|| comments() == Some(0)); | ||
assert_eq!(read("getRepo", "")["openIssues"], 2); | ||
// A record the member's server keeps cut short, so that it no longer | ||
// comes to the CID it was written with, is left out, and the rest of | ||
crates/knotless-serve/tests/web.rs+3−2
| @@ -3674,7 +3674,8 @@ fn searching_code() { | ||
let mine = |n: &String| n.starts_with(&theirs) && n.ends_with(".zoekt"); | ||
names.filter(mine).count() | ||
}; | ||
assert_eq!(shards(), 2); | ||
// A push's new shard is found before the one it replaces is deleted. | ||
wait_until(|| shards() == 2); | ||
// `/_status` tells of the index. | ||
let (_, status) = site.status("/_status"); | ||
let status: Value = serde_json::from_str(&status).unwrap(); | ||
| @@ -3684,5 +3685,5 @@ fn searching_code() { | ||
wait_until(|| found("needle_1") == 0); | ||
// And its shards are deleted. | ||
wait_until(|| shards() == 1); | ||
assert_eq!(found("needle_"), 2); | ||
wait_until(|| found("needle_") == 2); | ||
} | ||