您的位置:首页 > 编程语言 > PHP开发

07构建一个FTP测试计划

2017-07-06 18:06 183 查看

07构建一个FTP测试计划

Created Friday 30 June 2017

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 a 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.

本章你将会学习如何创建一个基本的对FTP站点的测试计划,我们将会创建4个用户对一个FTP站点请求两个文件,你也可以告诉用户运行测试两次。总的请求数是(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 View Results in Table.

为了构造测试计划,你会使用下面的元素:Thread Group, FTP Request, FTP Request Defaults, and View Results in Table。

7.1 添加用户

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.

每个JMeter测试计划的第一步都是添加一个Tread Group元素,Tread Group元素告诉Jmeter你想要模拟多少个用户,用户多久发送一下请求,他们会发送多少次请求。

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

回过头来,添加一个Thread Group元素先要通过选定测试计划来,然后点击你的鼠标右键到Add菜单,然后选择Add → ThreadGroup。

You 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.

你现在应该可以在测试计划下面看到线程组元素,如果你看不到,可以通过点击测试计划元素来“展开”测试计划树。

Next, 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 7.1 below)

下一步,你需要修改默认属性,如果你没有选中线程组元素,那么在树中选中线程组元素。你应该能够在JMeter窗口的右边部分看见线程组控制面板。



Figure 7.1. Thread Group with Default Values

Start by providing a more descriptive name for our Thread Group. In the name field, enter ‘FTP Users’.

先给我们的线程组一个更形象的名字,在名称字段,输入“FTP Users”。

Next, increase the number of users to 4.

接下来,增加用户数到4.

In the next field, the Ramp-Up Period, leave 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.

在下一个字段Ramp-Up Period,保留默认值0s,这个属性告诉JMeter每个用户启动之间有多久的延迟。例如,如果你输入Ramp-Up Period是5s,JMeter将会在5s结束的时候启动所有的用户。所以,如果我们有5个用户和5s的Ramp-Up Period,那么启动用户之间的延迟就是1s(5 users / 5 seconds = 1 user per second)。如果你设置值为0,那么Jmeter将会立即启动所有的你的用户。

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.

最后,在Loop Count字段输入2,这个属性告诉JMeter重复多少次你的测试,为了让JMeter反复的运行你的测试计划,选中Forever选择框。

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).在大部分应用中,你不得不手动的接受你在在控制面板中做的修改,在JMeter中,控制面板自动接受你做的修改。如果你修改了元素名,测试计划树将会在你离开控制面板后更新出新的文本(例如,当选中树中其他元素)。

See Figure 7.2 for the completed FTP Users Thread Group.



Figure 7.2. FTP Users Thread Group

7.2 添加默认FTP请求属性

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 7.3, you will add FTP Request elements which use some of the default settings you specified here.

现在我们已经定义了用户,是时候定义它们要执行的任务了,本节,你将给你的FTP请求指定默认配置。然后在7.3节,你将会添加FTP请求元素,请求元素会使用这些你指定的默认配置。

Begin by selecting the FTP 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 7.3).

先选中FTP用户元素,点击鼠标右键到添加菜单,然后选择Add → Config Element → FTP Request Defaults,然后选中这个新元素,来查看她的控制面板。



Figure 7.3. FTP Request Defaults

Like 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.

像大多数JMeter元素一样,FTP Request Defaults的控制面板有一个你可以修改的名称字段,在这个例子中,我们保留默认值。

Skip 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.domain.com in this case. 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.

跳到下一个元素,是FTP服务器的服务名称/IP,对于你要构建的测试计划,所有的FTP请求将会发送到相同的FTP服务器,在这个例子中是ftp.domain.com,将域名输入到这个字段。这是我们唯一需要指定的默认字段,剩下的字段保留默认值。

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.

FTP Request Defaults元素不会告诉JMeter发送FTP请求,它仅仅是定义了FTP请求元素使用的默认值。

See Figure 7.4 for the completed FTP Request Defaults element



Figure 7.4. FTP Defaults for our Test Plan

7.3 添加FTP请求

In our Test Plan, we need to make two FTP requests.

在我们的测试计划中,我们需要制作两个FTP请求。

JMeter sends requests in the order that they appear in the tree.JMeter按照他们在树中出现的顺序发送请求。

Start by adding the first FTP Request to the FTP Users element (Add → Sampler → FTP Request). Then, select the FTP Request element in the tree and edit the following properties (see Figure 7.5):

先添加地一个FTP Request到FTP Users元素(Add → Sampler → FTP Request)。然后选中树上的FTP Request元素,并编辑下面的属性:

Change the Name to “File1”.

修改Name为“File 1”。

Change the Remote File field to “/directory/file1.txt”.

修改Remote File字段为“/directory/file1.txt”。

Change the Username field to “anonymous”.

修改Username字段为“anonymous”。

Change the Password field to “anonymous@test.com“.

修改Password字段为”anonymous@test.com“。

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



Figure 7.5. FTP Request for file1

Next, add the second FTP Request and edit the following properties (see Figure 7.6:

接下来,添加第二个FTP Resquest并编辑下面的属性:

Change the Name to “File2”.

修改Name为”File2”。

Change the Remote File field to “/directory/file2.txt”.

修改Remote File字段为”/directory/file2.txt”。

Change the Username field to “anonymous”.

修改Username字段为”anonymous”。

Change the Password field to “anonymous@test.com“.

修改Password字段为”anonymous@test.com“。



Figure 7.6. FTP Request for file2

7.4 添加监听器查看保存测试结果

The 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.

最后你要添加到测试计划的元素是监听器。这个元素负责保存所有的你的FTP请求结果到文件中并展示一个可视化的数据模型。

Select the FTP Users element and add a View Results in Table listener (Add → Listener → View Results in Table).

选中FTP Users元素并添加View Results in Table listener (Add → Listener → View Results in Table)。

Run your test and view the results.



Figure 7.7. View Results in Table Listener
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  测试 jmeter