mirror of
https://github.com/rustfs/rustfs.git
synced 2026-09-07 12:35:54 +00:00
test(ecstore): wait for namespace owner release before asserting
The namespace owner tests decided that ownership had ended when the Weak probe stopped upgrading or when the mutation lease could be reacquired. Both signals fire before the owner guard's Drop decrements the pending counter: Arc releases its strong count before running Drop, and the lease drops its locks before its owner field. The rio-v2 lane hit that window in undo_fresh_version_keeps_physical_namespace_owner_after_timeout. Extend every drain wait to also require namespace_commits_pending() to be false, so the assertions observe the completed release instead of racing it.
This commit is contained in:
@@ -13291,7 +13291,7 @@ mod test {
|
||||
}),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
if published && owner_probe.upgrade().is_none() {
|
||||
if published && owner_probe.upgrade().is_none() && !ctx.namespace_commits_pending() {
|
||||
break;
|
||||
}
|
||||
tokio::task::yield_now().await;
|
||||
@@ -13429,7 +13429,10 @@ mod test {
|
||||
let generation = ctx.namespace_commit_generation();
|
||||
drop(release_tx);
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
while !std::fs::read(&xl_path).is_ok_and(|data| data == old_meta) || owner_probe.upgrade().is_some() {
|
||||
while !std::fs::read(&xl_path).is_ok_and(|data| data == old_meta)
|
||||
|| owner_probe.upgrade().is_some()
|
||||
|| ctx.namespace_commits_pending()
|
||||
{
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
})
|
||||
@@ -13554,7 +13557,7 @@ mod test {
|
||||
.expect("quota claim drains after syscall")
|
||||
.expect("revoke");
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
while owner_probe.upgrade().is_some() {
|
||||
while owner_probe.upgrade().is_some() || ctx.namespace_commits_pending() {
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -6437,7 +6437,12 @@ mod tests {
|
||||
let generations = (first_ctx.namespace_commit_generation(), second_ctx.namespace_commit_generation());
|
||||
drop(release_tx);
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
while Arc::strong_count(&group.dir_file) != 1 || first_probe.upgrade().is_some() || second_probe.upgrade().is_some() {
|
||||
while Arc::strong_count(&group.dir_file) != 1
|
||||
|| first_probe.upgrade().is_some()
|
||||
|| second_probe.upgrade().is_some()
|
||||
|| first_ctx.namespace_commits_pending()
|
||||
|| second_ctx.namespace_commits_pending()
|
||||
{
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -11038,6 +11038,16 @@ mod tests {
|
||||
assert_eq!(stored.size, 11);
|
||||
assert_eq!(stored.data.as_deref(), Some(b"inline-body".as_slice()));
|
||||
}
|
||||
// The lease releases its locks before dropping the namespace owner, and the
|
||||
// owner's `Drop` runs after its `Weak` probe stops upgrading, so wait for the
|
||||
// pending counter itself instead of asserting it right after the drain.
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
while ctx.namespace_commits_pending() || namespace_probe.upgrade().is_some() {
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
})
|
||||
.await
|
||||
.expect("released physical publishers must release namespace ownership");
|
||||
let generation_after_publication = ctx.namespace_commit_generation();
|
||||
assert!(!ctx.namespace_commits_pending());
|
||||
assert!(namespace_probe.upgrade().is_none());
|
||||
@@ -11177,6 +11187,13 @@ mod tests {
|
||||
.await
|
||||
.expect("late physical tail drains");
|
||||
drop(lease);
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
while ctx.namespace_commits_pending() || owner_probe.upgrade().is_some() {
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
})
|
||||
.await
|
||||
.expect("late physical tail must release namespace ownership");
|
||||
for dir in &dirs {
|
||||
let stored = reopen_local_disk(dir)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user