Class LoadScenarioReport

java.lang.Object
org.mockserver.load.LoadScenarioReport

public final class LoadScenarioReport extends Object
Builds an end-of-run summary report for a load scenario from a single LoadScenarioOrchestrator.LoadScenarioStatus snapshot (the live snapshot for a running run, or the retained terminal snapshot for a finished one).

Two equivalent renderings are produced from the same data:

  • toJson(LoadScenarioStatus) — a machine-readable JSON document (built with the shared ObjectMapperFactory mapper) carrying counts, latency percentiles, the threshold verdict and per-threshold results.
  • toJUnitXml(LoadScenarioStatus) — a JUnit-XML <testsuite> so a load run becomes a first-class CI artifact: one <testcase> per threshold (a breach produces a <failure>), plus a run completed testcase that fails on an error-caused terminal state or an abortOnFail abort. p95/p99/error-rate are surfaced as <properties>.

The XML is hand-built and XML-escaped (no new dependency) so a scenario name containing & < > " ' is rendered safely.

The report is derived purely from existing LoadScenarioOrchestrator.LoadScenarioStatus fields; it adds no new tracking to the hot path.

  • Method Details

    • errorRate

      public static double errorRate(LoadScenarioOrchestrator.LoadScenarioStatus status)
      Error rate for a run: failed requests as a fraction of the requests that have actually completed (failed / max(1, succeeded + failed)). The denominator is the completed count, not requestsSent, so an in-flight (dispatched-but-not-yet-completed) request — which can exist in a snapshot taken while the run is still draining — never dilutes the rate as if it were a success. A run with no completed request reports 0 rather than dividing by zero. This matches the ERROR_RATE threshold metric computed in LoadScenarioOrchestrator.evaluateThresholds.
    • runFailed

      public static boolean runFailed(LoadScenarioOrchestrator.LoadScenarioStatus status)
      True when the run is in a terminal state that should be treated as a CI failure: it was aborted by an abortOnFail threshold breach, it carries a FAIL verdict, or it stopped while having recorded request failures. A clean COMPLETED/STOPPED run with no failures is a pass.
    • toJson

      public static String toJson(LoadScenarioOrchestrator.LoadScenarioStatus status)
      Build the JSON summary report for a run.
    • toJUnitXml

      public static String toJUnitXml(LoadScenarioOrchestrator.LoadScenarioStatus status)
      Build the JUnit-XML summary report for a run. The suite has one testcase per threshold plus a run completed testcase; breached thresholds and a failed run carry a <failure>.