Skip to content

Commit

Permalink
[RSDK-9365] fix flaky test (#372)
Browse files Browse the repository at this point in the history
as the executor is not multithreaded, using a sync condvar would just block the whole executor. 

in lieu of a hook/channel/flag to determine the state of a given request/response, we are using the fact that storage credentials are erased as the flag that the request was processed correctly.

the await-loop gives more opportunities
for the server and fake_server to make progress
  • Loading branch information
mattjperez authored Jan 23, 2025
1 parent 491e339 commit 7efaeb8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions micro-rdk/src/common/conn/viam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1321,12 +1321,21 @@ mod tests {
})));
exec.block_on(async move {
let other_clone = cloned_exec.clone();
let _fake_server_task =
cloned_exec.spawn(async move { run_fake_app_server(other_clone, app).await });
let _fake_server_task = cloned_exec.spawn(async move {
run_fake_app_server(other_clone, app).await;
});
let _task = cloned_exec.spawn(async move {
viam_server.run().await;
});
let _ = Timer::after(Duration::from_millis(500)).await;

for _ in 0..10 {
// await multiple times to give both servers opportunity to process request/response
let _ = Timer::after(Duration::from_millis(50)).await;
if !cloned_ram_storage.has_robot_credentials() {
// viam_server properly handled response from fake_app_server
break;
}
}
assert!(!cloned_ram_storage.has_robot_credentials())
});
}
Expand Down

0 comments on commit 7efaeb8

Please sign in to comment.