Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

S dng Jmeter

Trc khi bt u test chng ta lp 1 test plan s h tro Jmeter thuc hin. C 1 vi yu t trong test plan
nh thread groups, listeners, assertions, sample generating controllers, logic controllers etc. Nhng yu t
ny s oc m t nh hnh di. Nn nh y rng 1 test plan phi c t nht 1thread group
Group
Purpose
Samplers: Nhng phn t ny l send requests n servers. C nhng samplers cho nhng kiu request:
HTTP/HTTPS, FTP, SOAP, JDBC, "Java"
Listeners: Chng l tp nhng kt qu ca run test ca ban
Timers: oc s dng chn tr gia nhng request. Chng cn lm cho test ca ban hin thuc
hon
Logic Controllers: Nunhng request oc jnh ngha trong test plan ca ban s thuc thi ph thuc vo 1
vi logic, th ban cn n logic controllers. Chng thch hop cu trc if-then-else v loop trong java hay bt
c programming language khc.
Configuration Elements: Chng lm vic vi samplers bng cch thm nhng thng tin chung vi nhng
request.
Assertions: Cho php ban kim tra nu responses ban ly cha d liu mong oi hay nhn trong pham vi
thi gian jnh sn.
Step 1: Bt u chay JMeter th chay file JMeter.bat cho Windows hay JMeter file trn Unix.
Step 2: Create a thread group bng cch right-clicking Test plan element nh oc biu din trong hnh
trn. Sau chon ADD ri chon Thread group option. Sau khi chon thread group option mt thread group
element s oc tao bi Jmeter under Test Plan element. By gi xc thuc v s long user oc gi
lp vi ngi test v s ln test plan oc lp lai
Mt s thuc tnh c th thit lp nh bn di:
Name -- Ban c th tao bt c tn cho thread group
Number of Threads -- Ban c th nhp nhiu threads gi lp. Mi user c lp oc ai din bi mi
thread v vy ban mun gi lp vi 5 user ng thi ban cn nhp gi trj 5 cho thuc tnh ny.
Ramp-Up Period -- Cho bit thi gian a ra bi jmeter tao tt c nhng thread cn thit. Nu ban thit
lp 10s tai ramp-up period cho 5 thread th Jmeter s thuc hin trong 10s tao ra 5 thread. Ngoi ra
bng cch thit lp n gi trj 0 tt c threads c th oc tao 1 ln.
Forever -- Nu ban chon option ny th Jmeter s quyt jnh thi gian gi request
Loop Count -- Bng cch chi r gi trj ca n Jmeter cho bit rng c bao nhiu ln lp kim th oc lp
vi u kin l Forever check box oc uncheck
Step 3: By gi cn cp n HTTP request (URL and parameters). Click bn phi voThread Group
node ri chon Add -> Sampler -> HTTP Request nh hnh biu din
The following properties can be set on the HTTP Request screen.
Name -- Ban s a m t tn tai thread group c th c nhiu HTTP Request elements.
Server Name or P -- cp server name hay ja chi P ca my m ban chay ng dng oc kim th
Port Number -- Chi ra port number m Web applications chay thng l 80
Protocol -- cp giao thc oc s dng v d hoc HTTPS hoc HTTP
Method -- Phong thc GET hay POST
Path -- Ban cn cp ng dn ngun s x l request ny.
Follow Redirects -- follows redirect ions, if any , sent by the Web application.
Parameters -- Option ny biu din danh sch thng s gi vi request. Ban c th thm xo thng s ny
Send a file with a request -- Option ny upload file c th oc gi lp trong Web application
Retrieve all images and Java Applets -- Option ny oc s dng download ni dung embedded
Step 4: jnh dang nhng kt qu, right-clicking vo Thread group node ri chon Add -> Listener -> View
Results Tree.
Step 5: By gi l thi im run the Test plan by selecting Run from the menu v ri select Start (or
Ctrl-R): t test plan oc lp lai 10 ln View Result Tree nh oc biu din bn di
Step 6: Kt qu s oc nhn thy trong Results Tree sau khi hon thnh test plan. Ban c th thy hnh
bn di chng ta c th chon chon request u tin trong bn trn v ngoi ra request pht sinh kt
qu trong form ca 1 HTML page with the text "Hello World!"
Step 7: Jmeter c tnh nng cn quan tm l Add more listeners. Ban c th thm View Results trong
Table listener hin thj requests in tabular form nh biu din bn di
Ngoi ra ban c th thm Aggregate Report listener ly tm tt nh bn di
Step 8: lu test plancho ln sau s dng chon File from the menu v ri Save Test Plan (hay Ctrl-S)
Chay load test
Ban cng c th hin thj thj ca test sau khi ang chay n. Bng cch Thread group -> Add -> Listener
-> Graph results
Biu nh trn l test results vi number of threads = 5, ramp-up time = 10, loop count = 100, v loop
controller thit lp l 1.
Ba thng s trong biu oc hin thj throughput (green line), median (purple line) and average (blue
line). Nu chng ta sa thng s gi lp cao hon bng cch tng number of threads l 50, v thay i
ramp-up time l 5 v loop count l 20, th chng ta s oc thj sau y bng cch bt u chay lai test
The meaning of the parameters at the bottom of the chart is as follows: ( ngha ca nhng thng s bn
di ca biu nh sau
S long request oc x l bi server trn pht oc chi r bi Throughput.
Average oc tnh ton nh tng thi gian chay oc chia bi s request oc gi n server.
Thi gian oc miu t bi Median i.e. mt na response time caserver l t hon s long ny.
Su bin response time ca server oc chi r bi Deviation.
Hon thnh request cui cng oc biu din bi Latest.
Bng bn di tm tt 2 ln chay:
Number of threads
Throughput, responses/minute
Average, ms
Median, ms
5
1665
57
31
50
174
314
62
Ban cng c th thm Spline Visualier hnh dung test results ca tt c nhng ln th.
The same test results have been shown using Spline Visualier.
=====================================
S dng Recording
1. Bt u jmeter vi jmeter.bat trn windows v jmeter.sh trn unix
2. Chon test plan trn tree
3. Right click vo test plan v thm 1 thread group: add -> thread group
4. Chon thread group
5. Right click add -> config element -> Http Request Defaults
6. Protocol v d nhp HTTP
7. Server name v d nhp jakarta.apache.org
8. Path trng
. Port number v d nhp 80
10.Chon workbench
11.Right click trn workbench v thm Http proxy: add -> non-test elements -> Http
Proxy Server
12.Port field - v d nhp 00
13.Target Controller click vo drop down v chon test plan > thread group
14.Click button add trn Patterns to include. N s tao ra 1 vng trng.
15. V d nhp ..html
16.Click button add trong Patterns to exclude. N s tao ra 1 vng trng.
17. V d nhp ..gif
18.Click button start di cng
1.M nternet Explorer, nhng khng oc ng Jmeter.
Ch : Chc chn include v exclude patterns l ng. Bn di l nhng k tu ph bin.
. - all
..png png images
..gif gif images
..jpg jpeg images
..php
..jsp
..html
..htm
..js
20.T tool bar, click tools -> internet options.
21.Chon tab connection
22.Click button lan settings.
23.Trn tab connections, check Use a proxy server for your LAN. Trng ja chi v port s enable.
24.Address Nhp Localhost hay P address ca h thng
25.Port v d port 00. (Trng port Http Proxy Server)
26.Click ok button
27.Click ok button lai. N s tr v trnh duyt
28.Trong Address, v d nhp Thnh vin mi thy link .
2.Click vo 1 vi links Jmeters page.
30.Close internet explorer v bring up the Jmeter window.

You might also like