test: CB + backpressure property suites; TestStream contract honesty + when() - #295
Merged
Merged
Conversation
…B and backpressure state machines TestStream (kpipe-test): - Builder javadoc no longer claims a blanket 1:1 translation to the fluent facade; it now scopes the claim to the operator vocabulary and sink terminals, and names the deliberate differences (mutable builder, size-only toBatch per the v1 batch semantics, no onFiltered/onFailed/peekResult observers - assert through captured output, metrics(), and errors() instead). - Added the missing when(Predicate, UnaryOperator, UnaryOperator) builder method, composed exactly like the facade's when, so the transform vocabulary genuinely matches. Covered by branch-routing and null-branch-filters tests. Property tests (kpipe-consumer): - CircuitBreakerPropertyTest: random success/failure/fire-probe event sequences over windowSize 2-10 and threshold 0.3-0.9, driven through ConsumerHealthController.recordOutcome with the hand-fired scheduler seam. Asserts legal-edges-only transitions, no trip from CLOSED before the window fills, and outcomes-while-OPEN are fully ignored - no wall clock involved, the probe firing is an explicit generated event. - BackpressureHysteresisPropertyTest: random in-flight walks 0-20k over high watermarks 100-10000 (low = 70% of high), driven through BackpressureController.check with the paused-flag feedback loop the consumer runs. Asserts pause only at/above high, resume only at/below low, and strict pause/resume alternation (no flapping in the band).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #295 +/- ##
============================================
- Coverage 79.79% 79.66% -0.14%
+ Complexity 1075 1073 -2
============================================
Files 86 86
Lines 3599 3604 +5
Branches 440 441 +1
============================================
- Hits 2872 2871 -1
- Misses 546 550 +4
- Partials 181 183 +2 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Architecture-pass items #14 + #15.
Property tests (the two state machines that had only example-based coverage):
CircuitBreakerPropertyTest— 3 properties × 200 tries over random outcome/probe sequences (window 2–10, threshold 0.3–0.9): only legal edges ever observed; never trips before the window fills; outcomes while OPEN are ignored. Fully deterministic — the OPEN→HALF_OPEN probe is a captured-scheduler event, not wall clock. Zero skipped invariants.BackpressureHysteresisPropertyTest— 2 properties × 200 tries over random load walks (0–20k) and watermark pairs: pause only at/above high, resume only at/below low, strict pause/resume alternation (no flapping inside the band).TestStream contract — the Builder's "translates 1:1 to a KPipe.X chain" claim was partially false. Now scoped to what is true (operator vocabulary + terminals), with the deliberate differences named (mutable builder, size-only
toBatch, no observers — assert via captured output/metrics/errors). And the transform vocabulary is now genuinely complete:when(predicate, ifTrue, ifFalse)added, composed identically toDefaultStream.when, with branch + null-filter tests.kpipe-test 43/43; consumer property tests green (two known Testcontainers launch flakes pass in isolation).