Skip to content

test: make background flush recovery test deterministic - #355

Merged
marandaneto merged 1 commit into
mainfrom
test/deterministic-background-flush
Oct 27, 2026
Merged

marandaneto merged 1 commit into
mainfrom
test/deterministic-background-flush

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

The release job failed because BackgroundFlushContinuesAfterException waited only one second for its second background flush. The same commit passed in the regular CI workflow.

The test now uses explicit task signals instead of timed waits. It holds the first flush until the next batch is queued, then lets that flush throw and checks that the next batch is delivered. It also watches the background tasks so a worker that exits after the exception fails an assertion instead of leaving the test waiting forever. Production code is unchanged.

💚 How did you test it?

  • dotnet restore --locked-mode, bin/fmt --check, and the Release build passed after syncing with main.
  • The full test suite passed with dotnet test --configuration Release --no-build --nologo -- RunConfiguration.TargetPlatform=ARM64: 2,883 passed and four existing skips. Both test targets rolled forward to the installed .NET 9 runtime on this Mac.
  • The updated test passed 20 repeated runs on each target before the sync.
  • Temporarily made the background worker exit after an exception. The updated test failed on both targets without a timeout. Reverted that mutation.
  • Autoreview reported no actionable findings.

📝 Checklist

  • All commits are signed (see Commit signing)
  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

This is a test-only change. No changeset or documentation update is needed.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Pi used shell, file editing, GitHub CLI, and autoreview tools to investigate the failure and update the test in a dedicated worktree. Explicit synchronization was chosen instead of increasing the timeout. The regression check confirmed that the test still detects a worker stopping after a flush exception. Human review is required.

@marandaneto marandaneto self-assigned this Oct 23, 2026
@marandaneto
marandaneto marked this pull request as ready for review October 23, 2026 17:26
@marandaneto
marandaneto requested a review from a team as a code owner October 23, 2026 17:26
@github-actions

Copy link
Copy Markdown
Contributor

posthog-dotnet Compliance Report

Date: 2026-10-23T17:28:27.977888+00:00
Duration: 125017ms

✅ All Tests Passed!

47/47 tests passed


Capture Tests

✅ 30/30 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 266ms
Format Validation.Event Has Uuid ✅ 129ms
Format Validation.Event Has Lib Properties ✅ 113ms
Format Validation.Distinct Id Is String ✅ 112ms
Format Validation.Token Is Present ✅ 114ms
Format Validation.Custom Properties Preserved ✅ 119ms
Format Validation.Event Has Timestamp ✅ 111ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 121ms
Retry Behavior.Retries On 503 ✅ 8123ms
Retry Behavior.Does Not Retry On 400 ✅ 2118ms
Retry Behavior.Does Not Retry On 401 ✅ 2114ms
Retry Behavior.Respects Retry After Header ✅ 8121ms
Retry Behavior.Implements Backoff ✅ 22135ms
Retry Behavior.Retries On 500 ✅ 6119ms
Retry Behavior.Retries On 502 ✅ 6120ms
Retry Behavior.Retries On 504 ✅ 6117ms
Retry Behavior.Max Retries Respected ✅ 22117ms
Deduplication.Generates Unique Uuids ✅ 120ms
Deduplication.Preserves Uuid On Retry ✅ 6116ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 13121ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 6122ms
Deduplication.No Duplicate Events In Batch ✅ 116ms
Deduplication.Different Events Have Different Uuids ✅ 112ms
Compression.Sends Gzip When Enabled ✅ 111ms
Batch Format.Uses Proper Batch Structure ✅ 110ms
Batch Format.Flush With No Events Sends Nothing ✅ 106ms
Batch Format.Multiple Events Batched Together ✅ 116ms
Error Handling.Does Not Retry On 403 ✅ 2112ms
Error Handling.Does Not Retry On 413 ✅ 2113ms
Error Handling.Retries On 408 ✅ 6117ms

Feature_Flags Tests

✅ 17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 149ms
Request Payload.Flags Request Uses V2 Query Param ✅ 110ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 109ms
Request Payload.Flags Request Omits Authorization Header ✅ 111ms
Request Payload.Token In Flags Body Matches Init ✅ 110ms
Request Payload.Groups Round Trip ✅ 114ms
Request Payload.Groups Default To Empty Object ✅ 110ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 110ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 110ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 110ms
Request Lifecycle.No Flags Request On Init Alone ✅ 4ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 108ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 214ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 114ms
Retry Behavior.Retries Flags On 502 ✅ 1114ms
Retry Behavior.Retries Flags On 504 ✅ 1110ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 212ms

@marandaneto
marandaneto merged commit 7401c7c into main Oct 27, 2026
21 checks passed
@marandaneto
marandaneto deleted the test/deterministic-background-flush branch October 27, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants