lost and found ( for me ? )

multi-mechanize : performance and load test with multi-mechanize and python

about multi-mechanize

This tool generates traffic from your python scripts.
You could generate a wide variety of traffic with multi-mechanize and python scripts.

[root@f18 ~]# cat /etc/fedora-release ;uname -ri
Fedora release 18 (Spherical Cow)
3.9.4-200.fc18.x86_64 x86_64

[ installation ]

[root@f18 ~]# yum install -y  python-pip python-matplotlib

Downloading/unpacking multi-mechanize
 Downloading multi-mechanize-1.2.0.tar.gz
 Running setup.py egg_info for package multi-mechanize
   
Downloading/unpacking Mechanize (from multi-mechanize)
 Downloading mechanize-0.2.5.tar.gz (383kB): 383kB downloaded
 Running setup.py egg_info for package Mechanize
   
Installing collected packages: multi-mechanize, Mechanize
 Running setup.py install for multi-mechanize
   
   Installing multimech-run script to /usr/bin
   Installing multimech-newproject script to /usr/bin
   Installing multimech-gridgui script to /usr/bin
 Running setup.py install for Mechanize
   
Successfully installed multi-mechanize Mechanize
Cleaning up...



[ usage ]

at first , create a project
[root@f18 hattori]# multimech-newproject my_project

directory “my_project” will be created at your current working directory.
[root@f18 hattori]# ls my_project/
config.cfg  test_scripts

config.cfg : load , user definition file
test_scripts : python scripts for testing



[root@f18 hattori]# cat /home/hattori/my_project/config.cfg

[global]
run_time = 30
rampup = 0
results_ts_interval = 10
progress_bar = on
console_logging = off
xml_report = off


[user_group-1]
threads = 3
script = v_user.py

[user_group-2]
threads = 3
script = v_user.py

[root@f18 hattori]# ls /home/hattori/my_project/
config.cfg    results/      test_scripts/
[root@f18 hattori]# ls /home/hattori/my_project/test_scripts/
v_user.py  v_user.pyc





run multi-mechnize by using sample scripts.

run
[root@f18 hattori]# multimech-run my_project

 user_groups:  2
 threads: 6

[                  0%                  ]  0s/30s   transactions: 0  timers: 0  e[=                 3%                  ]  1s/30s   transactions: 0  timers: 0  e[===               7%                  ]  2s/30s   transactions: 6  timers: 6  e[====             10%                  ]  3s/30s   transactions: 7  timers: 7  e[=====            13%                  ]  4s/30s   transactions: 12  timers: 12 [======           17%                  ]  5s/30s   transactions: 17  timers: 17 [========         20%                  ]  6s/30s   transactions: 20  timers: 20 [=========        23%                  ]  7s/30s   transactions: 24  timers: 24 [==========       27%                  ]  8s/30s   transactions: 29  timers: 29 [================100%==================]  30s/30s   transactions: 112  timers: 112  errors: 0
waiting for all requests to finish...


analyzing results...

transactions: 118
errors: 0

test start: 2013-06-07 02:06:46
test finish: 2013-06-07 02:07:15

created: ./my_project/results/results_2013.06.07_02.06.45/results.html

done.

view a result file
[root@f18 hattori]# firefox /home/hattori/my_project/results/results_2013.06.07_02.06.45/results.html



generate HTTP traffic

create a project

[root@f18 hattori]# multimech-newproject http_load

[root@f18 hattori]# ls http_load/*
http_load/config.cfg

http_load/test_scripts:
v_user.py



make a python script for generating HTTP traffic
[root@f18 hattori]# cat /home/hattori/http_load/test_scripts/http_get.py
import mechanize
import time

class Transaction(object):
   def run(self):
       br = mechanize.Browser()
       br.set_handle_robots(False)

       start_timer = time.time()
       resp = br.open('http://127.0.0.1/')
       resp.read()
       latency = time.time() - start_timer

       self.custom_timers['Example_Homepage'] = latency

       assert (resp.code == 200)
       assert ('Example Web Page' in resp.get_data())



load profile
[root@f18 hattori]# cat /home/hattori/http_load/config.cfg
[global]
run_time = 30
rampup = 0
results_ts_interval = 10
progress_bar = off
console_logging = off
xml_report = off

[user_group-1]
threads = 100
script = http_get.py

run
[root@f18 hattori]# multimech-run http_load

 user_groups:  1
 threads: 100




analyzing results...

transactions: 1467
errors: 1467

test start: 2013-06-07 02:27:13
test finish: 2013-06-07 02:27:43

created: ./http_load/results/results_2013.06.07_02.27.13/results.html

done.

view the result file.
[root@f18 home]# firefox /home/hattori/http_load/results/results_2013.06.07_02.27.13/results.html




great tool !!!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.