You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by "mehrdad2000 (via GitHub)" <gi...@apache.org> on 2024/04/14 04:39:06 UTC

[I] random function generate multiple value when access more than once [jmeter]

mehrdad2000 opened a new issue, #6269:
URL: https://github.com/apache/jmeter/issues/6269

   ### Expected behavior
   
   _No response_
   
   ### Actual behavior
   
   _No response_
   
   ### Steps to reproduce the problem
   
   Hi
   I'm using jmeter 5.6.2 with iso8583 plugin.
   
   try to use this groovy script but seems jmeter create two value for field 11 that use random function ${__Random(111111111111,999999999999,)}!
   
   seems random function generate multiple value when access more than once!
   
   if (!vars.getObject('addMac')) {
       def macKey = new javax.crypto.spec.SecretKeySpec(
           org.jpos.iso.ISOUtil.hex2byte('1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A'), 'ISO9797ALG3')
       def ssm = new nz.co.breakpoint.jmeter.iso8583.SecurityModule()
   
       vars.putObject('addMac', { sampler ->
           def msg = sampler.getRequest()
           def p = msg.getPackager()
   
           def bytes = [0,2,11,12,47].collect {
               p.getFieldPackager(it).pack(msg.getComponent(it))
           }.flatten() as byte[]
   
           sampler.addField('64', ssm.generateMAC(bytes, macKey, macKey.getAlgorithm()))
       })
   }
   vars.getObject('addMac').call(sampler)
   
   
   
   ![image](https://github.com/tilln/jmeter-iso8583/assets/26499665/84931e61-5028-44c0-bdad-c39877183d4a)
   
   
   FYI: main issue report [here ](https://github.com/tilln/jmeter-iso8583/issues/87) and developer of this plugin told me this issue related to jmeter 5.6.2!
   
   
   Would you please fix this issue?
   Any idea?
   Thanks
   
   ### JMeter Version
   
   5.6.2
   
   ### Java Version
   
   _No response_
   
   ### OS Version
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] random function generate multiple value when access more than once [jmeter]

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on issue #6269:
URL: https://github.com/apache/jmeter/issues/6269#issuecomment-2053942701

   >seems random function generate multiple value when access more than once!
   
   That seems about right for a random function, doesn't it?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] random function generate multiple value when access more than once [jmeter]

Posted by "tilln (via GitHub)" <gi...@apache.org>.
tilln commented on issue #6269:
URL: https://github.com/apache/jmeter/issues/6269#issuecomment-2053909705

   This appears to be caused by #5788 in version 5.6
   Setting the property `function.cache.per.iteration=true` revert to the old behaviour.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] random function generate multiple value when access more than once [jmeter]

Posted by "tilln (via GitHub)" <gi...@apache.org>.
tilln commented on issue #6269:
URL: https://github.com/apache/jmeter/issues/6269#issuecomment-2054168523

   Here is a script: [jmeter-regression-v5.6.jmx.txt](https://github.com/apache/jmeter/files/14971891/jmeter-regression-v5.6.jmx.txt)
   ![image](https://github.com/apache/jmeter/assets/19366960/614c88f4-f713-4816-99e1-9d6f2e2e77da)
   
   Expected would be that the SampleResult's label and URL match as they do with the caching.
   
   JTL output from v5.5
   ```
   timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
   1713123663745,963,GET https://www.google.com/search?q=AECC,200,OK,Thread Group 1-1,text,true,,115147,130,1,1,https://www.google.com/search?q=AECC,658,0,457
   ```
   vs. 5.6.3
   ```
   timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
   1713123690243,961,GET https://www.google.com/search?q=EEDB,200,OK,Thread Group 1-1,text,true,,90089,130,1,1,https://www.google.com/search?q=EABD,711,0,493
   ```
   
   This might be an unintended consequence of the caching removal, but I think this is not unreasonable to expect that the sampler properties are evaluated once. 
   I have written a lot of scripts with random functions or other, non-idempotent functions in sampler payloads in conjunction with some sort of access to sampler properties (via Preprocessors or plugins such as the one the author is using), that break after upgrading to v5.6.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] random function generate multiple value when access more than once [jmeter]

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on issue #6269:
URL: https://github.com/apache/jmeter/issues/6269#issuecomment-2054094482

   I would say `function.cache.per.iteration` is a wrong approach to handle things. At the same time I don't understand the problem you have.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] random function generate multiple value when access more than once [jmeter]

Posted by "tilln (via GitHub)" <gi...@apache.org>.
tilln commented on issue #6269:
URL: https://github.com/apache/jmeter/issues/6269#issuecomment-2054170501

   > At the same time I don't understand the problem you have.
   
   The problem the author has is that the Random function is evaluated once when accessing the sampler payload for generating the MAC (in his JSR223 Preprocessor or likewise in a plugin's preprocessor) and then again when the sampler samples, resulting in a MAC mismatch.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] random function generate multiple value when access more than once [jmeter]

Posted by "mehrdad2000 (via GitHub)" <gi...@apache.org>.
mehrdad2000 commented on issue #6269:
URL: https://github.com/apache/jmeter/issues/6269#issuecomment-2054091994

   @vlsi in this case we need to use that variable for generate mac.
   So I turn cache on as @tilln mentioned.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] random function generate multiple value when access more than once [jmeter]

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on issue #6269:
URL: https://github.com/apache/jmeter/issues/6269#issuecomment-2054112518

   Could you share a reproducer script, expected and the actual output?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] random function generate multiple value when access more than once [jmeter]

Posted by "mehrdad2000 (via GitHub)" <gi...@apache.org>.
mehrdad2000 commented on issue #6269:
URL: https://github.com/apache/jmeter/issues/6269#issuecomment-2054111087

   @vlsi the main problem is generate random number and use that number to generate Mac.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org