Class Expect
Without these a scenario can only ever describe what happened, which is enough for somebody watching and not enough for a pipeline: a build cannot be failed on a description. An expectation turns a run into an answer — this queue's p99 stays under 50ms, this producer loses nothing, this backlog does not grow — and the command line's exit code follows.
Per node, not for the whole run. A scenario's interesting property is usually asymmetric: the audit leg may lag as much as it likes while the fulfilment leg must not. An overall p99 would average exactly the distinction worth keeping.
Every field is optional. What is not stated is not checked, because an expectation nobody wrote is not one the run failed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionachievedRateAtLeast(long rate) consumeRateAtLeast(long rate) booleanisEmpty()noBacklog(boolean required) The queue must not be deeper at the end than it was at the start.noFailures(boolean required) The tail, which is where a queue's real behaviour shows.booleanbooleantoString()withinPercentOfOffered(int percent) How far the achieved rate may fall short of the offered one.
-
Constructor Details
-
Expect
public Expect()
-
-
Method Details
-
p50Below
- Parameters:
limit- the median must stay under this- Returns:
- this expectation
-
p99Below
- Parameters:
limit- the 99th percentile must stay under this- Returns:
- this expectation
-
p999Below
The tail, which is where a queue's real behaviour shows.- Parameters:
limit- the 99.9th percentile must stay under this- Returns:
- this expectation
-
consumeRateAtLeast
- Parameters:
rate- this queue's consumers must handle at least this many a second- Returns:
- this expectation
-
achievedRateAtLeast
- Parameters:
rate- this producer must actually offer at least this many a second- Returns:
- this expectation
-
withinPercentOfOffered
How far the achieved rate may fall short of the offered one.The useful shape for a producer, because the number that matters is relative: a generator that offered 19,400 of 20,000 did its job, and one that offered 12,000 did not, and neither is expressible as a fixed floor that survives changing the rate.
- Parameters:
percent- the allowed shortfall, so 5 means at least 95% of what was asked for- Returns:
- this expectation
-
noFailures
- Parameters:
required- whether every publish must succeed- Returns:
- this expectation
-
noBacklog
The queue must not be deeper at the end than it was at the start.Not checked for a stream, which retains what it has served and is always "deeper".
- Parameters:
required- whether the backlog must not grow- Returns:
- this expectation
-
p50BelowValue
-
p99BelowValue
-
p999BelowValue
-
consumeRateAtLeastValue
-
achievedRateAtLeastValue
-
withinPercentOfOfferedValue
-
requiresNoFailures
public boolean requiresNoFailures() -
requiresNoBacklog
public boolean requiresNoBacklog() -
isEmpty
public boolean isEmpty()- Returns:
- whether anything at all is being asked for
-
toString
-