8000 test(capture): wait for the status condition, not a fixed event-loop budget by shroominic · Pull Request #203 · shroominic/OpenGlucose · GitHub
[go: up one dir, main page]

Skip to content

test(capture): wait for the status condition, not a fixed event-loop budget - #203

Closed
shroominic wants to merge 1 commit into
release/v0.4.0from
fix/protocol-capture-status-flake
Closed

shroominic wants to merge 1 commit into
release/v0.4.0from
fix/protocol-capture-status-flake

Conversation

@shroominic
Copy link
Copy Markdown
Owner

Closes #198.

The defect

openhealth/test/protocol_capture_status_test.dart fired the heartbeat timer twice and then counted
statuses after a fixed 40 event-loop turns:

timers.last
  ..fire()
  ..fire();
await pumpEventQueue(times: 40);

final healthyBeforeConnect = _healthyStatuses(statuses);
expect(healthyBeforeConnect.length, greaterThanOrEqualTo(3));

The status writer commits through real asynchronous work, so on a loaded runner those turns can
finish before the writes land. The Unit check — a required release gate — then fails on a test
budget rather than on a product contract:

❌ protocol_capture_status_test.dart: publishes exact fail-closed schema and advancing health proofs (failed)
Expected: a value greater than or equal to <3>
  Actual: <0>

Evidence that this is load-dependent and not a regression: the same Unit job passed on head
018dd90 (run 35310179815 job 105490417714) and failed on the next head a084d8f
(run 35312259964 job 105496537847), while git diff --name-only 018dd906..a084d8f touches no file
this test imports. Five consecutive local runs of the file, and two full local test-unit runs,
pass.

Change

_pumpUntil() pumps in small chunks until the condition holds, bounded by a wall-clock timeout so a
real hang still fails the following assertion with the real evidence. The strictly-advancing
assertions this feeds are unchanged, and no production file is touched.

Verification

Command Result
flutter test test/protocol_capture_status_test.dart 3/3 pass
flutter test test/ 483 passed, twice
dart format --output=none --set-exit-if-changed on the file exit 0
scripts/flutter-workspace.sh format-check (all projects) exit 0

Not covered

The publisher's behaviour is unchanged; this fixes the test's budget, not a product race. If a real
hang ever occurs, the assertion after _pumpUntil still fails loudly.

…budget

Closes #198.

The Unit gate failed on protocol_capture_status_test.dart:123 with
'Expected: a value greater than or equal to <3> / Actual: <0>' on head a084d8f,
while the same job passed on 018dd90 with the same test and the same app sources
for this path. The test fired its heartbeat timer twice and then counted statuses
after a fixed 40 event-loop turns; the status writer commits through real
asynchronous work, so a loaded runner can finish those turns before the writes
land.

_pumpUntil() pumps in small chunks until the condition holds, bounded by a
wall-clock timeout so a real hang still fails the following assertion with the
real evidence. The strictly-advancing assertions are unchanged.

Verification:
- flutter test test/protocol_capture_status_test.dart 3/3 pass
- flutter test test/ (483 tests) pass twice
- dart format --set-exit-if-changed lib test integration_test exit 0
@shroominic
Copy link
Copy Markdown
Owner Author

Verification note: the red checks on this PR are release/v0.4.0's pre-existing baseline, not this change. Each one is fixed on the release lane, which is where this fix was integrated (92a1de2, PR #163) and where Unit now passes (run 35313130980 job 105499080564, 3m6s).

Red check here Cause on this base Fixed on the lane by
Unit Tests 13 test/private_bench_test.dart failures (Expected: <65> etc.) — the private-bench host scope #183 (and #179 for the macOS scoping), absorbed in #163
Integration Tests Integration tests and unit tests cannot be run in a single invocation — the workspace runner #141's content, carried as a cherry-pick in #163
iOS Build and Native Tests the iOS build changed ios/Podfile.lock — the lane's integration_test pod entry #180, absorbed in #163

This PR touches exactly one test file and no production code:

openhealth/test/protocol_capture_status_test.dart | 23 +++++++++++++++++++++-

Locally on this branch: flutter test test/protocol_capture_status_test.dart 3/3 pass, flutter test test/ 483 pass twice, and scripts/flutter-workspace.sh format-check exit 0. The gate evidence that matters for it is the integrated Unit check on #163.

@shroominic
Copy link
Copy Markdown
Owner Author

Carried by the GS1 consolidation in PR #209 (branch feature/cbio-gs1, head 3eca4f4).

This PR is contained in the consolidated line; the merge that carries it is c85f827.

Closing as subsumed by the consolidation - not as won't fix. The per-defect evidence stays in this thread, and the carrying commit above is where the change now lives.

@shroominic shroominic closed this Sep 18, 2026
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.

1 participant

0