best way to parameterize test?

164 views
Skip to first unread message

jd

unread,
Oct 5, 2010, 5:17:21 PM10/5/10
to multi-mechanize
I am interested in load testing a web service of ours that handles
registrations of new users. Since our system requires the username to
be unique (upon registration) I need to create a load test that I can
inject some simple parameters to simulate 5000 *different* users all
registering over a few minute span. Is there a way I can do that using
a multi-mechanize script? I am interested in using httplib directly
since I need to post JSON to our registration endpoint. On the
surface, it seems like multi-mechanize is configured more for running
the same case repeatedly. I want to still utilize the power of the
threading that your engine provides, but I need each thread to run the
test case with some slightly different data.

This tool looks great - I am hoping I can use it. Any feedback you can
provide would be really helpful!

Thanks,

JD

Rob Dennis

unread,
Oct 5, 2010, 6:36:33 PM10/5/10
to multi-m...@googlegroups.com
JD,

I this situation, I've used the uuid module and uuid.uuid4() to to get a universally unique identifier on each invocation of run(). This may be appropriate for your purposes.

Thanks,
-Rob

corey goldberg

unread,
Oct 7, 2010, 2:23:19 PM10/7/10
to multi-mechanize
Hi JD,

yes, you can certainly do parametrization and data-driven testing. I
don't have any examples posted, but I'll add some content to the wiki
and update this thread when I get some time.

but basically...
since your scripts are pure python, you have a lot of options of how
you want to implement a data driven test. you can embed data in your
scripts, or read from a db, or file. The easiest approach for a case
like yours is probably to have a text file containing your parameter
values. you could have a rows of csv values like "username, password,
whatever".
then, inside the __init__() method of your test Transaction, you can
load the data files with a csv reader and have access to the data from
inside your run() method.


also...
scripts have access to the following variables which can be useful for
loading unique data:
- thread_num
- process_num

so.. lets say I have a simple data file that is just a list of user
names. I can do something like this to load data inside my
__init__():

with open('/path/usernames.txt') as f:
self.user_names = f.read().splitlines()

then inside my run() method, I can do:

user_name = self.user_names[self.thread_id]

and user_name would be unique to that VU/thread.


That is a really rushed explanation and perhaps hard to follow :)
I'll get together some sample code and post it when I get time.

hth,

-Corey

Kester Mielke

unread,
Apr 29, 2013, 5:49:26 AM4/29/13
to multi-m...@googlegroups.com
Hi Corey,

i am not able to access self.thread_num oder self.process_num. Any hints?

Thx
Regards
Kester
Reply all
Reply to author
Forward
0 new messages