How to run scenarios one by one using taurus

1,666 views
Skip to first unread message

absha...@gmail.com

unread,
Oct 6, 2015, 10:23:08 AM10/6/15
to codename-taurus
Need the execute 2 scenarios one by one.
 
Scenario 1 (Initial environment setup jmx– need to be run only once per test )
Scenario 2 (Should start after Scenario 1 ends)
Scenario2 has multiple thread group which runs in parallel.


Below code executes scenarios in parallel but I need scenarios to be executed one by one.

---
execution:
 - scenario: 
     script: my1.jmx
 - scenario: 
     script: my2.jmx
 
 
Can you please let me know how to config this in Taurus ?
 
 
 
 
Thanks,
AB Shanthosh

Andrey Pokhilko

unread,
Oct 6, 2015, 10:36:59 AM10/6/15
to codenam...@googlegroups.com
Hi,

To have sequential execution, just execute bzt multiple times in command line.

Andrey Pohilko
Chief Scientist
P: +7 (909) 631-21-69
BlazeMeter

absha...@gmail.com

unread,
Oct 6, 2015, 11:35:17 AM10/6/15
to codename-taurus
Thanks for the quick response.

grose.m...@gmail.com

unread,
Apr 19, 2016, 7:47:09 PM4/19/16
to codename-taurus
Hey Andrey,

To clarify where my head went with your advice, in the context of step 1. authenticating for an api (runs once). step 2. running the test:  would the recommended way be to have the first bzt execution output a file with authentication tokens that a latter bzt run would consume? 

Or would there be other ways to pass the authentication tokens along?

Thanks
MG

Andrey Pokhilko

unread,
Apr 20, 2016, 4:46:26 AM4/20/16
to codenam...@googlegroups.com
Well, I don't have full picture of what you do, but I assume you don't need anything from first execution except those authentication tokens. So I'd make first execution to write the CSV file with tokens and second to use this file as data source.

I'd even not to use JMeter for the token generating, usually python/shell scripts are more efficient. Having script generating tokens allows you to use Taurus "shell exec" service to invoke it before each test start. http://gettaurus.org/docs/Services/#Shell-Executor-Service-Module

Andrey Pohilko
Chief Scientist
P: +7 (909) 631-21-69
BlazeMeter Inc.
--
You received this message because you are subscribed to the Google Groups "codename-taurus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codename-taur...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codename-taurus/08243851-5641-4e43-b5fe-491270fb2bc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

grose.m...@gmail.com

unread,
Apr 20, 2016, 10:56:14 AM4/20/16
to codename-taurus
Ah interesting, i'll dig into the shell exec service and see how it goes.

Very appreciative of the fast reply!

Ram

unread,
Oct 19, 2023, 12:56:38 PM10/19/23
to codename-taurus
Hello,
I am also looking for a solution for similar issue ("I don't need anything from first execution except those authentication tokens."
I have two scenarios, first scenario has the token and the second one need to use it. 
Tried several ways, but didn't worked. This works fine with local variables declared in single Scenario.
Got to know that this can be implemented using '__StringToFile' function/ or by write/read to csv., but I am not able to invoke this from taurus yml file.
Could you please share a sample snippet to write/ read from csv or to use __StringToFile.  or any better way, in thread safe manner.

DT

unread,
Oct 19, 2023, 2:37:45 PM10/19/23
to codename-taurus
If you're looking for Taurus-only solution you can consider using JSR223 blocks


Code snippet to write variable into a file:

new File('file.txt').text = vars.get('your-variable-name')

Code snippet to read the file into a variable:

vars.put('your-variable-name', new File('file.txt').text

More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?

Ram

unread,
Oct 20, 2023, 4:44:22 AM10/20/23
to codename-taurus
Thank you for the response.

Yes, I am looking only for Taurus solution. Not doing anything from jmeter directly.

scenarios:

  scenario1:

    requests:

           - url: 

             extract-jsonpath:

                   userToken: $.access_token

              jsr223: 'vars.put("tokenVar", ${userToken})’.      

             [[ Note: Also tried as below .. 

                        jsr223:

                           execute: after

                           script-text: |

                           vars.put("tokenVar", ${userToken}) ]]

         scenario2:

               requests: 

                 - url: 

                   headers:

                         Authorization: Bearer ${__base64Encode(${tokenVar})}

                            [ [ Note: Also tried to access 

                               Authorization: Bearer ${__base64Encode(${vars.get("tokenVar")})} 

                              I believe I dont have to add jsr223 block to retrieve (access) the value .. 

                            ]]


Getting error jmeter.log as below:

2023-10-20 10:37:41,555 ERROR o.a.j.e.JSR223PostProcessor: Problem in JSR223 script, JSR223PostProcessor

javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

Script1.groovy: 1: Unexpected input: '(' @ line 1, column 9.

   vars.put("tokenVar", fa6-ba1-4ff-a29-5d782)

           ^

1 error

    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.compile(GroovyScriptEngineImpl.java:183) ~[groovy-jsr223-3.0.7.jar:3.0.7]


Also explored the option to write file provided above.

As I cannot use put (due to above error), I coudnt write to file using solution provided above-- > new File('file.txt').text = vars.get('your-variable-name')

Thanks for the hint, this is a bad idea, but still I tried a temporary alternative as below: 

In scenario1:

      jsr223:

          execute: after

          script-text: |

            new File('file.txt').text = '${userToken}'    # works fine


In scenario2:

variables:

      userTokenNew: no        # declared a new local variable

 jsr223:

          execute: before

          script-text: |

               userTokenNew = new File('file.txt').text.            # works fine

           headers:

                Authorization: Bearer ${__base64Encode('${userTokenNew}')}.    # Unauthorized error



Could you please let me know if anything wrong in my code ?
If this is a known issue, kindly let me know the best way for passing token between scenarios ?

DT

unread,
Oct 20, 2023, 8:14:43 AM10/20/23
to codename-taurus
There are too many issues with "your" "code", it will take days to go through each of them separately and explain what's wrong with it and I don't see any point in doing this. Just copy and paste the below example and amend it accordingly to your needs:

execution:
- concurrency: 1
iteraions: 1
scenario: Scenario1
- concurrency: 1
iterations: 1
scenario: Scenario2

scenarios:
Scenario1:
requests:
extract-regexp:
some_variable: (\w+)
match-no: 0
jsr223:
script-text: 'new File("myfile.txt").text = vars.get("some_variable")'
execute: after

Scenario2:
requests:
headers:
Authorization: Bearer ${some_variable}
jsr223:
execute: before
script-text: 'vars.put("some_variable", new File("myfile.txt").text)'

modules:
local:
sequential: true



Just in case get familiarized with the following materials:

Ram

unread,
Oct 20, 2023, 9:37:37 AM10/20/23
to codename-taurus
Thank you for the detailed info, it worked.. !!
Reply all
Reply to author
Forward
0 new messages