Class LoadCheck


public class LoadCheck extends ObjectWithJsonToString
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.

  • Constructor Details

    • LoadCheck

      public LoadCheck()
  • Method Details

    • loadCheck

      public static LoadCheck loadCheck()
    • getSource

      public LoadCheck.Source getSource()
    • withSource

      public LoadCheck withSource(LoadCheck.Source source)
    • getHeaderName

      public String getHeaderName()
    • withHeaderName

      public LoadCheck withHeaderName(String headerName)
    • getJsonPath

      public String getJsonPath()
    • withJsonPath

      public LoadCheck withJsonPath(String jsonPath)
    • getComparator

      public LoadCheck.Comparator getComparator()
    • withComparator

      public LoadCheck withComparator(LoadCheck.Comparator comparator)
    • getValue

      public String getValue()
    • withValue

      public LoadCheck withValue(String value)
    • extract

      public String extract(HttpResponse response)
      Extract the observed value from response per this check's source, using the shared LoadResponseExtractor primitives. Returns null when the source is unset or nothing matches. May throw for a malformed JSONPath — callers evaluate best-effort.
    • evaluate

      public boolean evaluate(HttpResponse response)
      Evaluate this check against response: extract the observed value and compare it to value with the comparator. A null comparator (nothing to assert) passes. May throw for a malformed JSONPath/regex — the orchestrator runs this inside a try/catch and 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).