Class LoadScenarioFromRecording

java.lang.Object
org.mockserver.load.LoadScenarioFromRecording

public class LoadScenarioFromRecording extends Object
Seeds an editable, runnable LoadScenario from traffic previously recorded by MockServer in proxy/recording mode (the RECEIVED_REQUEST entries returned by MockServerEventLog.retrieveRequests(org.mockserver.verify.Verification, java.lang.String, java.util.function.Consumer<java.util.List<org.mockserver.model.RequestDefinition>>)).

This is the "record-to-load" flagship: capture real traffic through the proxy, then replay its shape as a load test. Two modes control how the recorded requests become LoadSteps:

  • LoadScenarioFromRecording.Mode.VERBATIM (default) — one LoadStep per recorded request, in recorded order, preserving the concrete path, body and headers. An optional maxSteps truncates to the first N recorded requests (the orchestrator's loadGenerationMaxSteps also caps).
  • LoadScenarioFromRecording.Mode.TEMPLATIZED — recorded requests are deduplicated by (method, templatised-path) using the SHARED MetricLabels.routeOf(String) templatizer (e.g. /orders/123 and /orders/456 collapse to one /orders/{id} route), keeping one representative example per unique route, ordered by descending hit frequency (most-hit routes first). One LoadStep is emitted per unique route, each carrying that route's observed hit COUNT as its weight, and the generated scenario is marked WEIGHTED so each iteration picks a route in proportion to its recorded frequency — reproducing the recorded traffic MIX.

Target precedence for where each generated request is sent (carried as the request's Host header and secure flag, the routing surface every load step uses):

  1. an explicit LoadScenarioFromRecording.Target supplied by the caller (applied to every step), else
  2. each recorded request's existing routing is left untouched — recorded proxied requests already carry their upstream target (Host header / secure flag).

When the caller supplies no LoadProfile the same conservative default as LoadScenarioFromOpenAPI is applied — a single short constant-VU stage — so the generated scenario is immediately runnable yet safe; the operator is expected to edit the profile afterward.

This is a pure generator: it produces a LoadScenario object and drives no traffic.