-
Notifications
You must be signed in to change notification settings - Fork 493
test: make wall-clock-bound tests robust under CI load #4480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,9 @@ use std::time::{Duration, Instant}; | |
| use baml_bridge::runtime::BamlCallContext; | ||
| use baml_sdk::throws_test; | ||
|
|
||
| const _MAX_CANCELLATION_SECONDS: f64 = 0.5; | ||
| const _MAX_CANCELLATION_SECONDS: f64 = 5.0; | ||
| // The cancelled calls below sleep 60s: the operation must dwarf this bound, or a | ||
| // regression that ignored cancellation would still finish inside it and pass. | ||
|
Comment on lines
+15
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
manifest="$(fd --type f '^Cargo\.toml$' baml_language/sdk_tests | head -n 1)"
test -n "$manifest"
cargo test --manifest-path "$manifest" --libRepository: BoundaryML/baml Length of output: 145 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- manifests ---'
fd --type f '^Cargo\.toml$' baml_language/sdk_tests | head -n 20
manifest="$(fd --type f '^Cargo\.toml$' baml_language/sdk_tests | head -n 1)"
printf '\n--- selected manifest: %s ---\n' "$manifest"
sed -n '1,220p' "$manifest"
printf '\n--- test file structure ---\n'
wc -l baml_language/sdk_tests/crates/rust/function_calls/customizable/test_cancellation.rs
sed -n '1,220p' baml_language/sdk_tests/crates/rust/function_calls/customizable/test_cancellation.rs
printf '\n--- package/workspace references ---\n'
rg -n '^\[workspace|^\[package|^name\s*=|^members\s*=|^path\s*=|test_cancellation|sdk_tests' baml_language/sdk_tests --glob 'Cargo.toml' --glob '*.rs' | head -n 120Repository: BoundaryML/baml Length of output: 17865 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- Rust manifest ---'
sed -n '1,220p' baml_language/sdk_tests/crates/rust/Cargo.toml
printf '\n--- Rust build script ---\n'
sed -n '1,180p' baml_language/sdk_tests/crates/rust/build.rs
printf '\n--- Rust harness test-file handling ---\n'
sed -n '70,125p' baml_language/sdk_tests/harness_setup/src/rust.rs
sed -n '350,390p' baml_language/sdk_tests/harness_setup/src/rust.rs
printf '\n--- Rust crate targets and test declarations ---\n'
rg -n '^\s*#\[test\]|^\s*#\[tokio::test\]|mod customizable|test_cancellation|include!|path\s*=|crate-type|lib\b' \
baml_language/sdk_tests/crates/rust baml_language/sdk_tests/harness_setup/src/rust.rs \
--glob '*.rs' --glob 'Cargo.toml' | head -n 160Repository: BoundaryML/baml Length of output: 22153 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- Rust library entry point ---'
sed -n '1,180p' baml_language/sdk_tests/crates/rust/src/lib.rs
printf '\n--- Generated test target code ---\n'
sed -n '380,520p' baml_language/sdk_tests/harness_setup/src/rust.rs
printf '\n--- Rust crate test files ---\n'
find baml_language/sdk_tests/crates/rust -maxdepth 2 -type f \
\( -path '*/tests/*' -o -name 'lib.rs' -o -name 'main.rs' \) -print | sortRepository: BoundaryML/baml Length of output: 6538 Run the Rust crate test command with the Rust manifest. Use 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
| /// python asserts `isinstance(exc.value, Cancelled)`; `baml_bridge::Error::Panic` | ||
| /// carries only the rendered message + trace, so the class check adapts to | ||
|
|
@@ -69,7 +71,7 @@ fn test_cancellation_sync_cancel_via_call_context() { | |
| }); | ||
|
|
||
| // PROVISIONAL: `_ctx=ctx` → the `_with_ctx` sibling. | ||
| let result = throws_test::SleepMs_with_ctx(2000, &ctx); | ||
| let result = throws_test::SleepMs_with_ctx(60000, &ctx); | ||
| _assert_cancelled_panic(result.unwrap_err()); | ||
| timer.join().unwrap(); | ||
| }); | ||
|
|
@@ -86,7 +88,7 @@ async fn test_cancellation_async_cancel_via_call_context() { | |
| // here the call and the aborter run under `join!` and the aborted call | ||
| // itself resolves to the cancellation error. | ||
| // PROVISIONAL: `_ctx=ctx` → the `_with_ctx` sibling. | ||
| let (result, ()) = tokio::join!(throws_test::SleepMs_async_with_ctx(2000, &ctx), async { | ||
| let (result, ()) = tokio::join!(throws_test::SleepMs_async_with_ctx(60000, &ctx), async { | ||
| tokio::time::sleep(Duration::from_millis(50)).await; | ||
| ctx.abort(); | ||
| }); | ||
|
|
@@ -98,7 +100,7 @@ async fn test_cancellation_async_cancel_via_call_context() { | |
| #[tokio::test] | ||
| async fn test_cancellation_async_cancel_via_task_cancel() { | ||
| let start = Instant::now(); | ||
| let task = tokio::spawn(throws_test::SleepMs_async(2000)); | ||
| let task = tokio::spawn(throws_test::SleepMs_async(60000)); | ||
|
|
||
| tokio::time::sleep(Duration::from_millis(50)).await; | ||
| task.abort(); | ||
|
|
@@ -127,7 +129,7 @@ async fn test_cancellation_async_cancel_via_task_group_sibling() { | |
| // `task.cancelled()`. | ||
| let result = tokio::try_join!( | ||
| async { | ||
| throws_test::SleepMs_async(2000) | ||
| throws_test::SleepMs_async(60000) | ||
| .await | ||
| .map_err(|_| "sleep failed") | ||
| }, | ||
|
|
@@ -145,7 +147,7 @@ async fn test_cancellation_async_cancel_via_asyncio_timeout() { | |
| // elapsed error is the `TimeoutError`, and the timed-out call future is | ||
| // dropped (cancelled). | ||
| let result = | ||
| tokio::time::timeout(Duration::from_millis(50), throws_test::SleepMs_async(2000)).await; | ||
| tokio::time::timeout(Duration::from_millis(50), throws_test::SleepMs_async(60000)).await; | ||
| assert!(result.is_err()); | ||
|
|
||
| _assert_fast_cancellation(start); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: BoundaryML/baml
Length of output: 50372
🏁 Script executed:
Repository: BoundaryML/baml
Length of output: 50372
🏁 Script executed:
Repository: BoundaryML/baml
Length of output: 50371
Cancel the timed-out future.
future.get(50, TimeUnit.MILLISECONDS)does not cancel the in-flightFns.SleepMs_async(60000L)call. Cancelfuturein a timeout cleanup path. Itscancel(true)implementation also cancels the engine call.🤖 Prompt for AI Agents