In JMeter how do I set multiple dynamic variables in User Parameters or CSV Data Set Config










0















Very new to JMeter (and a long time Stack Overflow listener but first time caller so take it easy on me) so any help would be appreciated.



I am trying to set up a JMeter test that uses multiple dynamically generated access tokens to run across scenarios. I currently have a set of data using the CSV Data Set Config containing login credentials of a user's email and password for example:



email1@email.com,password1
email2@email.com,password2


Next I send a HTTP POST request to the Login service which generates an accessToken. Then, I am using the JSON Extractor to grab the generated accessToken. After that I am using the BeanShell Assertion to store the accessToken property/variable.



My issue seems to lie here in this last step since it will only store the last generated variable instead of each of the generated accessTokens. I want to be able to store/overwrite the grabbed accessToken for each email password combination. I would like it to modify/populate the CSV file like this:



email1@email.com,password1,accessToken1
email2@email.com,password2,accessToken2


I have also tried using the Pre Processor > User Parameters



Screen shot of User Parameters



I would like to have the "userBearerToken" variable update/overwrite along with the tests, but I cannot find a way to do so or if this can even currently be done.



I'm finding it difficult to word what I am trying to ask, but basically I want to store multiple dynamically generated variables (accessTokens that change and time out) and use them in other tests. I don't care which component can handle this (either the CSV or User Parameter), but I need to be able to store these variables with their corresponding email password credentials.










share|improve this question


























    0















    Very new to JMeter (and a long time Stack Overflow listener but first time caller so take it easy on me) so any help would be appreciated.



    I am trying to set up a JMeter test that uses multiple dynamically generated access tokens to run across scenarios. I currently have a set of data using the CSV Data Set Config containing login credentials of a user's email and password for example:



    email1@email.com,password1
    email2@email.com,password2


    Next I send a HTTP POST request to the Login service which generates an accessToken. Then, I am using the JSON Extractor to grab the generated accessToken. After that I am using the BeanShell Assertion to store the accessToken property/variable.



    My issue seems to lie here in this last step since it will only store the last generated variable instead of each of the generated accessTokens. I want to be able to store/overwrite the grabbed accessToken for each email password combination. I would like it to modify/populate the CSV file like this:



    email1@email.com,password1,accessToken1
    email2@email.com,password2,accessToken2


    I have also tried using the Pre Processor > User Parameters



    Screen shot of User Parameters



    I would like to have the "userBearerToken" variable update/overwrite along with the tests, but I cannot find a way to do so or if this can even currently be done.



    I'm finding it difficult to word what I am trying to ask, but basically I want to store multiple dynamically generated variables (accessTokens that change and time out) and use them in other tests. I don't care which component can handle this (either the CSV or User Parameter), but I need to be able to store these variables with their corresponding email password credentials.










    share|improve this question
























      0












      0








      0








      Very new to JMeter (and a long time Stack Overflow listener but first time caller so take it easy on me) so any help would be appreciated.



      I am trying to set up a JMeter test that uses multiple dynamically generated access tokens to run across scenarios. I currently have a set of data using the CSV Data Set Config containing login credentials of a user's email and password for example:



      email1@email.com,password1
      email2@email.com,password2


      Next I send a HTTP POST request to the Login service which generates an accessToken. Then, I am using the JSON Extractor to grab the generated accessToken. After that I am using the BeanShell Assertion to store the accessToken property/variable.



      My issue seems to lie here in this last step since it will only store the last generated variable instead of each of the generated accessTokens. I want to be able to store/overwrite the grabbed accessToken for each email password combination. I would like it to modify/populate the CSV file like this:



      email1@email.com,password1,accessToken1
      email2@email.com,password2,accessToken2


      I have also tried using the Pre Processor > User Parameters



      Screen shot of User Parameters



      I would like to have the "userBearerToken" variable update/overwrite along with the tests, but I cannot find a way to do so or if this can even currently be done.



      I'm finding it difficult to word what I am trying to ask, but basically I want to store multiple dynamically generated variables (accessTokens that change and time out) and use them in other tests. I don't care which component can handle this (either the CSV or User Parameter), but I need to be able to store these variables with their corresponding email password credentials.










      share|improve this question














      Very new to JMeter (and a long time Stack Overflow listener but first time caller so take it easy on me) so any help would be appreciated.



      I am trying to set up a JMeter test that uses multiple dynamically generated access tokens to run across scenarios. I currently have a set of data using the CSV Data Set Config containing login credentials of a user's email and password for example:



      email1@email.com,password1
      email2@email.com,password2


      Next I send a HTTP POST request to the Login service which generates an accessToken. Then, I am using the JSON Extractor to grab the generated accessToken. After that I am using the BeanShell Assertion to store the accessToken property/variable.



      My issue seems to lie here in this last step since it will only store the last generated variable instead of each of the generated accessTokens. I want to be able to store/overwrite the grabbed accessToken for each email password combination. I would like it to modify/populate the CSV file like this:



      email1@email.com,password1,accessToken1
      email2@email.com,password2,accessToken2


      I have also tried using the Pre Processor > User Parameters



      Screen shot of User Parameters



      I would like to have the "userBearerToken" variable update/overwrite along with the tests, but I cannot find a way to do so or if this can even currently be done.



      I'm finding it difficult to word what I am trying to ask, but basically I want to store multiple dynamically generated variables (accessTokens that change and time out) and use them in other tests. I don't care which component can handle this (either the CSV or User Parameter), but I need to be able to store these variables with their corresponding email password credentials.







      jmeter performance-testing load-testing






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 23:35









      JTesterJTester

      32




      32






















          1 Answer
          1






          active

          oldest

          votes


















          0














          If you want to store the accessToken value into a JMeter property for using in other Thread Group(s) be aware that properties are global for the whole JVM and remain until JMeter is restarted so if you define a single accessToken property - each JMeter Thread (or iteration) will overwrite the value.



          The solution is to use current thread (or iteration) number as prefix or postfix, this can be done using either __$__threadNum function or relevant JMeter Variable depending on how iteration is defined or both.



          Example setup:



          1. In first thread group: $__setProperty(access_token_$__threadNum,bar,)

          2. In second thread group: $__P(access_token_$__threadNum,)

          Demo:



          enter image description here




          If you want to save the values into a file writing into the current one is not the best idea as you can (and most probably will) get malformed file due to a form of a race condition. So I would recommend using Sample Variables property instead.



          If you add the next line to user.properties file:



          sample_variables=email,password,accessToken



          JMeter will store the variables named $email, $password, and $accessToken along with their values in the .jtl results file which is basically CSV file which can be re-used anywhere else.



          However if you have a requirement to store only the credentials and the token you can go for the Flexible File Writer plugin and configure it to save the aforementioned variables values into a separate file, the relevant configuration would be as simple as:



          variable#0,variable#1,variable#2


          enter image description here



          You can install Flexible File Writer plugin using JMeter Plugins Manager



          enter image description here






          share|improve this answer























          • Thank you Dmitri T for the answer. I ended up using the Flexible File Writer plugin to solve this issue.

            – JTester
            Nov 16 '18 at 16:23










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291059%2fin-jmeter-how-do-i-set-multiple-dynamic-variables-in-user-parameters-or-csv-data%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          If you want to store the accessToken value into a JMeter property for using in other Thread Group(s) be aware that properties are global for the whole JVM and remain until JMeter is restarted so if you define a single accessToken property - each JMeter Thread (or iteration) will overwrite the value.



          The solution is to use current thread (or iteration) number as prefix or postfix, this can be done using either __$__threadNum function or relevant JMeter Variable depending on how iteration is defined or both.



          Example setup:



          1. In first thread group: $__setProperty(access_token_$__threadNum,bar,)

          2. In second thread group: $__P(access_token_$__threadNum,)

          Demo:



          enter image description here




          If you want to save the values into a file writing into the current one is not the best idea as you can (and most probably will) get malformed file due to a form of a race condition. So I would recommend using Sample Variables property instead.



          If you add the next line to user.properties file:



          sample_variables=email,password,accessToken



          JMeter will store the variables named $email, $password, and $accessToken along with their values in the .jtl results file which is basically CSV file which can be re-used anywhere else.



          However if you have a requirement to store only the credentials and the token you can go for the Flexible File Writer plugin and configure it to save the aforementioned variables values into a separate file, the relevant configuration would be as simple as:



          variable#0,variable#1,variable#2


          enter image description here



          You can install Flexible File Writer plugin using JMeter Plugins Manager



          enter image description here






          share|improve this answer























          • Thank you Dmitri T for the answer. I ended up using the Flexible File Writer plugin to solve this issue.

            – JTester
            Nov 16 '18 at 16:23















          0














          If you want to store the accessToken value into a JMeter property for using in other Thread Group(s) be aware that properties are global for the whole JVM and remain until JMeter is restarted so if you define a single accessToken property - each JMeter Thread (or iteration) will overwrite the value.



          The solution is to use current thread (or iteration) number as prefix or postfix, this can be done using either __$__threadNum function or relevant JMeter Variable depending on how iteration is defined or both.



          Example setup:



          1. In first thread group: $__setProperty(access_token_$__threadNum,bar,)

          2. In second thread group: $__P(access_token_$__threadNum,)

          Demo:



          enter image description here




          If you want to save the values into a file writing into the current one is not the best idea as you can (and most probably will) get malformed file due to a form of a race condition. So I would recommend using Sample Variables property instead.



          If you add the next line to user.properties file:



          sample_variables=email,password,accessToken



          JMeter will store the variables named $email, $password, and $accessToken along with their values in the .jtl results file which is basically CSV file which can be re-used anywhere else.



          However if you have a requirement to store only the credentials and the token you can go for the Flexible File Writer plugin and configure it to save the aforementioned variables values into a separate file, the relevant configuration would be as simple as:



          variable#0,variable#1,variable#2


          enter image description here



          You can install Flexible File Writer plugin using JMeter Plugins Manager



          enter image description here






          share|improve this answer























          • Thank you Dmitri T for the answer. I ended up using the Flexible File Writer plugin to solve this issue.

            – JTester
            Nov 16 '18 at 16:23













          0












          0








          0







          If you want to store the accessToken value into a JMeter property for using in other Thread Group(s) be aware that properties are global for the whole JVM and remain until JMeter is restarted so if you define a single accessToken property - each JMeter Thread (or iteration) will overwrite the value.



          The solution is to use current thread (or iteration) number as prefix or postfix, this can be done using either __$__threadNum function or relevant JMeter Variable depending on how iteration is defined or both.



          Example setup:



          1. In first thread group: $__setProperty(access_token_$__threadNum,bar,)

          2. In second thread group: $__P(access_token_$__threadNum,)

          Demo:



          enter image description here




          If you want to save the values into a file writing into the current one is not the best idea as you can (and most probably will) get malformed file due to a form of a race condition. So I would recommend using Sample Variables property instead.



          If you add the next line to user.properties file:



          sample_variables=email,password,accessToken



          JMeter will store the variables named $email, $password, and $accessToken along with their values in the .jtl results file which is basically CSV file which can be re-used anywhere else.



          However if you have a requirement to store only the credentials and the token you can go for the Flexible File Writer plugin and configure it to save the aforementioned variables values into a separate file, the relevant configuration would be as simple as:



          variable#0,variable#1,variable#2


          enter image description here



          You can install Flexible File Writer plugin using JMeter Plugins Manager



          enter image description here






          share|improve this answer













          If you want to store the accessToken value into a JMeter property for using in other Thread Group(s) be aware that properties are global for the whole JVM and remain until JMeter is restarted so if you define a single accessToken property - each JMeter Thread (or iteration) will overwrite the value.



          The solution is to use current thread (or iteration) number as prefix or postfix, this can be done using either __$__threadNum function or relevant JMeter Variable depending on how iteration is defined or both.



          Example setup:



          1. In first thread group: $__setProperty(access_token_$__threadNum,bar,)

          2. In second thread group: $__P(access_token_$__threadNum,)

          Demo:



          enter image description here




          If you want to save the values into a file writing into the current one is not the best idea as you can (and most probably will) get malformed file due to a form of a race condition. So I would recommend using Sample Variables property instead.



          If you add the next line to user.properties file:



          sample_variables=email,password,accessToken



          JMeter will store the variables named $email, $password, and $accessToken along with their values in the .jtl results file which is basically CSV file which can be re-used anywhere else.



          However if you have a requirement to store only the credentials and the token you can go for the Flexible File Writer plugin and configure it to save the aforementioned variables values into a separate file, the relevant configuration would be as simple as:



          variable#0,variable#1,variable#2


          enter image description here



          You can install Flexible File Writer plugin using JMeter Plugins Manager



          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 5:31









          Dmitri TDmitri T

          72.6k33662




          72.6k33662












          • Thank you Dmitri T for the answer. I ended up using the Flexible File Writer plugin to solve this issue.

            – JTester
            Nov 16 '18 at 16:23

















          • Thank you Dmitri T for the answer. I ended up using the Flexible File Writer plugin to solve this issue.

            – JTester
            Nov 16 '18 at 16:23
















          Thank you Dmitri T for the answer. I ended up using the Flexible File Writer plugin to solve this issue.

          – JTester
          Nov 16 '18 at 16:23





          Thank you Dmitri T for the answer. I ended up using the Flexible File Writer plugin to solve this issue.

          – JTester
          Nov 16 '18 at 16:23



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291059%2fin-jmeter-how-do-i-set-multiple-dynamic-variables-in-user-parameters-or-csv-data%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Darth Vader #20

          How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

          Ondo