十五年测试老手,长期负责WEB\APP 项目测试,目前主要负责团队管理工作。

使用JMeter创建FTP测试计划

上一篇 / 下一篇  2011-07-02 08:53:47 / 个人分类:JMeter

51Testing软件测试网%o g&XY'H[j

In this section, you will learn how to create a basic Test Plan to test an FTP site. You will create four users that send requests for two files on the O'Reilly FTP site. Also, you will tell the users to run their tests twice. So, the total number of requests is (4 users) x (2 requests) x (repeat 2 times) = 16 FTP requests. To construct the Test Plan, you will use the following elements: Thread Group FTP Request , FTP Request Defaults , and Spline Visualizer.

W|L6AKn(E$QFI051Testing软件测试网-G({ B ZBG|"R

&|O#{,~Eka0
This example uses the O'Reilly FTP site, www.oro.com. Please be considerate when running this example, and (if possible) consider running against another FTP site.
51Testing软件测试网:c~iS \*r#E

h-J` bbb0

| o9_W2iDS!?051Testing软件测试网R:Bu.G^/_u,g


9gfRq sun C5rV$z#s?0
8.1 Adding Users
51Testing软件测试网Xj'Wu\)P'`mt?/\w

The first step you want to do with every JMeter Test Plan is to add a Thread Group element. The Thread Group tells JMeter the number of users you want to simulate, how often the users should send requests, and the how many requests they should send.

Br)JZ%h V051Testing软件测试网's9W%?H Uf7k

Go ahead and add the ThreadGroup element by first selecting the Test Plan, clicking your right mouse button to get the Add menu, and then select Add --> ThreadGroup.

fjHj&b dg0

c.k4Ltmo-c.W0You should now see the Thread Group element under Test Plan. If you do not see the element, then "expand" the Test Plan tree by clicking on the Test Plan element.

#sFM~3t6?0

)vF3EjQZ0Next, you need to modify the default properties. Select the Thread Group element in the tree, if you have not already selected it. You should now see the Thread Group Control Panel in the right section of the JMeter window (see Figure 8.1 below)

4S,^,p8O-bxh'iBf051Testing软件测试网2S8U#sK n1gWgf8y]

&I(VH*G-g9U0

'~(sw9FtK8k*D-U]W0Figure 8.1. Thread Group with Default Values

M/v"U al%k0

4\5jR `|9IX m051Testing软件测试网8VfiC,`!U

Start by providing a more descriptive name for our Thread Group. In the name field, enter O'Reilly Users.

t4`D%Z sFh/TXy F051Testing软件测试网5L7]e&tb(Xr

Next, increase the number of users to 4.51Testing软件测试网A:^H*H&OjY#t

51Testing软件测试网{+q(Ojw8K_&B

In the next field, the Ramp-Up Period, leave the the default value of 0 seconds. This property tells JMeter how long to delay between starting each user. For example, if you enter a Ramp-Up Period of 5 seconds, JMeter will finish starting all of your users by the end of the 5 seconds. So, if we have 5 users and a 5 second Ramp-Up Period, then the delay between starting users would be 1 second (5 users / 5 seconds = 1 user per second). If you set the value to 0, then JMeter will immediately start all of your users.

j*V#jTy%K;Bv051Testing软件测试网W,`2^-g(t}%t1[

Finally, enter a value of 2 in the Loop Count field. This property tells JMeter how many times to repeat your test. To have JMeter repeatedly run your Test Plan, select the Forever checkbox.51Testing软件测试网-Nng K+Okk]

;?&JBTo VlQ051Testing软件测试网5Z8x3cAaF.\

In most applications, you have to manually accept changes you make in a Control Panel. However, in JMeter, the Control Panel automatically accepts your changes as you make them. If you change the name of an element, the tree will be updated with the new text after you leave the Control Panel (for example, when selecting another tree element).
51Testing软件测试网lq%f`"ka,w N

^#X L8Bo P3Si051Testing软件测试网:}*avqj

See Figure 8.2 for the completed O'Reilly Users Thread Group.51Testing软件测试网:B8_*VP/{8L

51Testing软件测试网|4{M#{!L"X H

,LT [%}UR0
51Testing软件测试网:A;}DpS%Q
Figure 8.2. O'Reilly Users Thread Group
51Testing软件测试网D,R;~v5{-LqZ

!xm;F9H7m.g9W0
51Testing软件测试网F4Q1D V?)gP)[

51Testing软件测试网w8H(XW|Y?mUK]A


;{;y+T)v,R0
8.2 Adding Default FTP Request Properties
51Testing软件测试网uG S7LedhW

Now that we have defined our users, it is time define the tasks that they will be performing. In this section, you will specify the default settings for your FTP requests. And then, in section 8.3, you will add FTP Request elements which use some of the default settings you specified here.

"aKz4M!O2c0

OZ4ID0_3@hZ0Begin by selecting the O'Reilly Users element. Click your right mouse button to get the Add menu, and then select Add --> Config Element --> FTP Request Defaults. Then, select this new element to view its Control Panel (see Figure 8.3).

"`YoF5A B051Testing软件测试网5q0_HRV(B.a+h2_R[Oj

M/e-h b j Zv`s6W0
51Testing软件测试网 rSM$R(j_
Figure 8.3. FTP Request Defaults

pW kTVu^0

Od yDU/UDpa0

l1jJ4Iu_ T,F0Like most JMeter elements, the FTP Request Defaults Control Panel has a name field that you can modify. In this example, leave this field with the default value.

&AiG7gv _7\F0

@$P:Z6G Sk+\0Skip to the next field, which is the FTP Server's Server Name/IP. For the Test Plan that you are building, all FTP requests will be sent to the same FTP server, ftp.oro.com. Enter this domain name into the field. This is the only field that we will specify a default, so leave the remaining fields with their default values.

5[2p UGuI-`"m051Testing软件测试网1F9Fq*J7`BR

51Testing软件测试网'OHS#P,}w

The FTP Request Defaults element does not tell JMeter to send an FTP request. It simply defines the default values that the FTP Request elements use.

F mXm$K051Testing软件测试网3i4n%X"e)V

YC/A r;i u%H!G;_0See Figure 8.4 for the completed FTP Request Defaults element

:ii-x;Ph7A051Testing软件测试网J1Z{,i%Po ]x%_C]#q

51Testing软件测试网hfPs^%^

51Testing软件测试网3X]U gQ{2G:X m
Figure 8.4. FTP Defaults for our Test Plan
51Testing软件测试网9r:EL5rD9aim9yR

(C"Yy(P5q!Y Zr$GP0
51Testing软件测试网6]e j {?`Y }

j l;x/w+P [5Q0
51Testing软件测试网9|rnP4Bu)_
8.3 Adding FTP Requests
51Testing软件测试网A HYR(\6u7v/_6@]W

In our Test Plan, we need to make two FTP requests. The first one is for the O'Reilly mSQL Java README file (ftp://ftp.oro.com/pub/msql/java/README), and the second is for the tutorial file (ftp://ftp.oro.com/pub/msql/java/tutorial.txt).51Testing软件测试网'M7niWIR+u

D%vv N4FPDa0BfFF%[051Testing软件测试网"bj6b[I

JMeter sends requests in the order that they appear in the tree.
51Testing软件测试网YlQ^\ y4h

51Testing软件测试网,B i }3t$}1t [g

51Testing软件测试网:o c`D$t+Cq7R%LV

Start by adding the first FTP Request to the O'Reilly Users element (Add --> Sampler --> FTP Request). Then, select the FTP Request element in the tree and edit the following properties (see Figure 8.5):51Testing软件测试网jvMxXe|

  1. Change the Name to "README".
  2. Change the File to Retrieve From Server field to "pub/msql/java/README".
  3. Change the Username field to "anonymous".
  4. Change the Password field to "anonymous".
51Testing软件测试网sG/D3o;M1SE6d

51Testing软件测试网q;pW,p$\G(i@1~

n_:T9^OY"R051Testing软件测试网 P6_Wo!zv8\&L~

You do not have to set the Server Name field because you already specified this value in the FTP Request Defaults element.

4F;d:A rr!C7vI^r1V)a051Testing软件测试网7tsTjG$C

51Testing软件测试网uE-Pu.e8]Jh*a5S

51Testing软件测试网9Lk-dn3`j7O0u


h2I[m{0Figure 8.5. FTP Request for O'Reilly mSQL Java README file
51Testing软件测试网 wnJ TuAY

-T C ZX[*@t051Testing软件测试网V3zXL T Is4l

Next, add the second FTP Request and edit the following properties (see Figure 8.6:51Testing软件测试网0y y;{8]e\C!{ Oa

  1. Change the Name to "tutorial".
  2. Change the File to Retrieve From Server field to "pub/msql/java/tutorial.txt".
  3. Change the Username field to "anonymous".
  4. Change the Password field to "anonymous".

hUUhg*j;W051Testing软件测试网VFXjE8v`

51Testing软件测试网 p|5^H\

51Testing软件测试网@7wB-dZM,K)q

51Testing软件测试网5x&BKEi
Figure 8.6. FTP Request for O'Reilly mSQL Java tutorial file
51Testing软件测试网9E9[8L n y#f!z;hV}oC

51Testing软件测试网Dj:m2\:[Y9w

51Testing软件测试网eZT#N6c.z6{6R u'f{

51Testing软件测试网x!O9i)c*]~:OhH8a8s


W$D!|Go M0
8.4 Adding a Listener to View/Store the Test Results

#s(z.m T G6B,@,zPk._*|0The final element you need to add to your Test Plan is a Listener . This element is responsible for storing all of the results of your FTP requests in a file and presenting a visual model of the data.

4vfD9F,\lK0

n.k!j3u2O.I0Select the O'Reilly Users element and add a Spline Visualizer listener (Add --> Listener --> Spline Visualizer).

;xg/r.b3s&p)H-L+U-[0

.G@$`m hn Ew]0

/Z0O`/RjEc0

2C8k7h N([^)z0Figure 8.7. Spline Visualizer Listener

TAG: Jmeter JMeter jmeter JMETER

 

评分:0

我来说两句

Open Toolbar