Skip to content

Commit

Permalink
[apache#1308] improvement(rust): detect whether data has been purged …
Browse files Browse the repository at this point in the history
…in UT (apache#1323)

### What changes were proposed in this pull request?

add code to improve purge unit test to detect whether arc reference is 0

### Why are the changes needed?

Fix: apache#1308 

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

1. UT

---------

Co-authored-by: 蒋文龙 <jiangwenlong@192.168.1.6>
  • Loading branch information
wenlongbrother and 蒋文龙 authored Nov 22, 2023
1 parent 4edd60f commit d72a483
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rust/experimental/server/src/store/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,8 +1084,22 @@ mod test {
let data = runtime.wait(store.get(reading_ctx.clone())).expect("");
assert_eq!(1, data.from_memory().shuffle_data_block_segments.len());

// get weak reference to ensure purge can successfully free memory
let weak_ref_before = store
.state
.get(&uid)
.map(|entry| Arc::downgrade(&entry.value()));
assert!(
weak_ref_before.is_some(),
"Failed to obtain weak reference before purge"
);

// purge
runtime.wait(store.purge(app_id.to_string())).expect("");
assert!(
weak_ref_before.clone().unwrap().upgrade().is_none(),
"Arc should not exist after purge"
);
let snapshot = runtime.wait(store.budget.snapshot());
assert_eq!(snapshot.used, 0);
// the remaining allocated will be removed.
Expand Down

0 comments on commit d72a483

Please sign in to comment.