Skip to content

Commit b6c0969

Browse files
committed
Add test for edge case that used to make benchmarks hang
1 parent cd13600 commit b6c0969

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

src/lola_fixtures.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,10 @@ pub fn input_streams_add_defer(size: usize) -> MapInputProvider {
573573
"y".into(),
574574
(0..size).map(|y| Value::Int(2 * y + 1)).collect(),
575575
);
576+
let add = if size % 2 == 0 { 0 } else { 1 };
576577
let e_stream = iter::repeat(Value::Deferred)
577578
.take((size / 2) as usize)
578-
.chain((0..size / 2).map(|_| Value::Str("x + y".into())))
579+
.chain((0..(size / 2) + add).map(|_| Value::Str("x + y".into())))
579580
.collect();
580581
input_values.insert("e".into(), e_stream);
581582

tests/runtime_tests.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,3 +2466,50 @@ async fn test_defer_comp_dynamic(executor: Rc<LocalExecutor<'static>>) -> anyhow
24662466
}
24672467
Ok(())
24682468
}
2469+
2470+
// TODO: TW there is a bug here with the typed async configuration - hence why I used the
2471+
// untyped only
2472+
#[apply(async_test)]
2473+
async fn test_benchmark_regression_long_add_defer(
2474+
executor: Rc<LocalExecutor<'static>>,
2475+
) -> anyhow::Result<()> {
2476+
// Specifically we used to fail with size >= 2007
2477+
const SIZE: usize = 5000;
2478+
for config in TestConfiguration::untyped_configurations() {
2479+
let spec = lola_specification(&mut spec_add_defer()).unwrap();
2480+
2481+
let input_streams = input_streams_add_defer(SIZE);
2482+
2483+
// Create output handler based on configuration
2484+
let mut output_handler = Box::new(ManualOutputHandler::new(
2485+
executor.clone(),
2486+
spec.output_vars.clone(),
2487+
));
2488+
let outputs = output_handler.get_output();
2489+
2490+
// Build base monitor with common settings
2491+
let builder = RuntimeBuilder::new()
2492+
.executor(executor.clone())
2493+
.model(spec.clone())
2494+
.input(Box::new(input_streams))
2495+
.output(output_handler);
2496+
2497+
// Apply configuration-specific settings
2498+
let builder = create_builder_from_config(builder, config);
2499+
2500+
let monitor = builder.build();
2501+
2502+
// Run monitor and collect results
2503+
executor.spawn(monitor.run()).detach();
2504+
let result: Vec<(usize, Vec<Value>)> = with_timeout(
2505+
outputs.take(SIZE).enumerate().collect(),
2506+
3,
2507+
format!("outputs.collect with config: {:?}", config).as_str(),
2508+
)
2509+
.await?;
2510+
2511+
// This test is just about not hanging
2512+
assert_eq!(result.len(), SIZE);
2513+
}
2514+
Ok(())
2515+
}

0 commit comments

Comments
 (0)