Search code examples
javajmeterstress-testingbeanshell

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?


Solution

  • 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