diff options
author | Brian Chen <brianc118@fb.com> | 2022-03-14 08:06:36 -0700 |
---|---|---|
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | 2022-03-14 08:06:36 -0700 |
commit | 930647734d1dc7892ea057b686de3b3e9be9e4f9 (patch) | |
tree | e8c9feeca44180ba7c9dfa232a34ce447a2c6d18 | |
parent | 8b97d13c048a0a08e462844420d89fd2210e5c51 (diff) |
Fix races in collector_plugin test
Summary:
There are a few races in the test that show up in stress test. We need
to use the barrier a few more times.
Reviewed By: dschatzberg
Differential Revision: D34598821
fbshipit-source-id: d97cf5f425b1fd58e4bbbd708a0ba77ed5f690a2
-rw-r--r-- | below/model/src/collector_plugin.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/below/model/src/collector_plugin.rs b/below/model/src/collector_plugin.rs index efcd0345..4f55ddc3 100644 --- a/below/model/src/collector_plugin.rs +++ b/below/model/src/collector_plugin.rs @@ -151,22 +151,31 @@ mod test { // Test overwriting sample futures::executor::block_on(collector.collect_and_update()).unwrap(); c.wait(); // <-- 1 + // Consumer checking overwritten sample + c.wait(); // <-- 2 // Test sending None futures::executor::block_on(collector.collect_and_update()).unwrap(); - c.wait(); // <-- 2 + c.wait(); // <-- 3 + // Consumer checking None + c.wait(); // <-- 4 // Test sending error. Will fail on both collector and consumer threads. let is_error = matches!( futures::executor::block_on(collector.collect_and_update()), Err(_) ); - c.wait(); // <-- 3 + c.wait(); // <-- 5 assert!(is_error, "Collector did not return an error"); }); + // Collector overwriting sample barrier.wait(); // <-- 1 assert_eq!(Some(2), consumer.try_take().unwrap()); barrier.wait(); // <-- 2 - assert_eq!(None, consumer.try_take().unwrap()); + // Collector sending None barrier.wait(); // <-- 3 + assert_eq!(None, consumer.try_take().unwrap()); + barrier.wait(); // <-- 4 + // Collector sending error + barrier.wait(); // <-- 5 assert!(matches!(consumer.try_take(), Err(_))); handle.join().unwrap(); |