You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Antti Holappa <an...@smartner.com> on 2002/04/02 18:37:10 UTC
RE: Multiple users.
I did a similar hack to my JMeter sources last month.
I had a group of users, user1-100 with the same password and a site that
needs two post parameters "username" and "password" for login. After
studying the code I made some quick changes to the source (see below) to
quickly get some tests going on with multiple users.
After the changes I created a test plan with Cookie Manager and put
(basicly) four controls to it:
1. Cookie Manager
2. HTTP Request for the sites homepage (to get a new cookie for the thread)
3. HTTP Request to the login servlet with two post parameters:
Name: Value:
username user%unum%
password 111111
4. HTTP Request for the logout page
(As you can see below the %unum% in username parameter is replaced with the
threads name/number).
This was just a quick&dirty solution but might be useful for someone in a
hurry to get some test results.
Antti H.
<code class="org.apache.jmeter.threads.JMeterThread">
public void run()
{
Thread.currentThread().setName(String.valueOf(threadNumberInGroup+1));
//System.out.println("Running thread " + threadNumberInGroup);
running = true;
...
</code>
<code class="org.apache.jmeter.protocol.http.sampler.HTTPSampler">
public void sendPostData(URLConnection connection, UrlConfig url) throws
IOException
{
((HttpURLConnection) connection).setRequestMethod("POST");
-> String postData = modifyPostData(url.getQueryString());
connection.setRequestProperty("Content-length", "" + postData.length());
connection.setRequestProperty("Content-type",
"application/x-www-form-urlencoded");
connection.setDoOutput(true);
PrintWriter out = new PrintWriter(connection.getOutputStream());
out.print(postData);
out.close();
}
// added by aholappa -->
public String modifyPostData(String postData) {
int i = postData.indexOf("%25unum%25");
if (i==-1) {
return postData;
}
String number = Thread.currentThread().getName();
//System.out.println("Modifying number is : " + number);
return postData.substring(0,i) + number + postData.substring(i+10);
}
// <-- added by aholappa
</code>
> -----Original Message-----
> From: david garcia [mailto:mr4dmusic@yahoo.com]
> Sent: 31. maaliskuuta 2002 2:18
> To: JMeter Users List
> Subject: Re: Multiple users.
>
>
>
> I would love to take a look at the patch. I have been
> looking at the code and trying to figure out a way to do it. . .
> Henrik Ridder <he...@partitur.se> wrote: I did a
> modification of JMeter some time ago, just because I needed unique
> users.
>
> At that time I had do alter the code a bit. I haven't follow
> the developmet
> of JMeter for some time now and I don't know if there is a
> easy way to do
> it now.
>
> I don't think that patch will work on JMeter1.7 that is out now.
>
> But if the plan for Avalon is on the way I really hope they add that
> feature in that version.
>
> If you want I'll send you the patch and you can see if you
> can do anything
> with it.
>
> Not much help I'm afraid.
>
> Henrik
>
> --On den 29 mars 2002 16:17 -0800 david garcia wrote:
>
> >
> > So it appears that Jmeter threads are actually multiple
> instances of the
> > same user. Of course the most common thing to do in load
> testing is to
> > have each thread be an unique user. From reading the jmeter
> docs, It is
> > not clear that this is even possible. Has anybody out there
> done? If so
> > how? I suspect that the modification manager is involved
> somehow, yet I
> > cannot quite see how when I read the docs. . .
> >
> > -David-
>
> >
> >
> >
> > ---------------------------------
> > Do You Yahoo!?
> > Yahoo! Greetings - send greetings for Easter, Passover
>
>
>
> --------------------------------
> Partitur Informationsteknik AB
> Wenner-Gren Center
> SE-113 46 Stockholm, Sweden
>
> tel. +46 8 566 280 00
> ext. +46 8 566 280 09
> fax. +46 8 566 280 20
> mob. +46 708 83 66 67
>
> http://www.partitur.se/
> --------------------------------
> PING PONG - simply more fun
>
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:
>
>
>
> ---------------------------------
> Do You Yahoo!?
> Yahoo! Greetings - send greetings for Easter, Passover
>