Skip to content

Fix flaky tests: InboxSpec, ShardRegionSpec, and scheduler interval test#8035

Merged
Aaronontheweb merged 3 commits into
akkadotnet:devfrom
Aaronontheweb:fix/additional-racy-tests
Jan 27, 2026
Merged

Fix flaky tests: InboxSpec, ShardRegionSpec, and scheduler interval test#8035
Aaronontheweb merged 3 commits into
akkadotnet:devfrom
Aaronontheweb:fix/additional-racy-tests

Conversation

@Aaronontheweb
Copy link
Copy Markdown
Member

@Aaronontheweb Aaronontheweb commented Jan 26, 2026

Summary

Fixes flaky tests discovered in PR #8023 and #8035 CI runs.

Changes

1. InboxSpec.Inbox_have_a_default_and_custom_timeouts

  • Problem: Assert.Throws<TimeoutException> fails because Inbox.Receive() internally uses async and can wrap the TimeoutException in an AggregateException
  • Fix: Use Record.Exception and check for both direct TimeoutException and AggregateException-wrapped TimeoutException using helper method IsTimeoutException

2. ShardRegionSpec.ClusterSharding_must

  • Problem: Synchronous ExpectMsg<int> in AwaitRebalance could timeout during shard rebalancing
  • Fix: Convert AwaitRebalance to async AwaitRebalanceAsync using ExpectMsgAsync<int>, and use AwaitAssertAsync at the call site

3. DefaultScheduler_ActionScheduler_Schedule_Tests.ScheduleRepeatedly_in_milliseconds_Tests_and_verify_the_interval

  • Problem: Test expected scheduler intervals to be within 10% accuracy, but CI machines have significant timing variability (13.24% deviation observed)
  • Fix: Increased tolerance from 10% to 30% to accommodate CI variability while still catching gross scheduler bugs

Test plan

  • InboxSpec.Inbox_have_a_default_and_custom_timeouts passes locally
  • ShardRegionSpec.ClusterSharding_must passes locally
  • ScheduleRepeatedly_in_milliseconds_Tests_and_verify_the_interval passes locally
  • No feature code changes, test-only fixes

- InboxSpec.Inbox_have_a_default_and_custom_timeouts: Handle both
  direct TimeoutException and AggregateException-wrapped TimeoutException
  since Inbox.Receive() uses async internally and may wrap exceptions

- ShardRegionSpec.ClusterSharding_must: Convert AwaitRebalance to async
  using ExpectMsgAsync to avoid synchronous blocking during shard
  rebalance wait
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) January 26, 2026 21:34
The ScheduleRepeatedly_in_milliseconds_Tests_and_verify_the_interval test
was failing on CI with 13.24% deviation (expected max 10%). CI machines
have significant timing variability due to CPU contention, virtualization
overhead, and GC pauses.

Increased tolerance from 10% to 30% to accommodate CI variability while
still catching gross scheduler bugs (e.g., intervals off by 50%+).
@Aaronontheweb Aaronontheweb changed the title Fix additional flaky tests: InboxSpec and ShardRegionSpec Fix flaky tests: InboxSpec, ShardRegionSpec, and scheduler interval test Jan 27, 2026
@Aaronontheweb Aaronontheweb merged commit ac7678e into akkadotnet:dev Jan 27, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant