Reputation: 927
Currently experimenting with swapping out a couple of powershell warm up commands for our web app to use jmeter test plans. The features look much improved and execute significantly quicker.
I am executing the test plans using the non-gui mode through octopus deploy. How can i get the task to quit reporting failure when it encounters a http error status code? I need the job to report as failure on encountering an error and mark the task as complete if any of my hosts return anything other than a http success code?
We are using DFS across 20+ hosts and the existing powershell works as a good check that everything has replicated and working before we bring the new instances live (using blue/green deployment).
Upvotes: 0
Views: 399
Reputation: 168157
Put the following code into "Script" area:
if ((prev.getResponseCode() as int) > 399) {
System.out.println('HTTP status code for URL: ' + prev.getUrlAsString() + ' was ' + prev.getResponseCode())
System.exit(-1)
}
That's it, when you run your test and get HTTP Status code 400 or higher - the JSR223 Assertion will terminate the test and return non-zero exit status code
More information: Scripting JMeter Assertions in Groovy - A Tutorial
Upvotes: 1