Skip to content

Commit

Permalink
Use short timeout instead of now_or_never.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidblewett committed Jan 11, 2024
1 parent 8c08009 commit 9620a51
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/test_high_consumers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::HashMap;
use std::error::Error;
use std::sync::Arc;

use futures::future::{self, FutureExt};
use futures::future;
use futures::stream::StreamExt;
use maplit::hashmap;
use rdkafka_sys::RDKafkaErrorCode;
Expand Down Expand Up @@ -546,7 +546,7 @@ async fn test_consume_partition_order() {

let mut i = 0;
while i < 12 {
if let Some(m) = consumer.recv().now_or_never() {
if let Ok(m) = time::timeout(Duration::from_millis(100), consumer.recv()).await {
// retry on transient errors until we get a message
let m = match m {
Err(KafkaError::MessageConsumption(
Expand All @@ -564,9 +564,11 @@ async fn test_consume_partition_order() {
let partition: i32 = m.partition();
assert!(partition == 0 || partition == 2);
i += 1;
} else {
panic!("Timeout receiving message");
}

if let Some(m) = partition1.recv().now_or_never() {
if let Ok(m) = time::timeout(Duration::from_millis(100), partition1.recv()).await {
// retry on transient errors until we get a message
let m = match m {
Err(KafkaError::MessageConsumption(
Expand All @@ -583,6 +585,8 @@ async fn test_consume_partition_order() {
};
assert_eq!(m.partition(), 1);
i += 1;
} else {
panic!("Timeout receiving message");
}
}
}
Expand Down

0 comments on commit 9620a51

Please sign in to comment.