Dominick Navarro
Dominick Navarro

Reputation: 752

JMeter go back to previous sampler

I am quite new to jmeter, I am using it to load test an application. My current setup is good if running few threads at a time but gets problems when more users get connected.

Here's the scenario,

sample_1: request table data
sample_2: set table row with empty user column as used by current user
    |
    '-->post_process_beanshell: check if have error message
sample_3: do other stuff

Currently I am able to check if the 2nd sample has an error message, the question is how do I tell beanshell to go back to 1st sample when the 2nd sample has an error message?

Upvotes: 3

Views: 788

Answers (2)

Dmitri T
Dmitri T

Reputation: 168072

I would recommend put your "sample_3" under If Controller like:

  • Loop Controller (define maximum number of n-tries)
    • sample_1
    • sample_2
      • post_process_beanshell
    • If Controller: condition ${JMeterThread.last_sample_ok}
      • sample_3

JMeterThread.last_sample_ok - is a pre-defined variable which returns "true" if previous sampler was successful and "false" if not so if your "sample_2" will fail - "sample_3" won't be executed and the whole sequence will start over

Upvotes: 2

RaGe
RaGe

Reputation: 23677

Assuming you want to keep going back to sampler1 until sampler2 beanshell returns true, use a While controller.

Stick both sampler1 and sampler2 in a while controller which is conditional on the result of your error check.

Upvotes: 1

Related Questions