Use of more than JSR223 pre-processor in Taurus/JMeter plan

179 views
Skip to first unread message

Software Tester

unread,
May 9, 2023, 1:17:29 PM5/9/23
to codename-taurus
Hi -

Does Taurus support more than one before/after type JSR223 block in a single scenario? More than one script file?

Example, with apologies - the text formatting tools seem to remove all YAML indentation, there is no option to format as code, etc.

    requests:
      - url: /dummy/sampler
        method: GET
        jsr223:
        - language: groovy
          #script-file: script/conc_proto.groovy
          script-text: |
            import org.apache.jmeter.threads.JMeterVariables
            JMeterVariables vars = ctx.getVariables()
            Integer local_count = vars.get('count1').toInteger()
            local_count++
            log.info(local_count)
            vars.put('count1',local_count)
            execute: before
        jsr223:
        - language: groovy
          #script-file: script/conc_proto.groovy
          script-text: |
            import org.apache.jmeter.threads.JMeterVariables
            JMeterVariables vars = ctx.getVariables()
            Integer local_count = vars.get('count1').toInteger()
            count2++
            log.info(count2)
            vars.put('count1',local_count)
            execute: before
        sampler:
          classname: com.blazemeter.jmeter.citrix.client.Sampler
          arguments: []

DT

unread,
May 9, 2023, 2:18:18 PM5/9/23
to codename-taurus
Does Taurus support more than one before/after type JSR223 block in a single scenario? It does, here is a minimal working demo:


execution:
- scenario: jsr-example

scenarios:
jsr-example:
requests:
jsr223:
- language: groovy
script-text: "log.info('First')"
execute: after
compile-cache: true
- language: groovy
script-text: "log.info('Second')"
execute: after

It will result into the following JMeter test plan:
Untitled.jpg

More than one script file? No because JMeter doesn't support it

If you're facing problems with your 2nd PreProcessor not executing - it's because your count2 variable is not defined. You can get more information regarding the failure in jmeter.log file which is in your Taurus artifacts directory.You can also launch JMeter GUI like bzt your-test.yaml -gui

It will make your script debugging process faster and easier.

Software Tester

unread,
May 10, 2023, 10:48:00 AM5/10/23
to codename-taurus
Well, immediately I see one issue - re-using the jsr223 block initializing keyword. I didn't realize that you defined multiple scripts under the single block heading. Thanks!
Reply all
Reply to author
Forward
0 new messages