Skip to content

Commit

Permalink
fix hello_ok_true test on LB
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickfreed committed Mar 22, 2022
1 parent eb01057 commit 764d9f5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/sdam/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,21 @@ async fn hello_ok_true() {

let mut options = setup_client_options.clone();
options.sdam_event_handler = Some(handler.clone());
options.direct_connection = Some(true);
options.heartbeat_freq = Some(Duration::from_millis(500));

// for simplicity, just look at the events for one of the hosts.
let observed_address = options.hosts[0].clone();

let _client = Client::with_options(options).expect("client creation should succeed");

// first heartbeat should be ismaster but contain helloOk
subscriber
.wait_for_event(Duration::from_millis(2000), |event| {
if let Event::Sdam(SdamEvent::ServerHeartbeatSucceeded(e)) = event {
if e.server_address != observed_address {
return false;
}

assert_eq!(e.reply.get_bool("helloOk"), Ok(true));
assert!(e.reply.get("ismaster").is_some());
assert!(e.reply.get("isWritablePrimary").is_none());
Expand All @@ -426,6 +433,9 @@ async fn hello_ok_true() {
subscriber
.wait_for_event(Duration::from_millis(2000), |event| {
if let Event::Sdam(SdamEvent::ServerHeartbeatSucceeded(e)) = event {
if e.server_address != observed_address {
return false;
}
assert!(e.reply.get("isWritablePrimary").is_some());
assert!(e.reply.get("ismaster").is_none());
return true;
Expand Down

0 comments on commit 764d9f5

Please sign in to comment.