在JMETER中-如何在API测试的每个单独请求级别实现TPS

时间:2019-08-19 01:47:47

标签: transactions jmeter httprequest throughput jmeter-4.0

I would like to achieve transactions per minutes at request level, what would be approach and how the script structure should look like ?

要求:

我总共有67个并发用户。

I need to achieve transaction per minute at each request level, all under same thread group. As per my requirement, my each HTTP sampler is a transaction. This is for API testing.

6 API requests under 6 simple controller. 

My Script structure:
1. Test Plan
2. Thread Group
3. Simple Controller
    i. HTTP Sampler
    ii. Response Assertion.
    iii. Boundary value Extractor
    iv. Results Action Set Handler
4. View Results Tree
5. Summary Report

I have tried 2 ways:

Instead of simple controller, i have used throughput controller and used percent Executions.

I also had constant throughput timer.

Requirement:
In total i have 67 concurrent users.

I need to achieve transaction per minute at each request level, all under same thread group.

6 API requests under 6 simple controller.

My Script structure:

1. Test Plan
2. Thread Group
3. Simple Controller
    i. HTTP Sampler
    ii. Response Assertion.
    iii. Boundary value Extractor
    iv. Results Action Set Handler
4. View Results Tree
5. Summary Report

Example:    
All API requests / http sampler falls under the same thread group and request should execute in the given sequence as correlation is in place.

API请求每分钟1-152个请求。 API请求2-每分钟56个请求。 API请求每分钟3-32个请求。 API请求每分钟4-12个请求。 API请求每分钟5-12个请求。 API请求每分钟6-12个请求。

Were i need to perform a load test and soak test as well with the above workload model.

1 个答案:

答案 0 :(得分:1)

在同一Samplers下,不同的Thread Group不能具有不同的吞吐量级别,因为JMeter颠倒执行Samplers并循环执行,因此总执行速度将降低到最慢采样器的执行速率。

解决方案是将要以不同速度执行的请求放在不同的线程组下。如果需要在不同线程组中的线程之间传递值,则可以使用:

    在第一个线程组中使用
  1. __setProperty() function将所需的值保存到JMeter属性中,在第二个线程组中使用__P() function来读取该值。您可能还希望将其与__threadNum() function结合使用以使值特定于线程。
  2. Inter-Thread Communication Plugin

您可以依次使用以下测试元素之一来设置不同线程组下的Sampler所需的TPS:

  1. Constant Throughput Timer
  2. Precise Throughput Timer
  3. Throughput Shaping Timer