On 26/06/2009, Stromas, Aaron (NIH/OD) [C] <[email protected]> wrote:
> -----Original Message-----
>  From: sebb [mailto:[email protected]]
>
> Sent: Friday, June 26, 2009 12:13 PM
>  To: JMeter Users List
>  Subject: Re: ForEach and BeanShell question
>
>  On 26/06/2009, Stromas, Aaron (NIH/OD) [C] <[email protected]> wrote:
>  >
>  >
>  >  -----Original Message-----
>  >  From: sebb [mailto:[email protected]]
>  >
>  > Sent: Friday, June 26, 2009 11:44 AM
>  >  To: JMeter Users List
>  >  Subject: Re: ForEach and BeanShell question
>  >
>  >  On 26/06/2009, Stromas, Aaron (NIH/OD) [C] <[email protected]> wrote:
>  >  >
>  >  >
>  >  >  -----Original Message-----
>  >  >  From: sebb [mailto:[email protected]]
>  >  >
>  >  > Sent: Friday, June 26, 2009 10:36 AM
>  >  >  To: JMeter Users List
>  >  >  Subject: Re: ForEach and BeanShell question
>  >  >
>  >  >  On 26/06/2009, Stromas, Aaron (NIH/OD) [C] <[email protected]> 
> wrote:
>  >  >  >
>  >  >  >
>  >  >  >  -----Original Message-----
>  >  >  >  From: sebb [mailto:[email protected]]
>  >  >  >
>  >  >  > Sent: Friday, June 26, 2009 9:39 AM
>  >  >  >  To: JMeter Users List
>  >  >  >  Subject: Re: ForEach and BeanShell question
>  >  >  >
>  >  >  >  On 26/06/2009, Stromas, Aaron (NIH/OD) [C] <[email protected]> 
> wrote:
>  >  >  >  > -----Original Message-----
>  >  >  >  >  From: sebb [mailto:[email protected]]
>  >  >  >  >
>  >  >  >  > Sent: Friday, June 26, 2009 8:45 AM
>  >  >  >  >  To: JMeter Users List
>  >  >  >  >  Subject: Re: ForEach and BeanShell question
>  >  >  >  >
>  >  >  >  >  On 26/06/2009, Stromas, Aaron (NIH/OD) [C] 
> <[email protected]> wrote:
>  >  >  >  >  >
>  >  >  >  >  >
>  >  >  >  >  >  -----Original Message-----
>  >  >  >  >  >  From: sebb [mailto:[email protected]]
>  >  >  >  >  >  Sent: Thursday, June 25, 2009 2:08 PM
>  >  >  >  >  >  To: JMeter Users List
>  >  >  >  >  >  Subject: Re: ForEach and BeanShell question
>  >  >  >  >  >
>  >  >  >  >  >  On 25/06/2009, Stromas, Aaron (NIH/OD) [C] 
> <[email protected]> wrote:
>  >  >  >  >  >  > Greetings!
>  >  >  >  >  >  >
>  >  >  >  >  >  >  I have a test plan that uses a RE Extractor to convert the 
> values of the HTML select element to the input values of the ForEach 
> controller. These values are of the form X,M,N~Y,A,B~...~Z,C,D, and I can see 
> from the log that they are properly generated. The reference name for these 
> values is tuple. The ForEach controller Input variable prefix is tuple, and 
> the Output variable name is threetuple.
>  >  >  >  >  >  >
>  >  >  >  >  >  >  I am emulating Javascript which breaks up the value of 
> selected option and submits an HTTP request with the values of each of 
> thre-tuple as parameter. To that end, I have another ForEach controller as a 
> child of the first one with the BeanShell preprocessor:
>  >  >  >  >  >  >
>  >  >  >  >  >  >  String[] tuples = vars.get("threetuple_1").split("~");
>  >  >  >  >  >  >
>  >  >  >  >  >  >  List list = new ArrayList();
>  >  >  >  >  >  >
>  >  >  >  >  >  >  for (int i = 0; i < tuples.length; i++) {
>  >  >  >  >  >  >     list.add(tuples[i].split(","));
>  >  >  >  >  >  >  }
>  >  >  >  >  >  >
>  >  >  >  >  >  >  vars.put("params", list);
>  >  >  >  >  >  >
>  >  >  >  >  >  >  The inner ForEach controller has a HTTP Request sampler 
> with a BeanShell preprocessor whose job is to break up the three-tuple into 
> individual parameters.
>  >  >  >  >  >  >
>  >  >  >  >  >  >  In short, no HTTP sampler ever executes, and the log shows 
> that the inner ForEach controller receives null input.
>  >  >  >  >  >  >
>  >  >  >  >  >  >  I can see in the log, what I presume to be invocation of 
> the outer ForEach:
>  >  >  >  >  >  >
>  >  >  >  >  >  >  ... jmeter.control.ForEach resultstring 
> isDone=SAR,713,0~RCC,988,343...
>  >  >  >  >  >  >
>  >  >  >  >  >  >
>  >  >  >  >  >  >  and the inner ForEach:
>  >  >  >  >  >  >
>  >  >  >  >  >  >  ... jmeter.control.ForeachController: No entries found - 
> null first entry: params_1
>  >  >  >  >  >  >
>  >  >  >  >  >  >  The questions are: is there any way of knowing why the 
> BeanShell preprocessor did not execute?
>  >  >  >  >  >  >
>  >  >  >  >  >  >  Once that problem resolved, I need to tackle the business 
> of the ForEach output variable which gets loop index appended to it, so how 
> can the BeanShell "know" which variable to use?
>  >  >  >  >  >  >
>  >  >  >  >  >  >  Any suggestions?
>  >  >  >  >  >
>  >  >  >  >  >  The ForEach Controller needs multiple variables, not a list:
>  >  >  >  >  >
>  >  >  >  >  >  
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#ForEach_Controller
>  >  >  >  >  >
>  >  >  >  >  >
>  >  >  >  >  >
>  >  >  >  >  > It still isn't working for me. This is the schematic of my 
> test:
>  >  >  >  >  >
>  >  >  >  >  >  ForEach controller
>  >  >  >  >  >    Input var prefix: tuple
>  >  >  >  >
>  >  >  >  >  What sets "tuple_1" etc?
>  >  >  >  >
>  >  >  >  >
>  >  >  >  > These are set by the Regular Expression extractor prior the 
> ForEach controller (Reference Name: tuple)
>  >  >  >  >
>  >  >  >  >
>  >  >  >  >  >    Output var name: threetuple
>  >  >  >  >  >    |
>  >  >  >  >  >    |
>  >  >  >  >  >    ForEach controller
>  >  >  >  >  >       Input var prefix: params
>  >  >  >  >
>  >  >  >  >  These need to be set BEFORE the controller is executed.
>  >  >  >  >
>  >  >  >  >
>  >  >  >  > That is what the BeanShell PREprocessor is for, is it not?
>  >  >  >
>  >  >  >  Pre-Processors are invoked before samplers in their scope.
>  >  >  >
>  >  >  >
>  >  >  > Which is precisely what I'm trying to achieve. Namely, I need the 
> preprocessor to run before the inner ForEach controller executes, but it does 
> not happen. The Debug Sampler does not show any params_* suggesting that the 
> preprocessor didn't execute. I don't see what I'm doing wrong. :-(
>  >  >  >
>  >  >
>  >  >  You have put the PreProcessor inside the ForEach Controller, so it
>  >  >  only exectutes if the FE controller runs.
>  >  >
>  >  >
>  >  >
>  >  > But this is a Cathch-22! How can I put it inside, if it is not executed?
>  >  >  The purpose of that preprocessor is to create x_1, x_2, ... variables 
> that the inner ForEach consumes. So, this strategy will not work, right?
>  >  >
>  >
>  >  Don't put it inside; it needs to run *before* the ForEach controller
>  >  so the variables are set up ready for the FE C.
>  >
>  >
>  > I tried to attach it to an If Controller inside the outer ForEach without 
> success. It has to be a child of something. Still, it didn't work for me. :-(
>
>  As I wrote before, pre-processors apply to samplers. If there is no
>  sampler in scope, the pre-processor cannot and will not run.
>
>
> That's what it is! It didn't register the first time, my apologies. Now it 
> all fell into place. Except, in my case I need a dummy sampler. Right now I 
> applied it to Debug sampler. Is there a better choice? Thanks very much.
>

Why not use the BeanShell sampler? No need for a separate
pre-processor in that case.

>
>  > >
>  >  >  >
>  >  >  >  >
>  >  >  >  >  >       Output var prefix: reqparams
>  >  >  >  >  >       |
>  >  >  >  >  >       |
>  >  >  >  >  >       BeanShell preprocessor
>  >  >  >  >  >       |   String packed = vars.get("threetuple")
>  >  >  >  >  >       |   String[] tuples =packed.split("~");
>  >  >  >  >  >       |   for (int i = i; i <= tuples.length; i++) {
>  >  >  >  >
>  >  >  >  >  I presume that is int i = 1; ...
>  >  >  >  >
>  >  >  >  > Yes, of course, I was free typing, not cut'n pasting
>  >  >  >  >
>  >  >  >  >
>  >  >  >  >  >       |       vars.put("params" + "_" + i, tuples[i-1]);
>  >  >  >  >  >       |
>  >  >  >  >  >       |
>  >  >  >  >
>  >  >  >  >  This is all too late.
>  >  >  >  >
>  >  >  >  >  >       HTTP request
>  >  >  >  >  >       |
>  >  >  >  >  >       BeanShell preprocessor
>  >  >  >  >
>  >  >  >  >  Did you mean post-processor?
>  >  >  >  >
>  >  >  >  >
>  >  >  >  > No, the idea is to unpack the string into parameters for the HTTP 
> request.
>  >  >  >
>  >  >  >  OK, then it would be clearer to move it before the sampler, though 
> of
>  >  >  >  course that won't affect when it is called.
>  >  >  >
>  >  >  >  >
>  >  >  >  >  >            String packed = vars.get("params");
>  >  >  >  >  >            String[] names = new String[]{"type", "p1", "p2", 
> "p3"};
>  >  >  >  >  >            for (int i = 0; i < names.length; i++) {
>  >  >  >  >  >                vars.put(names[i], p[i]);
>  >  >  >  >  >            }
>  >  >  >  >  >
>  >  >  >  >  >
>  >  >  >  >  >  I have also tried vars.get("threetuple_1") in the first 
> BeanShell. No matter what I try, in the log I see 
> "jmeter.control.ForeachController: No entries found - null first entry: 
> params_1".
>  >  >  >  >
>  >  >  >  >  That's because it is null.
>  >  >  >  >
>  >  >  >  >  >  Sorry for badgering, but I must be missing something basic. 
> TIA,
>  >  >  >  >
>  >  >  >  >  Use the Debug Sampler to show what variables are set at that 
> point in
>  >  >  >  >  the test plan.
>  >  >  >  >
>  >  >  >  >
>  >  >  >  > That is golden, thank you. I tried to use it before, but probably 
> at the wrong place, so it didn't show me much.
>  >  >  >
>  >  >  >  Use it liberally.
>  >  >  >
>  >  >  >  >
>  >  >  >  >  >  -a
>  >  >  >  >  >
>  >  >  >  >  >
>  >  >  >  >  >  
> ---------------------------------------------------------------------
>  >  >  >  >  >  To unsubscribe, e-mail: 
> [email protected]
>  >  >  >  >  >  For additional commands, e-mail: 
> [email protected]
>  >  >  >  >  >
>  >  >  >  >  >
>  >  >  >  >
>  >  >  >  >  
> ---------------------------------------------------------------------
>  >  >  >  >  To unsubscribe, e-mail: 
> [email protected]
>  >  >  >  >  For additional commands, e-mail: 
> [email protected]
>  >  >  >  >
>  >  >  >  >
>  >  >  >  >  
> ---------------------------------------------------------------------
>  >  >  >  >  To unsubscribe, e-mail: 
> [email protected]
>  >  >  >  >  For additional commands, e-mail: 
> [email protected]
>  >  >  >  >
>  >  >  >  >
>  >  >  >
>  >  >  >  
> ---------------------------------------------------------------------
>  >  >  >  To unsubscribe, e-mail: [email protected]
>  >  >  >  For additional commands, e-mail: [email protected]
>  >  >  >
>  >  >  >
>  >  >  >  
> ---------------------------------------------------------------------
>  >  >  >  To unsubscribe, e-mail: [email protected]
>  >  >  >  For additional commands, e-mail: [email protected]
>  >  >  >
>  >  >  >
>  >  >
>  >  >  ---------------------------------------------------------------------
>  >  >  To unsubscribe, e-mail: [email protected]
>  >  >  For additional commands, e-mail: [email protected]
>  >  >
>  >  >
>  >  >  ---------------------------------------------------------------------
>  >  >  To unsubscribe, e-mail: [email protected]
>  >  >  For additional commands, e-mail: [email protected]
>  >  >
>  >  >
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: [email protected]
>  >  For additional commands, e-mail: [email protected]
>  >
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: [email protected]
>  >  For additional commands, e-mail: [email protected]
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [email protected]
>  For additional commands, e-mail: [email protected]
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [email protected]
>  For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to