Package org.mockserver.load
Class LoadCheck
java.lang.Object
org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
org.mockserver.model.ObjectWithJsonToString
org.mockserver.load.LoadCheck
A per-step response assertion for a
LoadStep (the load-injection equivalent of a k6
check). After a step's response returns, each check extracts a value from that response and
compares it against an expected value with a LoadCheck.Comparator. Every evaluated check is
recorded as a pass or a fail — surfacing correctness problems (e.g. a 200 carrying the wrong
body) that latency/error metrics alone hide, because a load run only ever flags 5xx/connection
errors otherwise.
Checks are observational: a failing check never fails an individual request or stops
dispatch. Instead the pass/fail counts feed the mock_server_load_checks metric and the
end-of-run report, and can trip a LoadThreshold.Metric.CHECK_FAILURE_RATE threshold (which,
with abortOnFail, can abort the run and drive a non-zero CI exit code).
Extraction reuses the shared LoadResponseExtractor primitives (the same code
LoadCapture correlation uses). A default (no checks) leaves behaviour unchanged.
getSource()— where to read the observed value from (STATUS,HEADER,BODY_JSONPATH)getHeaderName()— the header name (required forHEADER)getJsonPath()— the JSONPath (required forBODY_JSONPATH)getComparator()— how the observed value is compared togetValue()getValue()— the expected value / comparand
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow the observed value is compared to the expectedgetValue().static enumWhere in the step's response aLoadCheckreads its observed value from. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanevaluate(HttpResponse response) Evaluate this check againstresponse: extract the observed value and compare it tovaluewith thecomparator.extract(HttpResponse response) Extract the observed value fromresponseper this check'ssource, using the sharedLoadResponseExtractorprimitives.getValue()booleanisValid()True when this check is complete enough to evaluate (a source and comparator are set).static LoadCheckwithComparator(LoadCheck.Comparator comparator) withHeaderName(String headerName) withJsonPath(String jsonPath) withSource(LoadCheck.Source source) Methods inherited from class org.mockserver.model.ObjectWithJsonToString
toStringMethods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
equals, fieldsExcludedFromEqualsAndHashCode, hashCode
-
Constructor Details
-
LoadCheck
public LoadCheck()
-
-
Method Details
-
loadCheck
-
getSource
-
withSource
-
getHeaderName
-
withHeaderName
-
getJsonPath
-
withJsonPath
-
getComparator
-
withComparator
-
getValue
-
withValue
-
extract
Extract the observed value fromresponseper this check'ssource, using the sharedLoadResponseExtractorprimitives. Returnsnullwhen the source is unset or nothing matches. May throw for a malformed JSONPath — callers evaluate best-effort. -
evaluate
Evaluate this check againstresponse: extract the observed value and compare it tovaluewith thecomparator. A null comparator (nothing to assert) passes. May throw for a malformed JSONPath/regex — the orchestrator runs this inside atry/catchand treats a throw as a fail. -
isValid
public boolean isValid()True when this check is complete enough to evaluate (a source and comparator are set).
-