fast exit dynamic test

This commit is contained in:
Anatoly Yakovenko
2018-07-16 22:22:29 -07:00
committed by Greg Fitzgerald
parent 47a22c66b4
commit 72282dc493
2 changed files with 8 additions and 0 deletions

View File

@ -318,6 +318,10 @@ impl FullNode {
FullNode { exit, thread_hdls } FullNode { exit, thread_hdls }
} }
//used for notifying many nodes in parallel to exit
pub fn notify_exit(self) {
self.exit.store(true, Ordering::Relaxed);
}
pub fn close(self) -> Result<()> { pub fn close(self) -> Result<()> {
self.exit.store(true, Ordering::Relaxed); self.exit.store(true, Ordering::Relaxed);
self.join() self.join()
@ -355,6 +359,7 @@ mod tests {
let exit = Arc::new(AtomicBool::new(false)); let exit = Arc::new(AtomicBool::new(false));
let entry = tn.data.clone(); let entry = tn.data.clone();
let v = FullNode::new_validator(kp, bank, 0, None, tn, &entry, exit); let v = FullNode::new_validator(kp, bank, 0, None, tn, &entry, exit);
v.notify_exit();
v.close().unwrap(); v.close().unwrap();
} }
} }

View File

@ -464,6 +464,9 @@ fn test_multi_node_dynamic_network() {
} }
} }
assert_eq!(consecutive_success, 10); assert_eq!(consecutive_success, 10);
for (_, node) in validators {
node.notify_exit();
}
for (_, node) in validators { for (_, node) in validators {
node.close().unwrap(); node.close().unwrap();
} }