You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by GitBox <gi...@apache.org> on 2022/11/16 14:44:49 UTC

[GitHub] [jmeter] frgirard opened a new issue, #5733: How to dynamically create samples

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

   ### The documentation URL
   
   https://jmeter.apache.org/usermanual/component_reference.html#JSR223_Sampler
   
   ### Feedback
   
   I need a JSR223 groovy script to be able to dynamically create samples. This script receives kafka records which have headers including processing times. I'd like to be able to create samples using these timestamp info.
   In my script, I create sampleresults :
   
   `def sr = new org.apache.jmeter.samplers.SampleResult(t_in, t_out - t_in)`
   
   But there's no way I know to add this sampleresult to JMeter results (.jtl, listeners...).
   How could I do that ?
   Thanks a lot !


-- 
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


[GitHub] [jmeter] FSchumacher commented on issue #5733: How to dynamically create samples

Posted by GitBox <gi...@apache.org>.
FSchumacher commented on issue #5733:
URL: https://github.com/apache/jmeter/issues/5733#issuecomment-1317321377

   First point might be annoying, but it is critical? Report could ignore those sample, could not it?
   For the second point. Do you think those listeners should be enhanced to support subsamples?
   
   Another way of implementing creation of samples would be by setting an array like object in the sampler and using a while/loop controller afterwards to iterate over the values of the array, using those values to fill in samplers.


-- 
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


[GitHub] [jmeter] FSchumacher commented on issue #5733: How to dynamically create samples

Posted by GitBox <gi...@apache.org>.
FSchumacher commented on issue #5733:
URL: https://github.com/apache/jmeter/issues/5733#issuecomment-1317295134

   Have you thought about adding those samples as sub results into your given SampleResult?
   
   https://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html#addSubResult(org.apache.jmeter.samplers.SampleResult)


-- 
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


[GitHub] [jmeter] frgirard commented on issue #5733: How to dynamically create samples

Posted by GitBox <gi...@apache.org>.
frgirard commented on issue #5733:
URL: https://github.com/apache/jmeter/issues/5733#issuecomment-1317371656

   Ok I'll try this way. In the meanwhile, do you know any way I could do by adding my sampleresults to JMeter results ? :)


-- 
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


[GitHub] [jmeter] frgirard commented on issue #5733: How to dynamically create samples

Posted by GitBox <gi...@apache.org>.
frgirard commented on issue #5733:
URL: https://github.com/apache/jmeter/issues/5733#issuecomment-1331998041

   Thanks a lot for your help, @FSchumacher !


-- 
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


[GitHub] [jmeter] frgirard commented on issue #5733: How to dynamically create samples

Posted by GitBox <gi...@apache.org>.
frgirard commented on issue #5733:
URL: https://github.com/apache/jmeter/issues/5733#issuecomment-1317304547

   Yes I did, but there are 2 issues with this method :
   
   - I cannot setIgnore() the groovy script generating the subresults, hence the jtl file is "polluted" with these samples
   - The subresults are not considered by some listeners like summary report


-- 
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


[GitHub] [jmeter] asfgit closed issue #5733: How to dynamically create samples

Posted by GitBox <gi...@apache.org>.
asfgit closed issue #5733: How to dynamically create samples
URL: https://github.com/apache/jmeter/issues/5733


-- 
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] How to dynamically create samples [jmeter]

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

   @frgirard thank you so much for your quick response. if its not too much to ask could you please provide a example JMX script with above script so i can better understand how main JSR223 is working with this logic together to produce dynamic labels ?


-- 
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


[GitHub] [jmeter] frgirard commented on issue #5733: How to dynamically create samples

Posted by GitBox <gi...@apache.org>.
frgirard commented on issue #5733:
URL: https://github.com/apache/jmeter/issues/5733#issuecomment-1317343356

   First point is quite critical because I won't be able to postprocess the jtl file (blazemeter)
   
   About the alternate way, do you suggest I use a loop controler then alter each sample created with the values I want ? I'm not sure I can alter the sample start time for instance.


-- 
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


[GitHub] [jmeter] FSchumacher commented on issue #5733: How to dynamically create samples

Posted by GitBox <gi...@apache.org>.
FSchumacher commented on issue #5733:
URL: https://github.com/apache/jmeter/issues/5733#issuecomment-1320249914

   Yes, the exception comes from JSR223Sampler calling SampleResult#sampleEnd() without checking, if the sampler has set a timestamp (not equal to `0`) first. Should probably fixed. 


-- 
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


[GitHub] [jmeter] frgirard commented on issue #5733: How to dynamically create samples

Posted by GitBox <gi...@apache.org>.
frgirard commented on issue #5733:
URL: https://github.com/apache/jmeter/issues/5733#issuecomment-1318467136

   Ok it seems to work, but I had to put the loop in a teardown threadgroup.
   I'm using SampleResult.setStartTime() and SampleResult.setEndTime().
   
   However, it rises an exception on every loop :
   
   `2022-11-17 12:02:39,362 ERROR o.a.j.s.SampleResult: sampleEnd called twice
   java.lang.Throwable: Invalid call sequence
   	at org.apache.jmeter.samplers.SampleResult.sampleEnd(SampleResult.java:1147) ~[ApacheJMeter_core.jar:5.5]
   	at org.apache.jmeter.protocol.java.sampler.JSR223Sampler.sample(JSR223Sampler.java:82) ~[ApacheJMeter_java.jar:5.5]
   	at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:651) ~[ApacheJMeter_core.jar:?]
   	at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:570) ~[ApacheJMeter_core.jar:?]
   	at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:501) ~[ApacheJMeter_core.jar:?]
   	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:268) ~[ApacheJMeter_core.jar:?]
   	at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_345]
   `
   Any idea on how I could fix that ?


-- 
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] How to dynamically create samples [jmeter]

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

   I'm using a dedicated JSR223 sampler into a loop controller, to create the samples I need. The values (start time, end time) are pushed by the main sampler to a java.util.concurrent.ConcurrentLinkedQueue and used by this sampler. All other samplers are setIgnore().
   It looks like that :
   
   `ConcurrentHashMap<String, String> trep = props.get "map.trep"
   ConcurrentLinkedQueue<String> rq = props.get "reception.queue"
   AtomicInteger skutraites = props.get "sku.count"
   
   String key = rq.poll()
   
   if (key)
   {
     String[] val = trep.get(key).split(",")
     trep.remove(key)
     t_in = Long.parseLong(val[0])
     t_out = Long.parseLong(val[1])
     taille = Integer.parseInt(val[2])
     type = val[3]
   
     skutraites.addAndGet(1)
   
     //log.info "Creating sample ${key}, ${t_in}, ${t_out}, ${taille}"
   
     SampleResult.setSampleLabel(type + "_aggreg")
     SampleResult.setStartTime(t_in)
     SampleResult.setEndTime(t_out)
     //SampleResult.setLatency(latency)
     SampleResult.setBytes(taille as long)
     SampleResult.setResponseMessage(key)
   }
   else
   {
     SampleResult.setIgnore()
     sleep 100
   }
   `


-- 
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


[GitHub] [jmeter] FSchumacher commented on issue #5733: How to dynamically create samples

Posted by GitBox <gi...@apache.org>.
FSchumacher commented on issue #5733:
URL: https://github.com/apache/jmeter/issues/5733#issuecomment-1317349886

   In Groovy space, you can do quite a lot. I would try it out. But it should be possible to use SampleResult#setStartTime(long) on the current sample.


-- 
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] How to dynamically create samples [jmeter]

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

   @frgirard  Could you please provide a sample on how you were able to do this "How to dynamically create samples
   "?


-- 
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