You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by je...@bnf.fr on 2005/01/20 16:49:42 UTC

reading file in a While Controller

Hello,

I want to read a file inside a while controller, each line of the file
contains an http request. A same user has to do all the resquests of the
file.
So I did a test plan which looks like this:

Simple Controller
  |
  \
    While Controller (LAST)
      User Defined Variable:
${_StringFromFile(${requeteUtilisateur},ligneCourante,,)}
      HttRequest ( logUtilisateur )
            |
            \ assertion


 (${requeteUtilisateur} contains the file to be read)

My problem is that only the first line of the file is read.
The second time the script enters in the loop, it still read the first
line, when I want it to read the next line.

Thanks for you attnetion
Jerome



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Réf. : Re: reading file in a While Controller

Posted by sebb <se...@gmail.com>.
The following test plan works for me:

Thread Group (forever)
 - User Parameters (Pre-Processor), with:
     * update once per iteration
     * Name=V, User_1=${_StringFromFile(sff.txt,,,1)}
 - Request that uses ${V}
 - Table Listener.

sff.txt contains a few lines of text - the sampler will be run once
for each line in the file.

In fact, you don't need the While Controller for this - StringFromFile
will stop the thread if it runs out of files to process. In this case
the count is 1, so it will stop processing at the end of the file.

Try it and see.

S.
On Fri, 21 Jan 2005 14:38:56 +0100, jerome.dupont@bnf.fr
<je...@bnf.fr> wrote:
> Hi, and Thanks for your answer:
> 
> I tried with a loop, and it still doesn't work, so I logged the user param
> section, to understand what happens exactly.
> 
> User Defined variable
>       webcca = ${_StringFromFile(${fichierWebCca},requeteUtilisateur,,)}
> 
> loop (2)
>     User Defined Variable:
>         ${_StringFromFile(${requeteUtilisateur},ligneCourante,,)}
>         ${__logn(LECTURE  ligne courante de ${requeteUtilisateur}:
> ${ligneCourante}:   ,,)}
>         http request (  ${ligneCourante}  )
> Assert Results
> 
> The file pointed by ${requeteUtilisateur} contains
> url1
> url2
> 
> In the assertion result pane, I can see that the httprequest is sent twice,
> but with url1 parameter each time.
> In the log file, I can see the message correspondig to "__logn(LECTURE
> ligne courante de ${requeteUtilisateur}: ${ligneCourante}:" only once.
> 
> It's like , the http request is executed 2 times while the User Defined
> Variable once.
> 
> I tried with several value for StringToFile last parameter (no value, 1 and
> 2), but it behave the same, reading the first line of the file.
> 
> Regards,
>       Jerome
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Réf. : Re: reading file in a While Controller

Posted by je...@bnf.fr.
Hi, and Thanks for your answer:

I tried with a loop, and it still doesn't work, so I logged the user param
section, to understand what happens exactly.

User Defined variable
      webcca = ${_StringFromFile(${fichierWebCca},requeteUtilisateur,,)}

loop (2)
    User Defined Variable:
        ${_StringFromFile(${requeteUtilisateur},ligneCourante,,)}
        ${__logn(LECTURE  ligne courante de ${requeteUtilisateur}:
${ligneCourante}:   ,,)}
        http request (  ${ligneCourante}  )
Assert Results

The file pointed by ${requeteUtilisateur} contains
url1
url2

In the assertion result pane, I can see that the httprequest is sent twice,
but with url1 parameter each time.
In the log file, I can see the message correspondig to "__logn(LECTURE
ligne courante de ${requeteUtilisateur}: ${ligneCourante}:" only once.

It's like , the http request is executed 2 times while the User Defined
Variable once.

I tried with several value for StringToFile last parameter (no value, 1 and
2), but it behave the same, reading the first line of the file.

Regards,
      Jerome



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: reading file in a While Controller

Posted by sebb <se...@gmail.com>.
You may be able to use the End count parameter instead of the While Controller:

http://jakarta.apache.org/jmeter/usermanual/functions.html#__StringFromFile

In your case, try using:

${_StringFromFile(${requeteUtilisateur},ligneCourante,,1)}

and set the test to run forever, or perhaps with a time limit.

Or use a Loop Controller or possibly a Runtime Controller.
These can be set to expire sometime after the file has been fully
read. I.e, if the file contains at most 1000 records, set the Loop
Count >=1000, etc.

S.

On Thu, 20 Jan 2005 16:49:42 +0100, jerome.dupont@bnf.fr
<je...@bnf.fr> wrote:
> Hello,
> 
> I want to read a file inside a while controller, each line of the file
> contains an http request. A same user has to do all the resquests of the
> file.
> So I did a test plan which looks like this:
> 
> Simple Controller
>   |
>   \
>     While Controller (LAST)
>       User Defined Variable:
> ${_StringFromFile(${requeteUtilisateur},ligneCourante,,)}
>       HttRequest ( logUtilisateur )
>             |
>             \ assertion
> 
>  (${requeteUtilisateur} contains the file to be read)
> 
> My problem is that only the first line of the file is read.
> The second time the script enters in the loop, it still read the first
> line, when I want it to read the next line.
> 
> Thanks for you attnetion
> Jerome
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org