On Thursday, August 30, 2012 at 10:32 PM, sebb wrote:
> On 30 August 2012 19:47, Morten Christensen (appinux)
> <[email protected] (mailto:[email protected])> 
> wrote:
> > On Thursday, August 30, 2012 at 8:22 PM, sebb wrote:
> > > On 30 August 2012 15:44, Morten Christensen (appinux)
> > > <[email protected] (mailto:[email protected])> 
> > > wrote:
> > > > Hi,
> > > > 
> > > > I am trying to extend JMeter with a custom login procedure that I have 
> > > > created using Http Client in a JavaSamplerClient. The custom login code 
> > > > creates 6 cookies on various domains and I want to add them to the 
> > > > JMeter's HTTP Cookie Manager that I have added to the Thread Group in 
> > > > my test plan in JMeter, so that subsequent HTTP REQUEST samplers will 
> > > > use them.
> > > 
> > > It's not clear why the existing HTTP Sampler cannot be used.
> > Because the login is for a very complex multi-domain App using a 
> > combination of POSTs, GETs, redirects and parsing/extracting about 30 
> > hidden input fields across multiple domains for the HTTP operations I use. 
> > Took a full day constructing and validating about 100 lines of Java code 
> > with crazy stuff going on. Not pretty and certainly not something I would 
> > care to try or even consider doing in JMeter.
> > 
> 
> 
> It may well have been tedious and tricky to do, but on the other hand
> the result would be usable without further hacking.
> 
> 

Yes, but even if I succeeded in creating using JMeter to login with a huge 
effort the result would be completely unmaintainable. I prefer to use tools 
that fit the solution versus using the "golden hammer" anti pattern. 

I do not believe it is unreasonable to be able to create custom HTTP login 
plugins for JMeter that works together with existing features but maybe this 
was never thought of by the JMeter developers?

> > > > My problem is that I can't access the instance of the HTTP Cookie 
> > > > Manager that JMeter is using and can't find any documentation about 
> > > > what to do.
> > > 
> > > 
> > > The CM is only made available to the HTTP Samplers.
> > This I have found also. But is it unreasonable to want to extend the 
> > existing HTTP samplers with a Login sampler that works together with the 
> > existing ones ?
> > > 
> > > But you may find that variable references in the CM will pick up
> > > cookies stored as variables by the login code.
> > > 
> > 
> > 
> > Yes, I saw something with CM and variables but I that CM and export to 
> > variables is not on by default.
> 
> I'm not talking about Cookie export here - AFAIK you don't need that.
> You want to add cookies to the CM.
> 
> 

Thinking about this again, I don't think it will work as I understand variables 
work across threads and I need to use different cookies for different threads 
representing different users having logged in.
 
> 
> > But if you think it is supported two-ways I might try to enable it and try. 
> > Not sure what I should call the variables though if the CM must be declared 
> > after my sampler runs etc. ?
> 
> 
> You can use whatever variable names you like, so long as they don't
> clash with others.
> 
> Try first with a simple UDV to define the vars and see what happens.
As stated above, I am afraid this won't support multiple users even if I can 
get UDV's to work ? 

Currently, my conclusion is that JMeter is to limited for my use. I guess I 
have to either program my own solution or find another tool with a more 
flexible plugin api. 

> > > > The provided JavaSamplerContext does not have anything of interest and 
> > > > nor does the JMeterContextService. I have also tried to cast the value 
> > > > of 
> > > > JMeterContextService.getContext().meterContext.getCurrentSampler().getProperty("HTTPSampler.cookie_manager")
> > > >  used by a source file I saw for the HTTP request but unfortunately 
> > > > this also did not work (returns null).
> > > > 
> > > > Any help will be much appreciated ? Alternatively, if it is impossible 
> > > > to create a simple JavaSamplerClient for custom cookie login, what is 
> > > > the recommended way?
> > > 
> > > What is it that the custom JavaSamplerClient does that the HTTP
> > > Sampler does not?
> > > 
> > 
> > 
> > The HTTP Sampler seems to be useful for trivial login only.
> 
> It can be used for lots of other cases too.
Yes, it is quite handy normally - just not for my use case.

> > My login case is unfortunately VERY complex involving a session accross 
> > multiple domains controlled by 6 different cookies.
> Should only be an issue if the cookies are dynamically created using 
> Javascript.
> 
> But I would still recommend using the standard HTTP Samplers; if
> necessary write special purpose Post-Processors to handle the
> responses.
> 
> Unfortunately, not something I can change. I can only test what is
> there (if I can login).
> 
> 

Thanks for your replies.

Cheers,
Morten

Reply via email to