Class Expect

java.lang.Object
org.acemq.workloads.scenario.Expect

public final class Expect extends Object
What a scenario is asked to prove.

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 Details

    • Expect

      public Expect()
  • Method Details

    • p50Below

      public Expect p50Below(Duration limit)
      Parameters:
      limit - the median must stay under this
      Returns:
      this expectation
    • p99Below

      public Expect p99Below(Duration limit)
      Parameters:
      limit - the 99th percentile must stay under this
      Returns:
      this expectation
    • p999Below

      public Expect p999Below(Duration limit)
      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

      public Expect consumeRateAtLeast(long rate)
      Parameters:
      rate - this queue's consumers must handle at least this many a second
      Returns:
      this expectation
    • achievedRateAtLeast

      public Expect achievedRateAtLeast(long rate)
      Parameters:
      rate - this producer must actually offer at least this many a second
      Returns:
      this expectation
    • withinPercentOfOffered

      public Expect withinPercentOfOffered(int percent)
      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

      public Expect noFailures(boolean required)
      Parameters:
      required - whether every publish must succeed
      Returns:
      this expectation
    • noBacklog

      public Expect noBacklog(boolean required)
      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

      public Duration p50BelowValue()
    • p99BelowValue

      public Duration p99BelowValue()
    • p999BelowValue

      public Duration p999BelowValue()
    • consumeRateAtLeastValue

      public Long consumeRateAtLeastValue()
    • achievedRateAtLeastValue

      public Long achievedRateAtLeastValue()
    • withinPercentOfOfferedValue

      public Integer withinPercentOfOfferedValue()
    • requiresNoFailures

      public boolean requiresNoFailures()
    • requiresNoBacklog

      public boolean requiresNoBacklog()
    • isEmpty

      public boolean isEmpty()
      Returns:
      whether anything at all is being asked for
    • toString

      public String toString()
      Overrides:
      toString in class Object