diff --git a/tests/unit/awm_v2.bats b/tests/unit/awm_v2.bats index 85d33ec..1fe28bf 100644 --- a/tests/unit/awm_v2.bats +++ b/tests/unit/awm_v2.bats @@ -100,7 +100,7 @@ teardown() { @test "awm_store_set respects TTL" { awm_store_set "ttl_key" "expires_soon" 1 - sleep 2 + sleep 0.5 result=$(awm_store_get "ttl_key" "expired") [ "$result" = "expired" ] } diff --git a/tests/unit/futures.bats b/tests/unit/futures.bats index 337f5c4..443bd81 100644 --- a/tests/unit/futures.bats +++ b/tests/unit/futures.bats @@ -92,7 +92,7 @@ teardown() { @test "future_status: returns running for active future" { local fid - fid=$(future_run sleep 2) + fid=$(future_run sleep 0.5) local status status=$(future_status "$fid") [[ "$status" == "running" ]] @@ -119,7 +119,7 @@ teardown() { @test "future_status: returns cancelled for cancelled future" { local fid - fid=$(future_run sleep 2) + fid=$(future_run sleep 0.5) future_cancel "$fid" local status status=$(future_status "$fid") @@ -167,7 +167,7 @@ teardown() { @test "future_await: returns 124 on timeout" { local fid - fid=$(future_run sleep 3) + fid=$(future_run sleep 0.8) run future_await "$fid" 1 [[ "$status" -eq 124 ]] future_cancel "$fid" @@ -238,7 +238,7 @@ teardown() { @test "future_cancel: cancels running future" { local fid - fid=$(future_run sleep 2) + fid=$(future_run sleep 0.5) future_cancel "$fid" local status status=$(future_status "$fid") @@ -247,7 +247,7 @@ teardown() { @test "future_cancel: returns 0 on success" { local fid - fid=$(future_run sleep 2) + fid=$(future_run sleep 0.5) future_cancel "$fid" [[ $? -eq 0 ]] } @@ -262,7 +262,7 @@ teardown() { @test "future_cancel: kills the background process" { local fid - fid=$(future_run sleep 2) + fid=$(future_run sleep 0.5) local dir="${TMPDIR:-/tmp}/mainframe/futures/$fid" local pid pid=$(<"$dir/pid") @@ -324,7 +324,7 @@ teardown() { @test "future_cleanup: preserves running futures" { local fid - fid=$(future_run sleep 2) + fid=$(future_run sleep 0.5) local dir="${TMPDIR:-/tmp}/mainframe/futures/$fid" future_cleanup @@ -335,7 +335,7 @@ teardown() { @test "future_cleanup --all: removes cancelled futures" { local fid - fid=$(future_run sleep 2) + fid=$(future_run sleep 0.5) future_cancel "$fid" local dir="${TMPDIR:-/tmp}/mainframe/futures/$fid" @@ -382,7 +382,7 @@ teardown() { @test "future_wait_any: returns first completed ID" { local fid1 fid2 - fid1=$(future_run sleep 2) + fid1=$(future_run sleep 0.5) fid2=$(future_run echo "quick") local first @@ -394,7 +394,7 @@ teardown() { @test "future_wait_any: returns 0 for successful first completion" { local fid1 fid2 - fid1=$(future_run sleep 2) + fid1=$(future_run sleep 0.5) fid2=$(future_run true) future_wait_any "$fid1" "$fid2" >/dev/null @@ -405,7 +405,7 @@ teardown() { @test "future_wait_any: returns 1 for failed first completion" { local fid1 fid2 - fid1=$(future_run sleep 2) + fid1=$(future_run sleep 0.5) fid2=$(future_run false) run bash -c "source '$MAINFRAME_ROOT/lib/common.sh'; source '$MAINFRAME_ROOT/lib/futures.sh'; future_wait_any '$fid1' '$fid2'" @@ -542,7 +542,7 @@ teardown() { @test "future: handles long-running commands" { skip "Skipping long-running test in unit suite" local fid - fid=$(future_run sleep 3) + fid=$(future_run sleep 0.8) future_await "$fid" 10 [[ $? -eq 0 ]] } diff --git a/tests/unit/retry.bats b/tests/unit/retry.bats index aa3ce8a..142a53c 100644 --- a/tests/unit/retry.bats +++ b/tests/unit/retry.bats @@ -240,7 +240,7 @@ teardown() { } @test "with_timeout: times out slow command" { - run with_timeout 1 sleep 3 + run with_timeout 1 sleep 2 [[ $status -eq 124 ]] } @@ -392,7 +392,7 @@ teardown() { circuit_breaker_call "test_svc" false || true # Wait for timeout - sleep 2 + sleep 0.5 local state state=$(circuit_breaker_state "test_svc") @@ -405,7 +405,7 @@ teardown() { circuit_breaker_call "test_svc" false || true # Wait for timeout to transition to half-open - sleep 2 + sleep 0.5 # Success in half-open should close circuit_breaker_call "test_svc" true @@ -527,7 +527,7 @@ teardown() { local marker="${TEST_TEMP_DIR}/ready" # Create the marker after 2 seconds - (sleep 2 && touch "$marker") & + (sleep 0.5 && touch "$marker") & run wait_for --timeout 5 --interval 1 test -f "$marker" assert_success @@ -548,7 +548,7 @@ teardown() { @test "wait_for_file: waits for file creation" { local file="${TEST_TEMP_DIR}/delayed.txt" - (sleep 2 && touch "$file") & + (sleep 0.5 && touch "$file") & run wait_for_file "$file" 5 assert_success @@ -699,7 +699,7 @@ teardown() { [[ $status -eq 1 ]] # Wait well beyond refill period (1s period + margin) - sleep 3 + sleep 1.5 # Should have tokens again run rate_limit_acquire "test_rl" --no-wait diff --git a/tests/unit/workpool.bats b/tests/unit/workpool.bats index d945fc9..56d6044 100644 --- a/tests/unit/workpool.bats +++ b/tests/unit/workpool.bats @@ -118,7 +118,7 @@ teardown() { # Submit a long-running job local job_id - job_id=$(pool_submit "test_pool" sleep 3) + job_id=$(pool_submit "test_pool" sleep 0.8) # Give it time to start sleep 0.2 @@ -423,7 +423,7 @@ EOF pool_create "test_pool" local job_id - job_id=$(pool_submit "test_pool" sleep 2) + job_id=$(pool_submit "test_pool" sleep 0.5) sleep 0.2 # Let it start @@ -443,7 +443,7 @@ EOF pool_create "test_pool" 1 # Submit a blocking job to occupy the worker - pool_submit "test_pool" sleep 2 > /dev/null + pool_submit "test_pool" sleep 0.5 > /dev/null sleep 0.2 # Submit another job that will be pending