Re: Sampler parameters in Log file or jtl file??
Please start a new thread for a new question On 29 March 2016 at 08:36, Srikrishna Dandamrajuwrote: > hi all > > i am getting below error for bean shell assertion issue, - To unsubscribe, e-mail: user-unsubscr...@jmeter.apache.org For additional commands, e-mail: user-h...@jmeter.apache.org
Re: Sampler parameters in Log file or jtl file??
hi all i am getting below error for bean shell assertion issue, Assertion failure message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.threads . . . '' : Typed variable declaration : Object constructor. i am trying to copy response in to a csv file with below bean shell assertion code import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.threads.JMeterContext; import org.apache.jmeter.threads.JMeterContextService; SampleResult previousResult=JMeterContextService.getContext().getPreviousResult(); previousResult.setSampleLabel(previousResult.getSampleLabel() + "_" + vars.get("comny_id_#") + "-Rows"); if(Integer.parseInt(vars.get("stopLooping")) == 3) { vars.put("stopAsking", "true"); Failure = true; FailureMessage = "Dont received data"; } if(vars.get("comny_id_#") != null && Integer.parseInt(vars.get("comny_id_#")) != 0) { vars.put("stopAsking","true"); FileOutputStream outPath = new FileOutputStream(vars.get("pathtoinputdata") + "comny_id_year.csv"); PrintStream outFile = new PrintStream(outPath); int iterMax = Integer.parseInt(vars.get("comny_id_#")); for(int i = 1; i <= iterMax; i++) outFile.println(vars.get("comny_id_" + i.toString()) + "," + vars.get("year_" + i.toString())); outPath.close(); outFile.close(); } help me as asap. Thanks Srikrishna.D On Fri, Mar 25, 2016 at 11:44 PM, Deepak Shettywrote: > A variable can be written to file using sample_variables ( > http://jmeter.apache.org/usermanual/listeners.html#sample_variables) - > However thats probably not what you are looking for > If I understand correctly , you want the parameters that the Sampler is > sending , to be printed out in the JTL file . I can see two options > > a. If you are limiting yourself to HTTPSamplers , it should be possible to > write a Pre-processor that reads all the parameters on the sampler and > writes it as a single string to a pre-defined variable , and then you > configure that variable to be written using sample_variables > b. Write your own listener (or use a listener that allows you to write > custom code) > > However the question is why do you want to do this ? Is it to debug > failures ? In which case there are probably better ways to handle it (for > e.g. saving responses or diagnostic information only on errors) - I also > sometimes use variable names in the Assertion , so that it gives me enough > information when the assertion fails > > regards > deepak > > On Thu, Mar 24, 2016 at 8:26 PM, Prakash Palnati < > prakash.paln...@snapwiz.com> wrote: > > > Hi, > > > > Is there a way that I get the parameters that are being passed in each > > sample in a log file or a jtl file? > > > > Thanks in advance. > > > > Best, > > Prakash > > >
Re: Sampler parameters in Log file or jtl file??
also you probably need to reset the value Right at the start , line 4 , add vars.put("allArgs",""); On Fri, Mar 25, 2016 at 7:37 PM, Prakash Palnati < prakash.paln...@snapwiz.com> wrote: > obviously not for load test Deepak. :) > > Thank you very much for the help. > On 26-Mar-2016 8:04 am, "Deepak Shetty"wrote: > > > Hi > > if you are performing a functional test , ok. if you are performing a > load > > test - think about the number of samples. You arent going to show > > individual samples in a report , on a load test right. And most of the > time > > only developers or testers understand parameters. > > In any case , if you need it option a) or b). > > For a) > > In jmeter.properties (or equivalent) define > > sample_variables=allArgs > > This tells JMeter to write the value of the variable named allArgs to the > > result file > > Then assuming your test is something like > > +ThreadGroup > > ++Sampler1 > > ++Sampler2 > > ++BeanShell Pre Processor (at this level so it applies to all samples) > > > > Code is something like > > import org.apache.jmeter.config.Arguments; > > import java.util.Map; > > import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; > > if(sampler instanceof HTTPSamplerBase) { > > Arguments args = sampler.getArguments(); > > Map map = args.getArgumentsAsMap(); > > if(map != null) { > > String s = map.toString(); > > vars.put("allArgs",s); > > } > > } > > > > > > > > On Fri, Mar 25, 2016 at 7:19 PM, Prakash Palnati < > > prakash.paln...@snapwiz.com> wrote: > > > > > Deepak, > > > > > > Thanks for the answer. The reason being, I developed a custom HTML > report > > > from jtl file using xsl. > > > > > > I want my stakeholders to see the report in detail. > > > On 25-Mar-2016 11:44 pm, "Deepak Shetty" wrote: > > > > > > > A variable can be written to file using sample_variables ( > > > > http://jmeter.apache.org/usermanual/listeners.html#sample_variables) > - > > > > However thats probably not what you are looking for > > > > If I understand correctly , you want the parameters that the Sampler > is > > > > sending , to be printed out in the JTL file . I can see two options > > > > > > > > a. If you are limiting yourself to HTTPSamplers , it should be > possible > > > to > > > > write a Pre-processor that reads all the parameters on the sampler > and > > > > writes it as a single string to a pre-defined variable , and then you > > > > configure that variable to be written using sample_variables > > > > b. Write your own listener (or use a listener that allows you to > write > > > > custom code) > > > > > > > > However the question is why do you want to do this ? Is it to debug > > > > failures ? In which case there are probably better ways to handle it > > (for > > > > e.g. saving responses or diagnostic information only on errors) - I > > also > > > > sometimes use variable names in the Assertion , so that it gives me > > > enough > > > > information when the assertion fails > > > > > > > > regards > > > > deepak > > > > > > > > On Thu, Mar 24, 2016 at 8:26 PM, Prakash Palnati < > > > > prakash.paln...@snapwiz.com> wrote: > > > > > > > > > Hi, > > > > > > > > > > Is there a way that I get the parameters that are being passed in > > each > > > > > sample in a log file or a jtl file? > > > > > > > > > > Thanks in advance. > > > > > > > > > > Best, > > > > > Prakash > > > > > > > > > > > > > > >
Re: Sampler parameters in Log file or jtl file??
obviously not for load test Deepak. :) Thank you very much for the help. On 26-Mar-2016 8:04 am, "Deepak Shetty"wrote: > Hi > if you are performing a functional test , ok. if you are performing a load > test - think about the number of samples. You arent going to show > individual samples in a report , on a load test right. And most of the time > only developers or testers understand parameters. > In any case , if you need it option a) or b). > For a) > In jmeter.properties (or equivalent) define > sample_variables=allArgs > This tells JMeter to write the value of the variable named allArgs to the > result file > Then assuming your test is something like > +ThreadGroup > ++Sampler1 > ++Sampler2 > ++BeanShell Pre Processor (at this level so it applies to all samples) > > Code is something like > import org.apache.jmeter.config.Arguments; > import java.util.Map; > import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; > if(sampler instanceof HTTPSamplerBase) { > Arguments args = sampler.getArguments(); > Map map = args.getArgumentsAsMap(); > if(map != null) { > String s = map.toString(); > vars.put("allArgs",s); > } > } > > > > On Fri, Mar 25, 2016 at 7:19 PM, Prakash Palnati < > prakash.paln...@snapwiz.com> wrote: > > > Deepak, > > > > Thanks for the answer. The reason being, I developed a custom HTML report > > from jtl file using xsl. > > > > I want my stakeholders to see the report in detail. > > On 25-Mar-2016 11:44 pm, "Deepak Shetty" wrote: > > > > > A variable can be written to file using sample_variables ( > > > http://jmeter.apache.org/usermanual/listeners.html#sample_variables) - > > > However thats probably not what you are looking for > > > If I understand correctly , you want the parameters that the Sampler is > > > sending , to be printed out in the JTL file . I can see two options > > > > > > a. If you are limiting yourself to HTTPSamplers , it should be possible > > to > > > write a Pre-processor that reads all the parameters on the sampler and > > > writes it as a single string to a pre-defined variable , and then you > > > configure that variable to be written using sample_variables > > > b. Write your own listener (or use a listener that allows you to write > > > custom code) > > > > > > However the question is why do you want to do this ? Is it to debug > > > failures ? In which case there are probably better ways to handle it > (for > > > e.g. saving responses or diagnostic information only on errors) - I > also > > > sometimes use variable names in the Assertion , so that it gives me > > enough > > > information when the assertion fails > > > > > > regards > > > deepak > > > > > > On Thu, Mar 24, 2016 at 8:26 PM, Prakash Palnati < > > > prakash.paln...@snapwiz.com> wrote: > > > > > > > Hi, > > > > > > > > Is there a way that I get the parameters that are being passed in > each > > > > sample in a log file or a jtl file? > > > > > > > > Thanks in advance. > > > > > > > > Best, > > > > Prakash > > > > > > > > > >
Re: Sampler parameters in Log file or jtl file??
Hi if you are performing a functional test , ok. if you are performing a load test - think about the number of samples. You arent going to show individual samples in a report , on a load test right. And most of the time only developers or testers understand parameters. In any case , if you need it option a) or b). For a) In jmeter.properties (or equivalent) define sample_variables=allArgs This tells JMeter to write the value of the variable named allArgs to the result file Then assuming your test is something like +ThreadGroup ++Sampler1 ++Sampler2 ++BeanShell Pre Processor (at this level so it applies to all samples) Code is something like import org.apache.jmeter.config.Arguments; import java.util.Map; import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; if(sampler instanceof HTTPSamplerBase) { Arguments args = sampler.getArguments(); Map map = args.getArgumentsAsMap(); if(map != null) { String s = map.toString(); vars.put("allArgs",s); } } On Fri, Mar 25, 2016 at 7:19 PM, Prakash Palnati < prakash.paln...@snapwiz.com> wrote: > Deepak, > > Thanks for the answer. The reason being, I developed a custom HTML report > from jtl file using xsl. > > I want my stakeholders to see the report in detail. > On 25-Mar-2016 11:44 pm, "Deepak Shetty"wrote: > > > A variable can be written to file using sample_variables ( > > http://jmeter.apache.org/usermanual/listeners.html#sample_variables) - > > However thats probably not what you are looking for > > If I understand correctly , you want the parameters that the Sampler is > > sending , to be printed out in the JTL file . I can see two options > > > > a. If you are limiting yourself to HTTPSamplers , it should be possible > to > > write a Pre-processor that reads all the parameters on the sampler and > > writes it as a single string to a pre-defined variable , and then you > > configure that variable to be written using sample_variables > > b. Write your own listener (or use a listener that allows you to write > > custom code) > > > > However the question is why do you want to do this ? Is it to debug > > failures ? In which case there are probably better ways to handle it (for > > e.g. saving responses or diagnostic information only on errors) - I also > > sometimes use variable names in the Assertion , so that it gives me > enough > > information when the assertion fails > > > > regards > > deepak > > > > On Thu, Mar 24, 2016 at 8:26 PM, Prakash Palnati < > > prakash.paln...@snapwiz.com> wrote: > > > > > Hi, > > > > > > Is there a way that I get the parameters that are being passed in each > > > sample in a log file or a jtl file? > > > > > > Thanks in advance. > > > > > > Best, > > > Prakash > > > > > >
Re: Sampler parameters in Log file or jtl file??
Deepak, Thanks for the answer. The reason being, I developed a custom HTML report from jtl file using xsl. I want my stakeholders to see the report in detail. On 25-Mar-2016 11:44 pm, "Deepak Shetty"wrote: > A variable can be written to file using sample_variables ( > http://jmeter.apache.org/usermanual/listeners.html#sample_variables) - > However thats probably not what you are looking for > If I understand correctly , you want the parameters that the Sampler is > sending , to be printed out in the JTL file . I can see two options > > a. If you are limiting yourself to HTTPSamplers , it should be possible to > write a Pre-processor that reads all the parameters on the sampler and > writes it as a single string to a pre-defined variable , and then you > configure that variable to be written using sample_variables > b. Write your own listener (or use a listener that allows you to write > custom code) > > However the question is why do you want to do this ? Is it to debug > failures ? In which case there are probably better ways to handle it (for > e.g. saving responses or diagnostic information only on errors) - I also > sometimes use variable names in the Assertion , so that it gives me enough > information when the assertion fails > > regards > deepak > > On Thu, Mar 24, 2016 at 8:26 PM, Prakash Palnati < > prakash.paln...@snapwiz.com> wrote: > > > Hi, > > > > Is there a way that I get the parameters that are being passed in each > > sample in a log file or a jtl file? > > > > Thanks in advance. > > > > Best, > > Prakash > > >
Re: Sampler parameters in Log file or jtl file??
A variable can be written to file using sample_variables ( http://jmeter.apache.org/usermanual/listeners.html#sample_variables) - However thats probably not what you are looking for If I understand correctly , you want the parameters that the Sampler is sending , to be printed out in the JTL file . I can see two options a. If you are limiting yourself to HTTPSamplers , it should be possible to write a Pre-processor that reads all the parameters on the sampler and writes it as a single string to a pre-defined variable , and then you configure that variable to be written using sample_variables b. Write your own listener (or use a listener that allows you to write custom code) However the question is why do you want to do this ? Is it to debug failures ? In which case there are probably better ways to handle it (for e.g. saving responses or diagnostic information only on errors) - I also sometimes use variable names in the Assertion , so that it gives me enough information when the assertion fails regards deepak On Thu, Mar 24, 2016 at 8:26 PM, Prakash Palnati < prakash.paln...@snapwiz.com> wrote: > Hi, > > Is there a way that I get the parameters that are being passed in each > sample in a log file or a jtl file? > > Thanks in advance. > > Best, > Prakash >
Sampler parameters in Log file or jtl file??
Hi, Is there a way that I get the parameters that are being passed in each sample in a log file or a jtl file? Thanks in advance. Best, Prakash