Jmeter使用http proxy方式录制
- 格式:docx
- 大小:188.29 KB
- 文档页数:3
JMETER中文手册1.简介Apache JMeter是100%纯java桌面应用程序,被设计用来测试C/S结构的软件(例如web应用程序)。
它可以用来测试包括基于静态和动态资源程序的性能,例如静态文件,Java Servlets,Java对象,数据库,FTP服务器等等。
JMeter可以用来在一个服务器、网络或者对象上模拟重负载来测试它的强度或者分析在不同的负载类型下的全面性能。
另外,JMeter能够通过让你们用断言创建测试脚本来验证我们的应用程序是否返回了我们期望的结果,从而帮助我们回归测试我们的程序。
为了最大的灵活性,JMeter允许我们使用正则表达式创建断言。
1.1 历史Apache软件组织的Stefano Mazzocchi是JMeter的创始人。
他编写它起初是为了测试Apache JServ的性能(一个已经被Apache Tomcat工程所替代的工程)。
我们重新设计JMeter 来增强用户界面并增加功能测试的能力。
1.2 未来我们希望看到作为开发者利用它的可插入架构使JMeter的功能快速扩展。
未来发展的主要目标是在没有影响JMeter的负载测试能力的情况下尽可能使JMeter成为最实用的回归测试工具。
2.入门开始使用JMeter最容易的方法是首先下载最新版并且安装它。
这个版本包含所有你在构建和运行Web,FTP,JDBC,和JNDI等测试时使用需要的所有文件。
如果你想执行JDBC测试,你当然需要从供应商得到适当的JDBC驱动。
JMeter没有提供任何JDBC驱动。
你可能需要下载的其它软件:BeanShell - BeanShell函数和测试元件需要Java Activation Framework - JavaMail需要Java Mail - Mail可视化,Mail Read er 和WebService(SOAP)取样器需要JMS - JMS取样器需要下一步, 开始使用JMeter并且参见用户手册创建一个测试计划一章使自己更加熟悉JMeter基础(例如,添加和删除元件)。
jmeter使用总结
JMeter 是一款开源的性能测试工具,主要用于测试 Web 应用程序的性能和负载能力。
以下是一些使用 JMeter 的总结:
1. 录制脚本:JMeter 可以通过录制浏览器的操作来生成测试脚本,这对于创建复杂的测试用例非常有帮助。
2. 线程组:线程组是 JMeter 测试计划的基本组成部分,用于设置并发用户数和执行测试的时间。
3. Sampler: Sampler 是 JMeter 中执行具体请求的组件,如 HTTP 请求、FTP 请求等。
4. 断言:断言用于验证响应是否符合预期,例如检查响应状态码、验证响应内容等。
5. 监听器:监听器用于收集和展示测试结果,如查看响应时间、吞吐量等。
6. 配置元件:配置元件用于设置请求的一些属性,如 HTTP 请求头、超时时间等。
7. 逻辑控制器:逻辑控制器用于控制 Sampler 的执行顺序和逻辑,如循环控制器、事务控制器等。
8. 远程测试:JMeter 支持远程测试,可以通过远程代理在多台机器上分布负载。
9. 报告生成:JMeter 可以生成各种类型的报告,如 HTML 报告、XML 报告等,以便分析测试结果。
10. 插件扩展:JMeter 支持插件扩展,可以通过安装插件来扩展其功能。
JMeter 是一款功能强大且易于使用的性能测试工具,通过合理使用上述功能,可以帮助你有效地测试和评估 Web 应用程序的性能。
JMeter的使⽤流程JMeter的使⽤流程简介JMeter是⼀款在国外⾮常流⾏和受欢迎的开源性能测试⼯具,像LoadRunner⼀样,它也提供了⼀个利⽤本地Proxy Server(代理服务器)来录制⽣成测试脚本的功能,但是这个功能并不好⽤。
安装:设置语⾔临时设置语⾔Options --》Choose Language——》Chinese (Simplified) 这种重启之后就失效了永久设置成中⽂进⼊meter的bin⽬录,找到“jmeter.properties”⽂件,添加“language=zh_CN”,保存之后再打开jmeter就永久变为中⽂环境了。
主要元件1、测试计划:是使⽤ JMeter 进⾏测试的起点,它是其它 JMeter测试元件的容器2、线程组:代表⼀定数量的⽤户,它可以⽤来模拟⽤户并发发送请求。
实际的请求内容在Sampler中定义,它被线程组包含。
3、配置元件:维护Sampler需要的配置信息,并根据实际的需要修改请求的内容。
4、前置处理器:负责在请求之前⼯作,常⽤来修改请求的设置5、定时器:负责定义请求之间的延迟间隔。
6、取样器(Sampler):是性能测试中向服务器发送请求,记录响应信息、响应时间的最⼩单元,如:HTTP Request Sampler、FTP Request Sample、TCP Request Sample、JDBC Request Sampler等,每⼀种不同类型的sampler 可以根据设置的参数向服务器发出不同类型的请求。
7、后置处理器:负责在请求之后⼯作,常⽤获取返回的值。
8、断⾔:⽤来判断请求响应的结果是否如⽤户所期望的。
9、监听器:负责收集测试结果,同时确定结果显⽰的⽅式。
10、逻辑控制器:可以⾃定义JMeter发送请求的⾏为逻辑,它与Sampler结合使⽤可以模拟复杂的请求序列。
元件的作⽤域和执⾏顺序元件作⽤域配置元件:影响其作⽤范围内的所有元件。
LoadRunner11使⽤代理录制脚本
⼀、背景
电脑安装了LoadRunner11,在进⾏脚本录制时发现录制的脚本为空,即录制时事件为0,也没有⾃动调出对应的浏览器;如下图:
问了度娘,发现LR11要成功录制脚本,对各浏览器的版本有要求!因不想对浏览器做版本回退或者下载重装,发现还有⼀种设置代理录制的⽅式!⼆、代理设置
1、浏览器进⾏代理设置:在代理设置页⾯设置代理端⼝
2、LoadRunner11中设置
在“起始页”点击Web(HTTP/HTML)打开“开始录制”弹窗;
在“开始录制”弹窗页⾯设置要录制的程序为LoadRunner安装⽬录下的bin⽬录下的wplus_init_wsock.exe(即LR的代理服务器),点击“选项”打开“录制选项”弹窗;
在“录制选项”弹窗中选择【⽹络-端⼝映射】,捕获级别选择“套接字级别数据”,点击“新增条⽬”;在“服务器条⽬”窗⼝填写被录制的系统对应的ip+端⼝,“流量转发”处勾选并填写与浏览器相同的代理端⼝,点击“更新”完成设置!
三、验证是否可成功录制
在“开始录制”弹窗中点击“确定”,弹出录制窗⼝和代理服务器启动程序;
(录制窗⼝)
(代理服务器启动程序)注意:不能关闭该提⽰框或者点击“关机”,否则⽆法录制
使⽤代理浏览器完成录制后停⽌录制,即可⽣成录制脚本,脚本中包含各操作事务,即录制成功。
Jmeter学习笔记一、jmeter的配置(已验证)根据jmeter特性,在配置安装前必须进行对JDK的安装配置,另外还得对JDK环境变量配置的有JAVA_HOME、CLASSPATH、PATH;配置步骤如下:验证配置是否成功:点击“菜单”-》运行-》输入cmd 回车-》在DOS 下输入Java或javac或jar。
二、jmeter的二种录制脚本的方法(已验证)第一种方法:B adboy监控internet explorer的活动,提供录制/回放功能.录制功能:badboy窗口的顶部显示当前是否处于录制状态,如果点击play按钮,badboy自动关闭录制功能,等到play结束后,可以点击recording按钮,继续录制脚本.Remark:必须等到上一步的request处理完毕后,才能点击发送下一个request,否则下一个request会作为第一个request的子frame.两种录制脚本模式(只验证过其中一种):Badboy提供两种录制模式:一 request 模式(默认模式) 二 navigation 模式.点击下图N,切换模式。
Request模式具有如下优点:如果测试的网页模版修改了,不影响脚本的回放.如果需要badboy导出脚本到jmeter进行性能测试,必须选择request 模式.同时request模式的缺点如下:request模式需要添加大量的断言来检查页面上的item.Navigation模式将会记录网站交互过程中browser中的元素的点击动作.当回放navigation模式脚本时候,不但回放http request,同时badboy会模拟brower中点击动作.navigation模式的缺点是 :无法使用navigation脚本进行性能测试,因为性能测试引擎运行时候不显示任何用户界面,所以无法执行navigation中模拟点击等动作.总结:选择navigation模式还是request模式,取决于测试的目的,如果仅仅要求测试功能而不关心界面,则request模式无疑为首选(此项是搜集资料中的总结,未对其验证)第二种方法:通过jmeter本身进行录制脚本,其步骤为:创建一个线程组(右键点击“测试计划”--->“添加”---->“线程组”)创建一个http代理服务器(右键点击“工作台”--->“添加”--->“非测试元件”--->“http代理服务器”)(备注:注意端口、IP设置及其参数表达式配置):针对IE浏览器器进行配置:三、jmeter测试时,各中测试的配置(核心)1.参数化:方法一、使用“函数助手”添加从文件中读取字符串的函数。
Jmeter⼊门使⽤JMeter的简单使⽤1.JMeter简介Apache JMeter是Apache组织开发的基于Java的压⼒测试⼯具。
⽤于对软件做压⼒测试,它最初被设计⽤于Web应⽤测试,但后来扩展到其他测试领域。
它可以⽤于测试静态和动态资源,例如静态⽂件、Java ⼩服务程序、CGI 脚本、Java 对象、数据库、FTP 服务器,等等。
JMeter 可以⽤于对服务器、⽹络或对象模拟巨⼤的负载,来⾃不同压⼒类别下测试它们的强度和分析整体性能。
另外,JMeter能够对应⽤程序做功能/回归测试,通过创建带有断⾔的脚本来验证你的程序返回了你期望的结果。
为了最⼤限度的灵活性,JMeter允许使⽤正则表达式创建断⾔。
2.安装与配置2.1. ⼯具/原料●JDK 1.7●Apache JMeter 3.02.2. 环境JMeter可以在Windows/Linux/Mac平台上运⾏,这⾥介绍在Windows 上的安装配置。
2.3. 安装步骤●安装JDK,⽹上下载⼀个JDK,配置好环境变量即可使⽤。
在dos界⾯输⼊java -version,能显⽰版本号,则证明JDK安装OK,可以使⽤。
●安装Jmeter:Jmeter不需要安装,解压之后即可使⽤;双击Jmeter的bin⽬录下的jmeter.bat,出现下⾯界⾯,则Jmeter启动成功,Jmeter就绪。
3.HTTP接⼝测试3.1. 测试实例以⼀个简单的接⼝为例:/doc/983e39af541810a6f524ccbff121dd36a32dc427.html /get?key2=value2&key1=value1在浏览器中打开的效果如下:在这⾥,成功的⽤浏览器访问了这个接⼝,并得到了成功的返回报⽂。
下⾯我们⽤Jmeter 来访问这个接⼝。
3.2. 使⽤Jmeter进程HTTP测试3.2.1.添加线程组右键“测试计划”->“添加”->“Threads(Users)”->“线程组”3.2.2.添加“HTTP请求”●右键“线程组”->“添加”->“Sampler”->“HTTP请求”●打开之后,填⼊访问该接⼝所需要的参数,效果如下图Tips:1.服务器名或IP:这⾥填写服务IP地址(不带端⼝),有域名的直接填写域名2.端⼝号:这⾥填写端⼝号,有域名的这⾥为空就好。
jmeter压⼒测试的简单实例+badboy脚本录制 JMeter的安装:在⽹上下载,在下载后的zip解压后,在bin⽬录下找到JMeter.bat⽂件,双击就可以运⾏JMeter.在使⽤jmeter前要先下载jdk包,配置java环境。
(参见Java环境配置教程)配置完成后在运⾏窗⼝检查⼀下java -version确定java环境配置完成。
⼀、(1)利⽤badboy进⾏⾃动脚本录制下载BadboyInstaller-2.2.5.exe 并安装完成后打开界⾯在地址栏输⼊⽹址后,点击录制按钮。
录制步骤为:⾸页->登录->输⼊⽤户名和密码->点击登录按钮->⾸页完成录制后将⽂档保存为:export to jmeter,⽣成⼀个.jmx⽂件。
(2)利⽤代理服务器录制badboy内嵌的浏览器是ie8,部分新的⽹站已经不做ie8的适配,这类⽹页可以⽤代理服务器录制。
创建⼀个线程,⽤来存放录制的脚本在⼯作台添加:⾮测试元件->HTTP代理服务器,设置代理服务器的端⼝号(⼀般设置为8080)在浏览器中为本机设置代理,注意设置的端⼝号与代理服务器中设置的端⼝号⼀致在HTTP代理中设置⽬标控制器,选择测试计划>线程组,点击启动。
⼆、利⽤jmeter进⾏压⼒测试在jmeter中打开刚才通过badboy保存的.jmx⽂件留下需要测试的内容,把⼀些录制过程中多余内容删除。
设置线程组和监听器:线程组:设置线程组的三个参数的定义分别为:线程数,Ramg-up Period(in seconds)(间隔时间),循环次数断⾔:设置响应断⾔,⽤来检查重要的节点处响应结果是否正确。
设置响应断⾔:(这⾥⽰例的响应断⾔是检查登录后的页⾯是否有⽤户登录的信息标识“usr-name”)查看断⾔结果:监听器:显⽰取样器结果的组件。
为了观察来⾃提供的取样器的响应内容,可以添加“观察结果树”监听器,为了图形化观察响应时间,可以添加“图形结果”,查看完整的测试结果和通过率,可以添加“聚合报告”。
HTTP RequestThis sampler lets you send an HTTP/HTTPS request to a web server. It also lets you control whether or not JMeter parses HTML files for images and other embedded resources and sends HTTP requests to retrieve them. The following types of embedded resource are retrieved:∙images∙applets∙stylesheets∙external scripts∙frames, iframes∙background images (body, table, TD, TR)∙background soundThe default parser is htmlparser. This can be changed by using the property "htmlparser.classname" - see jmeter.properties for details.If you are going to send multiple requests to the same web server, consider using an HTTP Request Defaults Configuration Element so you do not have to enter the same information for each HTTP Request.Or, instead of manually adding HTTP Requests, you may want to use JMeter's HTTP(S) Test Script Recorder to create them. This can save you time if you have a lot of HTTP requests or requests with many parameters.There are two different screens for defining the samplers:∙AJP/1.3 Sampler - uses the Tomcat mod_jk protocol (allows testing of Tomcat in AJP mode without needing Apache httpd) The AJP Sampler does not support multiple file upload; only the first file will be used.∙HTTP Request - this has an implementation drop-down box, which selects the HTTP protocol implementation to be used:o Java - uses the HTTP implementation provided by the JVM. This has some limitations in comparison with the HttpClient implementations - see below.o HTTPClient3.1 - uses Apache Commons HttpClient 3.1. This is no longer being developed, and support for this may be dropped in a future JMeter release.o HTTPClient4 - uses Apache HttpComponents HttpClient 4.x.o Blank Value - does not set implementation on HTTP Samplers, so relies on HTTP Request Defaults if present or on jmeter.httpsampler property defined injmeter.propertiesThe Java HTTP implementation has some limitations:∙There is no control over how connections are re-used. When a connection is released by JMeter, it may or may not be re-used by the same thread.∙The API is best suited to single-threaded usage - various settings are defined via system properties, and therefore apply to all connections.∙There is a bug in the handling of HTTPS via a Proxy (the CONNECT is not handled correctly). See Java bugs 6226610 and 6208335.∙It does not support virtual hosts.∙It does not support the following methods: COPY, LOCK, MKCOL, MOVE, PA TCH, PROPFIND, PROPPA TCH, UNLOCK.∙It does not support client based certificate testing with Keystore Config.Note: the FILE protocol is intended for testing purposes only. It is handled by the same code regardless of which HTTP Sampler is used.If the request requires server or proxy login authorization (i.e. where a browser would create a pop-up dialog box), you will also have to add an HTTP Authorization Manager Configuration Element. For normal logins (i.e. where the user enters login information in a form), you will need to work out what the form submit button does, and create an HTTP request with the appropriate method (usually POST) and the appropriate parameters from the form definition. If the page uses HTTP, you can use the JMeter Proxy to capture the login sequence.In versions of JMeter up to 2.2, only a single SSL context was used for all threads and samplers. This did not generate the proper load for multiple users. A separate SSL context is now used for each thread. To revert to the original behaviour, set the JMeter property:https.sessioncontext.shared=trueBy default, the SSL context is retained for the duration of the test. In versions of JMeter from 2.5.1, the SSL session can be optionally reset for each test iteration. To enable this, set the JMeter property:e.cached.ssl.context=falseNote: this does not apply to the Java HTTP implementation.JMeter defaults to the SSL protocol level TLS. If the server needs a different level, e.g. SSLv3, change the JMeter property, for example:https.default.protocol=SSLv3JMeter also allows one to enable additional protocols, by changing the property https.socket.protocols .If the request uses cookies, then you will also need an HTTP Cookie Manager . You can add either of these elements to the Thread Group or the HTTP Request. If you have more than one HTTP Request that needs authorizations or cookies, then add the elements to the Thread Group. That way, all HTTP Request controllers will share the same Authorization Manager and Cookie Manager elements.If the request uses a technique called "URL Rewriting" to maintain sessions, then see section 6.1 Handling User Sessions With URL Rewriting for additional configuration steps.Control PanelParametersAttribute Description RequiredName Descriptive name for this sampler that is shown in the tree.NoServer Domain name or IP address of the web server.e.g. . [Do not include thehttp:// prefix.] Note: in JMeter 2.5 (andlater) if the "Host" header is defined inYes,unlessprovidedby HTTPa Header Manager, then this will be used as the virtual host name. RequestDefaultsPortPort the web server is listening to. Default: 80 No Connect Timeout Connection Timeout. Number of milliseconds to wait for a connection to open.No Response Timeout Response Timeout. Number of millisecondsto wait for a response. Note that thisapplies to each wait for a response. If theserver response is sent in several chunks, the overall elapsed time may be longer thanthe timeout. A Duration Assertion can beused to detect responses that take too longto complete.No Server (proxy) Hostname or IP address of a proxy server to perform request. [Do not include the http:// prefix.]NoPort Port the proxy server is listening to. No,unlessproxyhostnameisspecifiedUsername (Optional) username for proxy server. NoPassword (Optional) password for proxy server.(N.B. this is stored unencrypted in the test plan)NoImplementation Java, HttpClient3.1, HttpClient4. If notspecified (and not defined by HTTP RequestDefaults), the default depends on the value of the JMeter propertyjmeter.httpsampler , failing that, theHttpClient4 implementation is used.No Protocol HTTP, HTTPS or FILE. Default: HTTP NoMethodGET, POST, HEAD, TRACE, OPTIONS, PUT,DELETE, PATCH (not supported for JAVAimplementation). With HttpClient4, the following methods related to WebDav arealso allowed: COPY, LOCK, MKCOL, MOVE, YesPROPFIND, PROPPATCH, UNLOCK.Content Encoding Content encoding to be used (for POST, PUT, PATCH and FILE). This the the character encoding to be used, and is not related to the Content-Encoding HTTP header.NoRedirect Automatically Sets the underlying http protocol handlerto automatically follow redirects, so they are not seen by JMeter, and thus will not appear as samples. Should only be used for GET and HEAD requests. The HttpClient sampler will reject attempts to use it for POST or PUT. Warning: see below for information on cookie and header handling.NoFollow Redirects This only has any effect if "Redirect Automatically" is not enabled. If set, the JMeter sampler will check if the responseis a redirect and follow it if so. The initial redirect and further responseswill appear as additional samples. The URL and data fields of the parent sample willbe taken from the final (non-redirected) sample, but the parent byte count and elapsed time include all samples. The latency is taken from the initial response (versions of JMeter after 2.3.4 - previously it was zero). Note that the HttpClient sampler may log the following message:"Redirect requested but followRedirects is disabled"This can be ignored.In versions after 2.3.4, JMeter will collapse paths of the form '/../segment' in both absolute and relative redirect URLs. For example http://host/one/../two =>http://host/two. If necessary, this behaviour can be suppressed by setting the JMeter propertyhttpsampler.redirect.removeslashdotdot=f alseNoUse KeepAlive JMeter sets the Connection: keep-alive header. This does not work properly withNothe default HTTP implementation, as connection re-use is not underuser-control. It does work with the Apache HttpComponents HttpClient implementations.Usemultipart/form-da ta for HTTP POST Use a multipart/form-data orapplication/x-www-form-urlencoded post requestNoBrowser-compatibl e headers When using multipart/form-data, this suppresses the Content-Type andContent-Transfer-Encoding headers; onlythe Content-Disposition header is sent.NoPath The path to resource (for example,/servlets/myServlet). If the resource requires query string parameters, add them below in the "Send Parameters With the Request" section. As a special case, if the path starts with "http://" or "https://" then this is used as the full URL. In this case, the server, port and protocol fieldsare ignored; parameters are also ignoredfor GET and DELETE methods. Also pleasenote that the path is not encoded - apart from replacing spaces with %20 - so unsafe characters may need to be encoded to avoid errors such as URISyntaxException.YesSend Parameters With the Request The query string will be generated from the list of parameters you provide. Each parameter has a name and value , the optionsto encode the parameter, and an option to include or exclude an equals sign (some applications don't expect an equals when the value is the empty string). The query string will be generated in the correct fashion, depending on the choice of "Method" you made (ie if you chose GET or DELETE, the query string will be appendedto the URL, if POST or PUT, then it will be sent separately). Also, if you are sendinga file using a multipart form, the query string will be created using the multipart form specifications. See below for someNofurther information on parameter handling.Additionally, you can specify whether each parameter should be URL encoded. If you are not sure what this means, it is probably best to select it. If your values contain characters such as the following then encoding is usually required.: ∙ASCII Control Chars∙Non-ASCII characters∙Reserved characters:URLs use some characters for special use in defining their syntax. Whenthese characters are not used in their special roleinside a URL, they need to be encoded,example : '$', '&', '+', ',' , '/', ':', ';', '=', '?', '@' ∙Unsafe characters: Some characters present the possibility of being misunderstood within URLsfor various reasons. These characters shouldalso always be encoded, example : ' ', '', '>', '#','%', ...File Path: Name of the file to send. If left blank, JMeter does not send a file, if filled in, JMeter automatically sends the request asa multipart form request.If it is a POST or PUT or PATCH request andthere is a single file whose 'Parameter name' attribute (below) is omitted, then the file is sent as the entire body of the request, i.e. no wrappers are added. This allows arbitrary bodies to be sent.This functionality is present for POST requestsafter version 2.2, and also for PUT requests after version 2.3. See below for some further information on parameter handling.NoParameter name: Value of the "name" web request parameter. NoMIME Type MIME type (for example, text/plain). If itis a POST or PUT or PATCH request and either the 'name' attribute (below) are omitted or the request body is constructed from parameter values only, then the value of this field is used as the value of theNocontent-type request header.Retrieve AllEmbeddedResources fromHTML FilesTell JMeter to parse the HTML file and send HTTP/HTTPS requests for all images, Java applets, JavaScript files, CSSs, etc. referenced in the file. See below for more details. No Use as monitor For use with the Monitor Results listener. NoSave response as MD5 hash? If this is selected, then the response isnot stored in the sample result. Instead, the 32 character MD5 hash of the data is calculated and stored instead. This isintended for testing large amounts of data.No Embedded URLs must match: If present, this must be a regularexpression that is used to match againstany embedded URLs found. So if you only want to download embedded resources from/, use the expression:http://example\.com/.*No Use concurrentpoolUse a pool of concurrent connections to get embedded resources. No Size Pool size for concurrent connections used to get embedded resources.No Source addresstype [Only for HTTP Request with HTTPClientimplementation]To distinguish the source address value,select the type of these:∙Select IP/Hostname to use a specific IP address or a (local) hostname ∙Select Device to pick the first available address for that interface which this may be either IPv4 or IPv6 ∙Select Device IPv4 To select the IPv4 address of the device name (like eth0, lo, em0, etc.) ∙ Select Device IPv6 To select the IPv6 address ofthe device name (like eth0, lo, em0, etc.)No Source addressfield [Only for HTTP Request with HTTPClient implementation] This property is used to enable IPSpoofing. It override the default local IPNoaddress for this sample. The JMeter hostmust have multiple IP addresses (i.e. IPaliases, network interfaces, devices). Thevalue can be a host name, IP address, or anetwork interface device such as "eth0" or"lo" or "wlan0".If the property httpclient.localaddress isdefined, that is used for all HttpClientrequests.N.B. when using Automatic Redirection, cookies are only sent for the initial URL. This can cause unexpected behaviour for web-sites that redirect to a local server.E.g. if redirects to . In this case the server will probably return cookies for both URLs, but JMeter will only see the cookies for the last host, i.e. . If the next request in the test plan uses , rather than , it will not get the correct cookies. Likewise, Headers are sent for the initial request, and won't be sent for the redirect. This is generally only a problem for manually created test plans, as a test plan created using a recorder would continue from the redirected URL.Parameter Handling:For the POST and PUT method, if there is no file to send, and the name(s) of the parameter(s) are omitted, then the body is created by concatenating all the value(s)of the parameters. Note that the values are concatenated without adding anyend-of-line characters. These can be added by using the __char() function in the value fields. This allows arbitrary bodies to be sent. The values are encoded if the encoding flag is set (versions of JMeter after 2.3). See also the MIME Type above how you can control the content-type request header that is sent.For other methods, if the name of the parameter is missing, then the parameter is ignored. This allows the use of optional parameters defined by variables. (versions of JMeter after 2.3)Since JMeter 2.6, you have the option to switch to Post Body when a request has only unnamed parameters (or no parameters at all). This option is useful in the following cases (amongst others):∙GWT RPC HTTP Request∙JSON REST HTTP Request∙XML REST HTTP Request∙SOAP HTTP RequestNote that once you leave the Tree node, you cannot switch back to theparameter tab unless you clear the Post Body tab of data.In Post Body mode, each line will be sent with CRLF appended, apart from the last line. To send a CRLF after the last line of data, just ensure that there is an empty line following it. (This cannot be seen, except by noting whether the cursor can be placed on the subsequent line.)Figure 1 - HTTP Request with one unnamed parameterFigure 2 - Confirm dialog to switchFigure 3 - HTTP Request using Body DataMethod Handling:The POST, PUT and PATCH request methods work similarly, except that the PUT and PATCH methods do not support multipart requests or file upload. The PUT and PATCH method body must be provided as one of the following:∙define the body as a file with empty Parameter name field; in which case the MIME Type is used as the Content-Type∙define the body as parameter value(s) with no name∙use the Post Body tabIf you define any parameters with a name in either the sampler or Http defaults then nothing is sent. PUT and PATCH require a Content-Type. If not using a file, attach a Header Manager to the sampler and define the Content-Type there. The GET and DELETE request methods work similarly to each other.Upto and including JMeter 2.1.1, only responses with the content-type "text/html" were scanned for embedded resources. Other content-types were assumed to be something other than HTML. JMeter 2.1.2 introduces the a new property HTTPResponse.parsers , which is a list of parser ids, e.g. htmlParser andwmlParser . For each id found, JMeter checks two further properties:∙id.types - a list of content types∙id.className - the parser to be used to extract the embedded resourcesSee jmeter.properties file for the details of the settings. If the HTTPResponse.parser property is not set, JMeter reverts to the previous behaviour, i.e. only text/html responses will be scannedEmulating slow connections:# Define characters per second > 0 to emulate slow connections#httpclient.socket.http.cps=0#httpclient.socket.https.cps=0Response size calculationOptional properties to allow change the method to get response size:∙Gets the real network size in bytes for the body responsesampleresult.getbytes.body_real_size=true∙∙Add HTTP headers to full response sizesampleresult.getbytes.headers_size=true∙The Java and HttpClient3inplementations do not includetransport overhead such as chunkheaders in the response body size.The HttpClient4 implementationdoes include the overhead in theresponse body size, so the value maybe greater than the number of bytesin the response content.Versions of JMeter before 2.5returns only data response size(uncompressed if request usesgzip/defate mode).To return to settings beforeversion 2.5, set the two propertiesto false.Retry handlingIn version 2.5 of JMeter, the HttpClient4 and Commons HttpClient 3.1 samplers used the default retry count, which was 3. In later versions, the retry count has been set to 1, which is what the Java implementation appears to do. The retry count can be overridden by setting the relevant JMeter property, for example:httpclient4.retrycount=3httpclient3.retrycount=3Note: Certificates does not conform to algorithm constraintsYou may encounter the following error: java.security.cert.CertificateException: Certificates does not conform to algorithm constraints if you run a HTTPS request on a web site with a SSL certificate (itself or one of SSL certificates in its chain of trust) with a signature algorithm using MD2 (like md2WithRSAEncryption) or with a SSL certificate with a size lower than 1024 bits.This error is related to increased security in Java 7 version u16 (MD2) and version u40 (Certificate size lower than 1024 bits), and Java 8 too.To allow you to perform your HTTPS request, you can downgrade the security of your Java installation by editing the Java jdk.certpath.disabledAlgorithms property. Remove the MD2 value or the constraint on size, depending on your case.This property is in this file:JAVA_HOME/jre/lib/security/java.securitySee Bug 56357 for details.See Also:∙Assertion∙Building a Web Test Plan∙Building an Advanced Web Test Plan∙HTTP Authorization Manager∙HTTP Cookie Manager∙HTTP Header Manager∙HTML Link Parser∙HTTP(S) Test Script Recorder∙HTTP Request DefaultsHTTP Requests and Session ID's: URL Rewriting。
Apache JMeter配置步骤压力测试实例一. 安装环境: (2)二.安装步骤: (2)三.实例环境: (2)四.测试步骤 (3)4.1 脚本录制 (3)五.测试验证脚本 (11)六.开始测试 (14)6.1 添加报表 (14)6.2 编辑测试压力数据 (15)6.3 查看报表 (16)一.安装环境:JMeter在Window XP / 2003 / W7 /W8基本都可以运行,前提是要安装好JDK包,JMeter 是基于JAVA开发的压力测试软件。
该次配置实例是在W8-64位系统中完成。
安装包:Apache Jmeter 2.10 至2013年11月5日时为最新版本JDK版本jdk-7u45-windows-x64 (下载的时候注意自己系统版本)下载地址:Jmeter 2.10:/download_jmeter.cgiJDK:/technetwork/java/javase/downloads/jdk7-downloads-1880260.html 二.安装步骤:安装步骤不做介绍,JDK安装下一步,下一步就OK。
JMeter不需要安装,压力包解压出来即可使用。
三.实例环境:压力测试目标:ECSHOP商场压力测试目的:测试ECHSOP商场300人同时登陆查看评论时,服务器压力压力测试脚本设计:1.打开ECSHOP登陆页面2.输入账户密码登陆ECSHOP3.进入用户中心4.查看评论5.退出ECSHOP管理平台压力测试预期效果:自己的测试环境,压力测试效果就不做讲解,只对配置步骤讲解。
四.测试步骤4.1 脚本录制脚本录制,JMeter启用WEB代理,浏览器把代理上网设置为JMeter所在的IP地址,自己电脑就是127.0.0.1代理端口默认8080。
至于浏览器修改代理上网服务器,不做截图。
Jmeter 运行在目录\apache-jmeter-2.10\bin 下jmeter.dat文件,双击打开进入Jmeter界面Jmeter界面建立测试计划,录制阶段不需要更改任何配置。
如何利用JMeter来录制性能测试的脚本JMeter是一款非常流行的开源的性能测试工具,是否可以通过它来录制测试场景呢?答案是肯定的,本文档就是详细的告诉大家该如何做呢。
本文包含以下几个部分:•录制器的设置•HTTPS配置•设置代理•录制脚本1.录制器的设置我们会利用Jmeter’s HTTP(s) Test Script Recorder来录制脚本首先启动JMeter (注:作者的机器是Mac,所有的截图或者命令都是基于Mac的,且基于JMeter 5.3介绍,如果读者是Windows的机器,请根据实际情况更改路径或者命令)然后点击菜单File->Template,在打开的Templates对话框中选择Recording,然后点击Create弹出一个填写参数的对话框,这个对话框中的内容可以修改或者暂时不修改,稍后再创建出的测试计划中修改也是可以的,然后点击Create此时JMeter为我们创建了测试计划,其中包含了用来录制HTTP/HTTPs的必要的一些组件先忽略其他的组件,直接看一下Thread Group,这个创建好的Tread Group中包含了一个Recording Controller,在录制的时候,这里就会包含通过JMeter Proxy录制请求。
在录制的时候可以做一些配置,就是通过HTTP(S) Test Script Recorder来进行配置2.HTTPs配置相对于HTTP,录制HTTPs的请求需要额外的配置2.1首先在刚刚创建的Test Plan中点击HTTPs Test Script Recorder,点击右边的Start按钮。
在打开的对话框中提示让安装CA Root Certificate,这个证书必须安装在浏览器中以支持HTTPs的请求的录制。
JMeter在<JMETER_HOME>/bin folder中会生成这个证书 - ApacheJMeterTemporaryRootCA.crt默认的证书有效期只有7天,这个很不方便,我们可以把时间修改长一点。
Jmeter使用http proxy方式录制
2.3.2.使用http proxy方式录制
第一步:启动Jmeter
第二步:右键点击测试计划(Test Plan)添加Threads-Threads Group(线程组)
第三步、右键点击工作台、添加-非测试元件-HTTP代理服务器(HTTP Proxy Server)
第四步、设置http代理服务器
名称:代理服务器的名字,默认即可。
端口:代理服务器的端口,默认是8080,如果被占用,可以换一个未被使用的端口
在命令提示符里面输入netstat–an可以查看本机当前被使用的端口。
Attempt HTTPS Spoofing:启用HTTPS欺骗,所有符合过滤规则的http请求都会被转为https 请求。
Only spoof URLs matching:采用正则表达式表示。
比如要过滤http://a.b/image而不希望过滤http://a.b/server,这里则填写http://a.b/server/.*。
目标控制器:录制的脚本存放的位置,这里选择之前创建好的线程组
分组:对于录制的samplers是否分组,怎么控制分组
记录HTTP信息头:是否自动记录并生成http header信息。
添加断言:是否添加空白的断言步骤
REgex matching:替换变量的时候是否使用正则表达式
Http sampler settings:指定http sampler的设置
Type:指定Http sampler的类型,默认是java的,可以选择httpclient4(httpclient3.1基本不使用了。
)
自动重定向:是否启用自动重定向,当发生重定向的时候,不会生成脚本。
一般java类型的http请求只有get和head方法才使用自动重定向,而在httpclient类型中,post和put 方法也可以使用自动重定向
跟随重定向:是否启用跟随重定向,是指发生重定向时,会生成sampler请求,即生成脚本。
UseKeepAlive:在头文件里面添加KeepAlive属性。
从HTML文件中获取所有内含的资源:获取除了html页面外所有内含的资源,包括图片等。
一般不勾选
Content-type filter:对Content-type进行过滤,选择要被录制到的Content-type。
类似于Loadrunner的Recording-option里的Non-Resource选项的设置。
这里有两种过滤方式,一种
是包含,一种是不包含。
多个类型之间使用逗号分隔。
比如只想录制到text/html和text/xml格式的content,则在include里面输入“text/html,text/xml”。
包含模式:这里则是对于录制的请求的过滤,采用正则表达式的规则进行过滤,也分包含和不包含两种模式。
启动:启动http 代理服务。
停止:停止http代理服务。
重启:重启http代理服务。
设置好之后,点击启动按钮即可。
第五步、打开IE浏览器,进入工具-Internet选项-连接-局域网设置,如图所示
选中代理服务器的为LAN使用代理服务器。
配置地址为localhost或者127.0.0.1,端口为8080(这个端口请与Jmeter中http proxy server 设置的端口保持一致),然后点击确定按钮。
这样在浏览器中间输入地址进行相应的操作,就会在Jmeter中自动生成脚本。
注意
1、录制完脚本后点击停止http proxy server
2、停止http proxy server后请将IE选项中的代理服务器取消。