In the previous article, the link pressure test has been mentioned many times. In the statistical results of the link pressure test, only the execution time of the link and the corresponding QPS are counted, but the request time of each interface in the link is not counted, especially for the change curve of the interface response time. Today, I will make up this piece of content.

Review of previous articles:

  • Replay browser request multi-link performance testing practice
  • Single link performance test practice
  • Parameter diversity method sharing in link performance test
  • Parameter flow diagram in link test
  • The thread synchronization CyclicBarrier class is applied at the performance test collection point

Train of thought

Because the response time of each HTTP or other protocol request in the link pressure test is not recorded in the performance test framework, the statistics of response results need to be classified.

  • Read logs about interface response time and requestID.
  • According to differentURLDistinguish between different interfaces and store different oneslistIn the.
  • useStatisticsUtilClass statistics drawing function to complete the data display.

Log information

Part of the log is shared here. The log format varies greatly, and the code for reading the interface response time in the log needs to be done by the user. You need to clear the log files in advance or temporarily specify other log files, you need to correctly estimate the log volume and log4j 2 configuration, and you end up with all the logs in one file to save trouble.

WARN-> Create order number :f1615455162cXCQX INFO-> Request URI: HTTPS:/ / * * * * / API/public/v1 / order/refund, time-consuming: 1181 ms, requestId: Fun20210311173240XNwfINFO-> Request URI: HTTPS:/ / * * * * / API/public/v1 / order/create, time-consuming: 1336 ms, requestId: Fun20210311173240NBiRINFO-> Request URI: HTTPS:/ / * * * * / API/public/v1 / order/refund, time-consuming: 853 ms, requestId: Fun20210311173241jBqrINFO-> Request URI: HTTPS:/ / * * * * / API/public/v1 / order/create, time-consuming: 895 ms, requestId: Fun20210311173241lYiSWARN-> Create order number :f1615455160YBAgE WARN-> Create order number :f1615455161Ia2GC INFO-> request URI: HTTPS:/ / * * * * / API/public/v1 / order/refund, time-consuming: 1163 ms, requestId: Fun20210311173240aNZOINFO-> Request URI: HTTPS:/ / * * * * / API/public/v1 / order/refund, time-consuming: 1600 ms, requestId: Fun20210311173240SScOINFO-> Request URI: HTTPS:/ / * * * * / API/public/v1 / order/refund, time-consuming: 1289 ms, requestId: Fun20210311173240UPSBINFO-> Request URI: HTTPS:/ / * * * * / API/public/v1 / order/refund, time-consuming: 35 ms, requestId: Fun20210311173242QENpINFO-> Request URI: HTTPS:/ / * * * * / API/public/v1 / order/create, time-consuming: 44 ms, requestId: Fun20210311173242LcGaWARN-> Create order number :f1615455162qrVq0 INFO-> Request URI: HTTPS:/ / * * * * / API/public/v1 / order/refund, time-consuming: 40 ms, requestId: Fun20210311173242fxJgINFO-> Request URI: HTTPS:/ / * * * * / API/public/v1 / order/create, time-consuming: 31 ms, requestId: Fun20210311173242XWelWARN-> Create order number :f1615455162baA6B INFO-> Request URI: HTTPS:/ / * * * * / API/public/v1 / order/create, time-consuming: 27 ms, requestId: Fun20210311173242LnwAWARN-> Create order number :f1615455162SajUwCopy the code

In addition to the response time of the two interfaces, the request log is the order number printed by WARN. The required log content format is relatively uniform.

The script

Scripts are still written in Groovy because they are too easy to use.

			def lines = RWUtil.readTxtFileByLine(getLongFile("link.log"), "public/v1/order".true)
        def create = []
        def refund = []
        lines.each {
            def first = (Regex.findFirst(it, /\d+ ms/) - " ms") as int
            if (it.contains(OrderApi.CREATE)) create << first
            else if (it.contains(OrderApi.REFUND)) refund << first
            else println it
        }
        println StatisticsUtil.statistics(create, "Create order interface".200)
        println StatisticsUtil.statistics(refund, "Refund".200)
Copy the code

The thread number 200 needs to pass its own parameter, which is used to generate the title and has no other practical use.

Console output

Because of the font, I can only put diagrams here.


FunTester.Tencent Cloud Author of the Year,Boss direct hire contract author, non-famous test developer ER, welcome to follow.

  • Automated Testing trends in 2021
  • Appium 2.0 quick reference
  • FunTester test framework architecture diagram
  • FunTester test project architecture diagram
  • Verify depth copy from JVM heap memory analysis
  • Single link performance test practice
  • There are six steps to an automation strategy
  • Handle request parameters in JMeter with Groovy
  • Gradle + Groovy basis
  • Gradle plus Groovy increases
  • Weak network test: what is the minimum fluent network speed?