For the complete documentation index, see llms.txt. This page is also available as Markdown.
Load TestingK6LocustJmeter

Script Validation

Understand how Harness checks a Python, JavaScript, or Java load test script before you save it, how to read errors and warnings, and when to skip validation in Harness Resilience Testing

When you upload or edit a script in the Load Test Studio, Harness checks it before you save. Mistakes that would otherwise fail the run, such as a syntax error, a file the runner cannot read, or a threshold on a metric that does not exist, show up under the script within seconds, each with the line it is on and a suggested fix. You find out while you are still editing, instead of minutes into a run.

LOAD TESTING IS BEHIND A FEATURE FLAG

Load Testing is behind a feature flag (CHAOS_LOAD_TESTING_ENABLED). Contact Harness Support to enable it.

What you will learn from this topic

  • When Harness checks a script, and which scripts it checks.

  • How to read the validation status, errors, and warnings.

  • What happens when a save is rejected, and how to fix it.

  • When to save a script with Skip validation, and which checks still apply.

  • What the most common findings mean for each Load Test Engine.


When Harness checks a script

Harness checks the script at two moments:

  • While you work. Shortly after you upload a file, edit the script inline, or change the infrastructure, Harness checks the script and updates the status next to the file name. You do not need to do anything to start the check.

  • When you save. Harness checks the script again when you create, edit, or clone a load test, and when you create or edit a load test template. A script with errors is not saved. If you edit a test without changing its script, the script is not checked again.

Validation applies to scripts that you upload or write in the studio:

  • Python: the Locust file you upload.

  • JavaScript: the k6 script you upload, including a script Harness converts from a HAR recording.

  • Java: the .jmx or .xml test plan, or the ZIP workspace with the plan, its data files, and plugin jars.

Harness does not check a test that uses Custom Image mode, because the script is inside your image.

VALIDATION NEVER BLOCKS A RUN

Validation applies only when you save. Tests saved before script validation was available, and tests saved with Skip validation, still run.


Read the validation status

The status appears next to the script file name on the Test Configuration tab:

Status
What it means

Validating script…

Harness is checking the script.

Validated

Harness found no problems.

Errors: N

The script has problems that would make the run fail. You cannot save until you fix them or skip validation.

Warnings: N

The script runs, but something in it can give misleading results or slow the test down. You can save.

Not fully validated

Some checks did not finish, so the script can still fail when the test runs.

Validation unavailable

Harness could not reach the validation service. You can still save, and Harness checks the script again on save.

When the script has findings, Harness lists them under the script in Script validation findings. Each finding shows:

  • Where it is: the line and column, such as 7:23. For a ZIP workspace, the file name comes first, such as plans/checkout.jmx:42.

  • What is wrong: a sentence that describes the problem.

  • How to fix it: a suggestion in grey under the problem.

  • The rule code: an identifier such as K6_OPEN_RELATIVE. Use it when you search this page or contact Harness Support.

An error has a red icon, and a warning has an orange icon. If the script has many findings, the list shows the first ones and says how many there are in total. Fix those, and the rest appear.

For a JavaScript script with errors, the load profile preview under Load Profile Overrides shows the first error instead of the graph until you fix it.

Errors

An error is a problem that would make the test fail, or make it run without sending any load. Harness rejects a save while the script has errors.

In the following example, the k6 script reads a file next to the script, which the runner does not receive, and sets a threshold on a metric that the script never creates:

The Test Configuration tab with a k6 script marked Errors: 2, and the Script validation findings panel under it listing K6_OPEN_RELATIVE and K6_UNKNOWN_THRESHOLD_METRIC with their lines, messages, and hints, followed by the Skip validation checkbox

Warnings

A warning points out something that does not stop the test but that you probably want to change, such as a listener that slows JMeter down, or an HTTP request without timeouts. Warnings never block a save. After you save, Harness reminds you how many warnings the script still has, and the warnings stay listed under the script.

In the following example, the JMeter plan has no connect or response timeout, so a stalled server can hold threads for the whole test:

The Test Configuration tab with a JMeter test plan marked Warnings: 1, and the Script validation findings panel under it listing JMETER_MISSING_HTTP_TIMEOUTS with the hint to set both timeouts in HTTP Request Defaults

Fix a rejected save

If you click Save while the script has errors, Harness does not save the test. A message tells you how many errors the script has, and the findings panel is titled The save was rejected because of these findings.

A red message saying "The script has 2 validation error(s). Fix them or select Skip validation, then save again." above the Test Configuration tab, where the findings panel is titled The save was rejected because of these findings

To save the test, perform the following steps:

  1. Read each error, and go to the line it points to.

  2. Fix the script by following the hint. Click Edit inline to change the script in the studio, or fix it in your editor and click Replace to upload it again.

  3. Wait for the status to change to Validated or Warnings: N.

  4. Click Save again.

If you cannot fix an error yet, you can save without validation.


Save without validation

When the script has errors, a Skip validation checkbox appears under the findings. Select it, then click Save, to save the script without the syntax, structure, and dependency checks.

Use it only when you are sure the script works where it runs, for example:

  • The finding is about something Harness cannot see, such as a dependency that your environment provides.

  • Validation did not finish, and you do not want to wait to save the test.

The script can still fail when the test runs, so run it once and check the result.

The checkbox disappears when the script no longer has errors, and it does not apply to a later save once the errors are gone.

Checks that still apply

Skip validation does not turn off the checks that protect the runner or the test settings. Harness still rejects the save when:

  • The script is too large. Split the script, or package it in a custom image and use Custom Image mode.

  • The ZIP workspace is unsafe or too large. For example, an entry points outside the workspace, appears twice, or unpacks to far more than its compressed size.

  • The JMeter plan declares a <!DOCTYPE> with entities. JMeter never needs one, so remove the declaration.

  • The script contains a runtime input or a secret expression. <+input> and <+secrets...> are not resolved inside a script body. Replace the expression with a value, or define a variable and read it in the script.

  • The test settings are invalid. For example, the ramp-up is longer than the test duration.


Dependencies and your infrastructure

Some findings are about something the script needs from the runner, such as a JMeter plugin jar, a k6 extension, a Python package, or a data file. How serious they are depends on where the test runs:

  • Kubernetes: Harness runs the script in its own runner image, which has only the engine and its standard libraries. A missing dependency makes the run fail, so the finding is an error.

  • Linux VM, or a template without infrastructure: Harness cannot tell what is installed on the machine, so the same finding is a warning.

When you change the infrastructure of a test, Harness checks the script again, and the status can change from Warnings to Errors or back.

To use a dependency on Kubernetes, bundle it with the script where the engine allows it, or build a custom runner image that contains it and use Custom Image mode.


Common findings

The following tables list the findings you are most likely to see for each engine. The hint in the findings panel always tells you how to fix the specific problem.

Rule
What it means
How to fix it

LOCUST_SYNTAX

The file is not valid Python.

Fix the line shown. Harness runs the other checks once the syntax is fixed.

LOCUST_PYTHON_VERSION

The script uses Python syntax that is newer than the runner's Python 3.9.

Rewrite that part for Python 3.9.

LOCUST_NO_USER_CLASS

The file defines no class that Locust can start, so Locust stops with "No User class found!".

Add a class that extends HttpUser, FastHttpUser, or User.

LOCUST_USER_WITHOUT_TASKS

A user class has no tasks, so Locust fails it.

Add a method decorated with @task, or set tasks = [...].

LOCUST_UNKNOWN_IMPORT

The script imports a module that is not in the Python standard library or installed with Locust, or a helper file next to the script. The runner receives only the Locust file.

Put the code in the Locust file, or use a runner image that installs the package.

LOCUST_UNDEFINED_NAME

The script uses a name that is never imported or defined, so Locust fails with NameError.

Import or define the name before you use it.

LOCUST_MODULE_OPEN

The script opens a file when Locust loads it, and the file is not on the runner.

Put the data in the script, or read it inside a task or on_start and handle a missing file.

LOCUST_INVALID_HOST

The host of a user class is not an http:// or https:// URL, so every request fails.

Use a full URL, such as https://api.example.com.

LOCUST_INVALID_WAIT_TIME

The wait_time is not a wait function, waits a negative time, or has its minimum above its maximum.

Use a function such as between(1, 3) or constant(1).

LOCUST_INVALID_WEIGHT

A user class or task has a weight of 0 or less, so Locust never runs it.

Set the weight to 1 or more.

Rule
What it means
How to fix it

K6_SYNTAX

The file is not valid JavaScript.

Fix the line shown. Harness runs the other checks once the syntax is fixed.

K6_TYPESCRIPT

The script is written in TypeScript, but k6 runs it as JavaScript.

Compile it to JavaScript first, for example with esbuild, and upload the .js file.

K6_NO_ENTRYPOINT

The script has no default function, so k6 has nothing to run.

Add export default function () { ... }, or set exec on every scenario.

K6_NOT_IMPORTED

The script calls a function, such as check() or sleep(), that it never imports.

Add the import, for example import { check } from 'k6'.

K6_OPEN_RELATIVE

open() reads a file next to the script, but the runner receives only the script.

Put the data in the script, for example as a JSON literal.

K6_RELATIVE_IMPORT

The script imports a local module, which the runner does not receive.

Put the module in the script, or import it from an https:// URL.

K6_BARE_IMPORT

The script imports an npm package by name, which k6 cannot resolve.

Bundle the package into the script, or import it from a URL such as https://jslib.k6.io.

K6_EXTENSION_MODULE

The script imports a k6 extension (xk6), and the Harness runner has none.

Use a custom runner image whose k6 build includes the extension.

K6_BROWSER_MODULE

The script uses k6/browser, and the Harness runner has no browser.

Use a custom runner image that includes Chromium.

K6_HTTP_IN_INIT

A request runs at the top level of the script, where k6 cannot send requests.

Move the request into the default function, or into setup().

K6_UNKNOWN_THRESHOLD_METRIC

A threshold uses a metric that is not built into k6 and that the script never creates.

Fix the metric name, or create the metric with new Trend(), Counter(), Rate(), or Gauge().

K6_INVALID_THRESHOLD

A threshold is not a valid expression.

Use an aggregation, an operator, and a number, such as p(95)<500.

K6_INVALID_DURATION

A duration cannot be read.

Use a duration such as 30s, 5m, or 1h30m.

K6_UNKNOWN_OPTION

An option is not a k6 option, so k6 ignores it.

Fix the spelling. Harness suggests the closest option when there is one.

K6_REMOTE_IMPORT (warning)

The script downloads a module from a URL when the test starts.

Make sure the runner can reach the host, and pin a version in the URL.

Rule
What it means
How to fix it

JMETER_XML_MALFORMED

The plan is not well-formed XML, so JMeter cannot load it.

Save the plan again from JMeter, without editing it by hand.

JMETER_NOT_A_PLAN

The file is not a JMeter test plan.

Upload the .jmx file that JMeter saved.

JMETER_NO_ENABLED_THREAD_GROUP

No thread group is enabled, so JMeter starts and sends nothing.

Enable a thread group, or add one under the test plan.

JMETER_NO_SAMPLER

No enabled thread group has an enabled sampler, so JMeter sends nothing.

Add or enable a sampler, such as an HTTP Request.

JMETER_HTTP_NO_HOST

An HTTP Request has no server, and no HTTP Request Defaults supplies one.

Set Server Name or IP, or add HTTP Request Defaults with the server.

JMETER_HTTP_INVALID_URL

An HTTP Request has a full URL or spaces in the server or path field.

Put only the host in Server Name or IP, and only the URL-encoded path in Path.

JMETER_UNRESOLVED_CLASS

The plan uses an element from a plugin that the runner does not have, such as a Concurrency Thread Group.

Upload a ZIP with the plugin jar directly under lib/.

JMETER_JAR_IN_SUBFOLDER

A plugin jar is in a subfolder of lib/, where JMeter does not load it.

Move the jar directly under lib/.

JMETER_CSV_MISSING

A CSV Data Set reads a file that is not in the ZIP workspace.

Add the file to the ZIP, with a path relative to the plan.

JMETER_CSV_ABSOLUTE

A CSV Data Set reads an absolute path, which exists only in a custom runner image.

Put the file in the ZIP workspace, and use a path relative to the plan.

JMETER_RAMP_UP_EXCEEDS_DURATION

A thread group ramps up for longer than it runs, so not every thread starts.

Make the ramp-up shorter than the duration.

JMETER_MISSING_HTTP_TIMEOUTS (warning)

HTTP requests have no connect or response timeout, so a stalled server can hold threads for the whole test.

Set both timeouts in HTTP Request Defaults.

JMETER_ACTIVE_GUI_LISTENER (warning)

A listener, such as View Results Tree, keeps every result in memory and slows the test down.

Disable or remove it. Harness collects the results for you.

JMETER_LEGACY_BEANSHELL (warning)

An element uses BeanShell, which is slow under load.

Use a JSR223 element with Groovy instead.


Troubleshooting

The status shows Not fully validated

Harness could not finish checking the script, for example because the check took too long or the validator was busy with other large scripts. Save again in a moment. If the status does not change, select Skip validation to save the script unchecked, and run the test once to confirm it works.

The status shows Validation unavailable

Harness could not reach the validation service. You can still click Save, and Harness checks the script on save. If the save is rejected, fix the errors it lists.

A finding says a file is not sent to the runner

On Kubernetes, the runner receives only the script, or for Java, the ZIP workspace. A file next to the script on your machine is not included. For JavaScript and Python, put the data in the script. For Java, upload a ZIP with the plan and the file, and use a path relative to the plan. To use a file you cannot include, build a custom runner image that contains it.

The save is still rejected after I select Skip validation

Some checks always apply, such as the script size, ZIP safety, input and secret expressions, and the test settings. Read the message that appears, and go to Checks that still apply to fix it.

I do not see the Skip validation checkbox

The checkbox appears only when the script has errors. A script with only warnings saves without it.

The script works on my machine but shows an error

Your machine may have plugins, extensions, packages, or files that the Harness runner does not have. Read the hint of the finding, and go to Dependencies and your infrastructure to decide how to supply the dependency.


Next steps

Last updated

Was this helpful?