Skip to content

Commit

Permalink
Disable TestWorld timeout for oneshot bench
Browse files Browse the repository at this point in the history
Further increase timeout for dkzp_validator tests
  • Loading branch information
andyleiserson committed Dec 3, 2024
1 parent ce54a84 commit 135fbe1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
1 change: 1 addition & 0 deletions ipa-core/benches/oneshot/ipa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ async fn run(args: Args) -> Result<(), Error> {
..Default::default()
},
initial_gate: Some(Gate::default().narrow(&IpaPrf)),
timeout: None,
..TestWorldConfig::default()
};
// Construct TestWorld early to initialize logging.
Expand Down
4 changes: 2 additions & 2 deletions ipa-core/src/protocol/context/dzkp_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1162,9 +1162,9 @@ mod tests {
let a: Vec<V> = repeat_with(|| rng.gen()).take(count).collect();
let b: Vec<V> = repeat_with(|| rng.gen()).take(count).collect();

// Timeout is 10 seconds plus count * (3 ms).
// Timeout is 20 seconds plus count * (5 ms).
let config = TestWorldConfig::default()
.with_timeout_secs(10 + 3 * u64::try_from(count).unwrap() / 1000);
.with_timeout_secs(20 + 5 * u64::try_from(count).unwrap() / 1000);

let [ab0, ab1, ab2]: [Vec<Replicated<V>>; 3] =
TestWorld::<NotSharded>::with_config(&config)
Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/protocol/hybrid/oprf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ mod test {
const SHARDS: usize = 2;
let world: TestWorld<WithShards<SHARDS>> = TestWorld::with_shards(TestWorldConfig {
initial_gate: Some(Gate::default().narrow(&ProtocolStep::Hybrid)),
timeout: Duration::from_secs(60),
timeout: Some(Duration::from_secs(60)),
..Default::default()
});

Expand Down
29 changes: 21 additions & 8 deletions ipa-core/src/test_fixture/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct TestWorld<S: ShardingScheme = NotSharded> {
rng: Mutex<StdRng>,
gate_vendor: Box<dyn TestGateVendor>,
_shard_network: InMemoryShardNetwork,
timeout: Duration,
timeout: Option<Duration>,
}

#[derive(Clone)]
Expand Down Expand Up @@ -161,9 +161,11 @@ pub struct TestWorldConfig {

/// Timeout for tests run by this `TestWorld`.
///
/// This timeout is implement using tokio, so it will only be able to terminate the test if the
/// If `None`, there is no timeout.
///
/// The timeout is implemented using tokio, so it will only be able to terminate the test if the
/// futures are yielding periodically.
pub timeout: Duration,
pub timeout: Option<Duration>,
}

impl ShardingScheme for NotSharded {
Expand Down Expand Up @@ -387,14 +389,19 @@ impl<S: ShardingScheme> TestWorld<S> {
}

async fn with_timeout<F: IntoFuture>(&self, fut: F) -> F::Output {
if cfg!(feature = "shuttle") {
fut.await
let timeout = if cfg!(feature = "shuttle") {
None
} else {
let Ok(output) = tokio::time::timeout(self.timeout, fut).await else {
self.timeout
};
if let Some(timeout) = timeout {
let Ok(output) = tokio::time::timeout(timeout, fut).await else {
tracing::error!("timed out after {:?}", self.timeout);
panic!("timed out after {:?}", self.timeout);
};
output
} else {
fut.await
}
}
}
Expand All @@ -414,7 +421,7 @@ impl Default for TestWorldConfig {
seed: thread_rng().next_u64(),
initial_gate: None,
stream_interceptor: passthrough(),
timeout: Duration::from_secs(10),
timeout: Some(Duration::from_secs(10)),
}
}
}
Expand All @@ -434,7 +441,13 @@ impl TestWorldConfig {

#[must_use]
pub fn with_timeout_secs(mut self, timeout_secs: u64) -> Self {
self.timeout = Duration::from_secs(timeout_secs);
self.timeout = Some(Duration::from_secs(timeout_secs));
self
}

#[must_use]
pub fn with_no_timeout(mut self) -> Self {
self.timeout = None;
self
}

Expand Down

0 comments on commit 135fbe1

Please sign in to comment.