You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Sriharsha Setty <sr...@gmail.com> on 2010/08/04 16:02:44 UTC

Jmeter HTTP objects

Hello users,

I want to process a HTTP response after Jmeter performs a POST operation.
For this, I believe, that one needs to add a Beanshell Post processor to
process the HTTP response. Please correct me if I am wrong.

If I am correct, I want to know the object name that I need to reference in
my Beanshell PostProcessor. Is this documented some where?

Thanks,
/harsha

Re: Jmeter HTTP objects

Posted by Deepak Shetty <sh...@gmail.com>.
Hi
>I basically want to store several doc ids returned (as responses) by
earlier samplers  and randomly do GETs on them.
Storing yes. The random part you may or may not be able to do depending on
your test plan

regards
deepak

On Wed, Aug 4, 2010 at 10:39 AM, Sriharsha Setty
<sr...@gmail.com>wrote:

> On Wed, Aug 4, 2010 at 10:59 PM, Deepak Shetty <sh...@gmail.com> wrote:
>
> > hi
> > why do you need it written into a file? When you say 'parse' how many
> > elements are we talking about? or do you just want the entire response
> > written?
> >
>
>  Like I said, I have a HTTP sampler that POSTs a JSON payload to a CouchDB
> server; The server returns a JSON response with the doc id. I want to store
> only the doc id (after parsing response), and use it in in the next sampler
> by GETing the document with the doc id.
>
>
> > a regular expression extractor can extract out data into a variable that
> > the
> > following samplers can use
> >
> > I basically want to store several doc ids returned (as responses) by
> earlier samplers  and randomly do GETs on them.  Can I achieve it with
> regular expression extractors?
>
> /harsha
>

Re: Jmeter HTTP objects

Posted by Sriharsha Setty <sr...@gmail.com>.
On Wed, Aug 4, 2010 at 10:59 PM, Deepak Shetty <sh...@gmail.com> wrote:

> hi
> why do you need it written into a file? When you say 'parse' how many
> elements are we talking about? or do you just want the entire response
> written?
>

 Like I said, I have a HTTP sampler that POSTs a JSON payload to a CouchDB
server; The server returns a JSON response with the doc id. I want to store
only the doc id (after parsing response), and use it in in the next sampler
by GETing the document with the doc id.


> a regular expression extractor can extract out data into a variable that
> the
> following samplers can use
>
> I basically want to store several doc ids returned (as responses) by
earlier samplers  and randomly do GETs on them.  Can I achieve it with
regular expression extractors?

/harsha

Re: Jmeter HTTP objects

Posted by Deepak Shetty <sh...@gmail.com>.
The regex  extractor itself lets you select a match number with a 0 for
random when multiple matches are found. so you should be able to us4e that
directory

regards
deepak

On Thu, Aug 5, 2010 at 12:21 AM, Sriharsha Setty
<sr...@gmail.com>wrote:

> [Sorry, hit the send button too early]
>
> On Thu, Aug 5, 2010 at 12:48 PM, Sriharsha Setty
> <sr...@gmail.com>wrote:
>
> > Thanks Deepak,
> >
> > On Wed, Aug 4, 2010 at 10:59 PM, Deepak Shetty <sh...@gmail.com>
> wrote:
> >
> >> a regular expression extractor can extract out data into a variable that
> >> the
> >> following samplers can use
> >>
> >
> > I am able to extract the required text from the POST response, and I feed
> > it immediately to a HTTP sampler that does a GET on it.
> >
>
> My test plan looks something like this:
>
> Post Thread group
>    Post HTTP request sampler
>        Extract_info (regex)
>    Get HTTP request sampler.
>
>
> Any idea how to randomize this plan?
>

Re: Jmeter HTTP objects

Posted by Sriharsha Setty <sr...@gmail.com>.
[Sorry, hit the send button too early]

On Thu, Aug 5, 2010 at 12:48 PM, Sriharsha Setty
<sr...@gmail.com>wrote:

> Thanks Deepak,
>
> On Wed, Aug 4, 2010 at 10:59 PM, Deepak Shetty <sh...@gmail.com> wrote:
>
>> a regular expression extractor can extract out data into a variable that
>> the
>> following samplers can use
>>
>
> I am able to extract the required text from the POST response, and I feed
> it immediately to a HTTP sampler that does a GET on it.
>

My test plan looks something like this:

Post Thread group
    Post HTTP request sampler
        Extract_info (regex)
    Get HTTP request sampler.


Any idea how to randomize this plan?

Re: Jmeter HTTP objects

Posted by Sriharsha Setty <sr...@gmail.com>.
Thanks Deepak,

On Wed, Aug 4, 2010 at 10:59 PM, Deepak Shetty <sh...@gmail.com> wrote:

> a regular expression extractor can extract out data into a variable that
> the
> following samplers can use
>

I am able to extract the required text from the POST response, and I feed it
immediately to a HTTP sampler that does a GET on it.


My test plan looks something like this:
Post thread group

Re: Jmeter HTTP objects

Posted by Deepak Shetty <sh...@gmail.com>.
hi
why do you need it written into a file? When you say 'parse' how many
elements are we talking about? or do you just want the entire response
written?
a regular expression extractor can extract out data into a variable that the
following samplers can use

regards
deepak

On Wed, Aug 4, 2010 at 10:27 AM, Sriharsha Setty
<sr...@gmail.com>wrote:

> Hi Deepak
>
> On Wed, Aug 4, 2010 at 10:50 PM, Deepak Shetty <sh...@gmail.com> wrote:
>
> > >I want to process a HTTP response after Jmeter performs a POST
> operation.
> > Define what you want to do. There are other Post processors available. If
> >
>
> My application returns a JSON payload as response. I want to parse the JSON
> payload and write it into a file. I have another HTTP Sampler that
> reads(__StringFromFile)  this file and performs a GET on it.
>
> Thanks,
> /harsha
>

Re: Jmeter HTTP objects

Posted by Sriharsha Setty <sr...@gmail.com>.
Hi Deepak

On Wed, Aug 4, 2010 at 10:50 PM, Deepak Shetty <sh...@gmail.com> wrote:

> >I want to process a HTTP response after Jmeter performs a POST operation.
> Define what you want to do. There are other Post processors available. If
>

My application returns a JSON payload as response. I want to parse the JSON
payload and write it into a file. I have another HTTP Sampler that
reads(__StringFromFile)  this file and performs a GET on it.

Thanks,
/harsha

Re: Jmeter HTTP objects

Posted by Deepak Shetty <sh...@gmail.com>.
I dont know why you want to do this since your requirements are satisified
without BeanShell, anyway,


 the Sample Result is something that is passed to you , you dont have to
create it
>From here
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_PostProcessor
You get
prev - (SampleResult) - gives access to the previous SampleResult
And from
http://jakarta.apache.org/jmeter/api/org/apache/jmeter/samplers/SampleResult.html#getResponseHeaders()
you get the correct method name

so
String str = prev.getResponseHeaders();

> log.info(str);


if you have errors in code you should see it in jmeter.log



On Tue, Aug 17, 2010 at 1:34 AM, Sriharsha Setty
<sr...@gmail.com>wrote:

> Hi Deepak,
>
>
> On Wed, Aug 4, 2010 at 10:50 PM, Deepak Shetty <sh...@gmail.com> wrote:
>
> >
> >
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_PostProcessor(note<http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_PostProcessor%28note>
> <
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_PostProcessor%28note
> >
> > the The following BeanShell variables are set up for use by the
> > script: ) and read about the objects at
> > http://jakarta.apache.org/jmeter/api/index.html
> >
> >
> After giving it a thought, I've decided that I should parse the response
> data using a BeanShell PostProcessor.
> I am adding a BeanShell PostProcessor to a HTTP Sampler (does a POST;
> receives an XML response).
>
> I am not too familiar with Java, so to start off, I wrote the following
> snippet to understand if I am doing it right. I expect the HTTP response
> header to be printed in jmeter.log, but I don't see it. I am doing
> something
> wrong here or have I missed doing something completely?
>
>
> import org.apache.jmeter.protocol.http.samplers.SampleResult;
> SampleResult sr = new SampleResult();
> String str = sr.getResponseHeadersAsString();
> log.info(str);
>

Re: Jmeter HTTP objects

Posted by Sriharsha Setty <sr...@gmail.com>.
Hi Deepak,


On Wed, Aug 4, 2010 at 10:50 PM, Deepak Shetty <sh...@gmail.com> wrote:

>
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_PostProcessor(note<http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_PostProcessor%28note>
> the The following BeanShell variables are set up for use by the
> script: ) and read about the objects at
> http://jakarta.apache.org/jmeter/api/index.html
>
>
After giving it a thought, I've decided that I should parse the response
data using a BeanShell PostProcessor.
I am adding a BeanShell PostProcessor to a HTTP Sampler (does a POST;
receives an XML response).

I am not too familiar with Java, so to start off, I wrote the following
snippet to understand if I am doing it right. I expect the HTTP response
header to be printed in jmeter.log, but I don't see it. I am doing something
wrong here or have I missed doing something completely?


import org.apache.jmeter.protocol.http.samplers.SampleResult;
SampleResult sr = new SampleResult();
String str = sr.getResponseHeadersAsString();
log.info(str);

Re: Jmeter HTTP objects

Posted by Deepak Shetty <sh...@gmail.com>.
>I want to process a HTTP response after Jmeter performs a POST operation.
Define what you want to do. There are other Post processors available. If
they dont satisfy your needs then you might want to look at BSF/Beanshell
Documents are here
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#BeanShell_PostProcessor(note
the The following BeanShell variables are set up for use by the
script: ) and read about the objects at
http://jakarta.apache.org/jmeter/api/index.html

regards
deepak


On Wed, Aug 4, 2010 at 7:02 AM, Sriharsha Setty
<sr...@gmail.com>wrote:

> Hello users,
>
> I want to process a HTTP response after Jmeter performs a POST operation.
> For this, I believe, that one needs to add a Beanshell Post processor to
> process the HTTP response. Please correct me if I am wrong.
>
> If I am correct, I want to know the object name that I need to reference in
> my Beanshell PostProcessor. Is this documented some where?
>
> Thanks,
> /harsha
>