Performance testing -Loadrunner, Jmeter performance testing concepts Detailed performance + + program code for recording (to be improved)

Loadrunner和Jmeter:

  1. Loadrunner, community version, a machine able to open up to 50 concurrent. Four machines is 200, four machines were manually set the operating parameters LR, after the implementation of the results were then aggregated statistics run together. Toll free version is very expensive, according to different protocols, concurrent to charge.
  2. Jmeter, open source, programming support, but otherwise Loadrunner support completely. Is lightweight, and eighty Shizhao in mac download java environment can do performance testing.

Performance Testing:

  1. Performance testing: under different load conditions, see the performance of the test system.
  2. Front-end performance: app performance (GT, Emmagee).
  3. Back-end performance: interfaces and services.

Performance:

  1. TPS and draw Response time: How many concurrent? How fast? correct? Three cases takes up much resources.

Performance testing of the whole process:

  1. 1

Utmost performance testing:

  1. The most extreme case of concurrent access to analog most likely to occur.

Loadrunner tool in three parts:

  1. virtualuser generator: Virtual User Generator: recording a script, the script debugging, in-line operation.
  2. controller: setting performance test scenarios to run multi-threaded (multi-process) concurrent, concurrent testing.
  3. analysys: Results of the analysis of the performance test execution, the chart can report.
  4. Supplementary: ipspoofer: ip spoofing, do all IP network traversal, the network is generally a few hundred IP, LR run, then usually about one minute and ran over, lacks significance, so in order to test a large IP, need to be developed to limit Turn off IP performance test to do. But this situation does not correspond to the real situation, should be considered.

Detailed concept:

  1. Start -HP Software-Start HP Web tours Server , equivalent to start the service, and then open http://127.0.0.1:1080/WebTours/index.htm  tool comes with the website, open the page click on the administration, when the association needs to do select the third Set LOGIN form's action tag to an error page.
  2. Association: the dynamic data into the variable will be used in subsequent tests. For example, after login, the system returns a token (string), access to all subsequent pages will be with this token. Recorded script to get the token, but all historical values ​​before, during performance tests and can not be reused, so the association needs to be done.
  3. Parameterization: Avoid a large number of requests are cache hits.

Create a recording script:

  1. Start virtualuser generator, File-new Script and solution-WebHttpHtml, created in the C: recording a script file \ under Users \ Sun \ Documents \ VuGen \ Scripts path.
  2. Script structure:
    1. vuser_init: function,
      performed once in a thread up to
      a preparation for data and other operations, performed before the action
    2. action: function, one thread can execute multiple 1-
    3. vuser_end: a function of performing up to thread 1 in
      a clean-up operation for data
      is performed after the action.
  3. Click the record icon to record, select the browser, recording mode and recording URL
  4. Registered in the implementation of the page operation, while LR automatically starts recording, and click the button to end after the end of registration, LR generated script recording, open the action can be seen after: the corresponding other user information collection script can be deleted. Below are the highlights script parsing,
    1.     web_url ( "index.htm", // request the name of
              "URL = http: //127.0.0.1: 1080 / WebTours / index.htm", // The requested URL
              "Resource = 0", // whether the resources, 0 is not a resource page 1 resource: documents, images, JS, CSS
              "RecContentType = text / HTML", // contentType, request type is page type
              "Referer =", // when this page is requested from what URL access to information
              "Snapshot = t2.inf", // screenshot file name
              "mode = HTML", // recording mode HTML, as well as modes is a URL, if there is ajax, flash, etc. will all have to use url.url http requests are recorded
              EXTRARES, // Here are all the resource file, "Url = http: //www.duba.com/hotwords.json" , "Referer =", ENDITEM, these are static resource files, if just want to test dynamic data, you can delete the following line, if want to dynamic and static testing is not necessary to empty the
              "Url = http: //www.duba.com/hotwords.json", "Referer =", ENDITEM
              LAST);
    2.     web_submit_data ( "login.pl_2", 
              "the Action = HTTP: //127.0.0.1: 1080 / CGI-bin / login.pl", // process the data submission URL
              "Method = POST", // HTTP protocol type
              "RecContentType = text / html", // resource type submitted, contentType
              "Referer = HTTP: //127.0.0.1:? 1080 / cgi-bin / login.pl username & password = = = & getInfo to true", from which // URL jump over the
              "Snapshot = t12.inf", 
              "Mode = HTML", 
              the ItemData, // the following these can also be written manually, access to relevant information by Ethereal
              "Name = username", "Value = changjinling" , ENDITEM, 
              "password = the Name", "the Value PasswordParameter = {}", ENDITEM, 
              "passwordConfirm the Name =", "the Value = 123456", ENDITEM, 
              " Name=firstName", "Value=chang", ENDITEM, 
              "Name=lastName", "Value=jinling", ENDITEM, 
              "The Name = address1", "Value = beijing", ENDITEM, 
              "the Name = address2", "Value = tongzhou", ENDITEM, 
              "the Name = register.x", "Value = 60", ENDITEM, // not on the UI page fields can see, it is implicit field, based on security considerations, such as the submission is valid How long do.
              "Name = register.y", "Value = 9", ENDITEM, // implicit field
              LAST);
    3. All registered script: Action ()
      {

          web_add_auto_header ( "DNT", 
              "1");

          web_url ( "index.htm", // request the name of
              "URL = http: //127.0.0.1: 1080 / WebTours / index.htm ", // URL requests
              " resource = 0 ", // whether the resource is 0, not a resource, a web, 1:? resource: file: pictures, JS, CSS ..
              " RecContentType = text / HTML "/ / contentType: request type: page type
              "Referer =", // access information from which URL to the
              "Snapshot = t1.inf", // name of the screenshot file
              "mode = HTML", // recording mode: html, url If there is ajax \ flash \:. You must use url: http request will record all down.
              EXTRARES, // resource file
              "url = .. / favicon.ico",  "Referer =", ENDITEM, 
              "Url=http://s.pc.qq.com/navigate/adc/adc_loader.js?v=20160326171611", ENDITEM, 
              "Url=http://s.pc.qq.com/navigate/adc/v4/engine_loader_v3.js", ENDITEM, 
              "Url=http://s.pc.qq.com/navigate/adc/jquery.min.js?ver=3", ENDITEM, 
              "Url=http://s.pc.qq.com/navigate/adc/velocity.js", ENDITEM, 
              LAST);

          web_set_sockets_option("SSL_VERSION", "2&3");



          web_url("login.pl", 
              "URL=http://127.0.0.1:1080/WebTours/login.pl?username=&password=&getInfo=true", 
              "Resource=0", 
              "RecContentType=text/html", 
              "Referer=http://127.0.0.1:1080/WebTours/home.html", 
              "Snapshot=t3.inf", 
              "Mode=HTML", 
              LAST);

          web_add_cookie("SRCHD=AF=NOFORM; DOMAIN=iecvlist.microsoft.com");

          web_add_cookie("SRCHUID=V=2&GUID=213C7604B2E646778D68C0E2C5F9563A&dmnchg=1; DOMAIN=iecvlist.microsoft.com");

          web_add_cookie("SRCHUSR=DOB=20190119; DOMAIN=iecvlist.microsoft.com");

          web_add_cookie("MC1=GUID=1cc40e7eeb084d58a1a4aab5a0176a31&HASH=1cc4&LV=201903&V=4&LU=1553846123710; DOMAIN=iecvlist.microsoft.com");

          web_add_cookie("MUID=30550888172C666B26C505A6132C607F; DOMAIN=iecvlist.microsoft.com");

          web_add_auto_header("UA-CPU", 
              "AMD64");

          

          web_revert_auto_header("UA-CPU");

          web_submit_data("login.pl_2", 
              "Action=http://127.0.0.1:1080/WebTours/login.pl",    //数据提交后的处理网址
              "Method = POST ", // http protocol type
              resource type, contenttype" RecContentType = text / html ",
              "Referer=http://127.0.0.1:1080/WebTours/login.pl?username=&password=&getInfo=true", 
              "Snapshot=t6.inf", 
              "Mode=HTML", 
              ITEMDATA, 
              "Name=username", "Value=tianchuan", ENDITEM, 
              "Name=password", "Value=tianchuan", ENDITEM, 
              "Name=passwordConfirm", "Value=tianchuan", ENDITEM, 
              "Name=firstName", "Value=tianchuan", ENDITEM, 
              "Name=lastName", "Value=tianchuan", ENDITEM, 
              "Name=address1", "Value=tianchuan", ENDITEM, 
              "Name=address2", "Value=tianchuan", ENDITEM, 
              "Name=register.x", "Value=57", ENDITEM, 
              "Name=register.y", "Value=13", ENDITEM, 
              LAST);

          return 0;
      }
    4. By script playback, then a user name and password to repeat the registration is not successful, although http returned 200, but in fact no registration is successful, that is, the business is not successful. In web_submit_data ( "login.pl_2", before adding a line to assert code is not saved if the registration is successful, otherwise an error // assert the front onto the request, if successful, the page will Thank you such words
          web_reg_find ( " text = Thank you, ", LAST ) If the registration is successful in the implementation of the log can see the prompt:. Action.c (220): registered web_reg_find successful for" text = Thank you, "(count = 1) [MsgId: MMSG . -26 364] If the registration fails in the execution log can be seen Tip: Action.c (220): Error -26366 : "Text = Thank you," not found for web_reg_find [MsgId: MERR-26366].
    5. Parameterization, the user name can be made by the random number, the file can also be used, to make the digital portion of the random number, right-2, with reference to FIG.
      1. 想看到脚本执行的参数是多少,可以设置以下,再执行,就可以在log中看到参数的实际的值了。  Action.c(220): Notify: Parameter Substitution: parameter "randomnumber" =  "76064"
        Action.c(220): Notify: Parameter Substitution: parameter "PasswordParameter" =  "123456"
      2. 想看到执行时网页的操作页面,通过设置Tools-options-Scripting-replay-show run-time viewer during replay。
      3. 通过文件做参数化如图设置,这里要注意以下Select next row的内容的选择,如果选择了Unique,小截图中的参数才能可用可选,具体含义如下:
      4. 设置action一共跑几次可用通过
      5. 如果想要分析问题,想得到更多的log,可以在log中选中,然后回放的时候就可以在日志中看到更多的服务返回的信息。
    6. 录登录的脚本。
    7. 自动关联,必须有两个页面有相同的内容才能关联,在Design-Design Studio中选中后点击Correlation。这样在脚本中就会自动添加如下代码:                                                                                                               /*Correlation comment - Do not change!  Original value='126029.393681652zticzDzpQDHfDiiQfpicVzcf' Name ='userSession' Type ='ResponseBased'*/
          web_reg_save_param_regexp(
              "ParamName=userSession",
              "RegExp=name=\"userSession\"\\ value=\"(.*?)\"/>\\\n<table\\ border",
              SEARCH_FILTERS,
              "Scope=Body",
              "IgnoreRedirections=No",
              "RequestUrl=*/nav.pl*",
              LAST);    这样的话,原脚本就会被自动的将userSession的值变为关联后                       web_submit_data("login.pl",
              "Action=http://127.0.0.1:1080/cgi-bin/login.pl",
              "Method=POST",
              "RecContentType=text/html",
              "Referer=http://127.0.0.1:1080/cgi-bin/nav.pl?in=home",
              "Snapshot=t33.inf",
              "Mode=HTML",
              ITEMDATA,
              "Name=userSession", "Value={userSession}", ENDITEM,
              "Name=username", "Value=changjinling", ENDITEM,
              "Name=password", "Value={PasswordParameter}", ENDITEM,
              "Name=JSFormSubmit", "Value=off", ENDITEM,
              "Name=login.x", "Value=32", ENDITEM,
              "Name=login.y", "Value=9", ENDITEM,
              LAST);
    8. 手动关联,假如只有一个页面想要做关联,首先需要在源码中找到需要关联的内容的左右边界,
    9. Runtime Settings菜单介绍。
    10. 接口测试的写法                                                                                                                                                    Action()
      {

          lr_rendezvous("hi");
          

          web_reg_find("Text={\"code\": \"00\", \"userid\": ",
              LAST);

          
          web_rest("POST: http://39.106.41.11:8080/register/",
              "URL=http://39.106.41.11:8080/register/",
              "Method=POST",
              //"EncType=raw",
              //"Snapshot=t854649.inf",
              "Body={\"username\":\"wxh22{usenum}\",\"password\":\"12345678abc\",\"email\":\"[email protected]\"}",
              LAST);
          
          

          return 0;
      },目前这个接口只要code返回00就是业务上注册成功了。
      1. 延伸:注册后需要登录,登录后返回值有token,需要将token取出来存到变量里,在后面的接口请求都可以用这个token作为请求参数去发送请求。
  5. Controller
    1. 启动Controller,有手动模式和目标模式两种方式,
    2. TPS拐点
    3. 如果想分析结果,最好可以通过对服务器端日志中得到更加具体的数据请求的时间等。
    4. 接口的响应时间,一百毫秒以上就是比较慢的了,一百毫秒以下就是不错的。
  6. Analysis
    1. 图示分析,在Average Transaction Response Time图标中右击选择Show Transaction Breakdown Tree,如图示:
  7. 网络流程:通过dns-找到ip-建立连接-发送请求-等待服务器处理-接收服务器返回数据-断开连接,first buffer time:等待服务器处理+返回数据的第一个字节在网上的传输时间。

Guess you like

Origin blog.csdn.net/chang_jinling/article/details/89428668