如何在jmeter中的同一个线程组中的各个线程之间共享4个计数器变量。保持初始值?

时间:2018-04-03 08:38:54

标签: groovy jmeter

  

/ *你好

     

我需要在> jmeter中生成100万个json请求进行负载测试。每个线程都会运行每个请求。我创建了一个帖子   group.Each json请求应如下所示:* /

      {
                "transaction_id": "TestTransactionId_1522743726505_0",
                "document_id": "TestDocumentId_1522743726505_200",
                "sender_id": "TestSenderId_1522743726505",
                "receiver_id": "TestReceiverId_1522743726505",
                "process_name": "TRANSACTION_TRACKING_PURCHASEORDER",
                "changed_by": "TestChangedBy_1522743726505",
                "system_id": "TestSystemId_1522743726505",
                "correlation_id": "TestDocumentId_1522743726505_200",
                "order_date": "1522743726505",
                "document_date": "1522743726505",
                "alert_type": "SUCCESS",
                "event_name": "TestEvent_1522743726505_200_0_0",
                "event_timestamp": "1522743726505",
                "event_id": "a907c672-a6bb-4295-a886-22fd1ba0b5f0",
                "host": "TestHost",
                "date_happened": "1522743726505",
                "reference_payload_id": "TestDocumentId_1522743726505_200",
                "error_message": "TestError_1522743726505",
                "source": "CIG",
                "attachment_document_type": "TRANSACTION_TRACKING_PURCHASEORDER"
            }


  /*  I need to generate this using 4 counter variables which are dependent upon each other. Following is the code for the same:
Can someone help me how to achieve this. My problem is that the threads are getting initialized everytime and its not picking the updated value. I am using jmeter groovy.*/

if (currentEventInDoc == 0) {
               currentDoc = (currentDoc+1)%numberOfDocPerOrder;
           }

           if (currentEventInDoc == 0 && currentDoc == 0) {
               currentOrder++;
           }      

        I

1 个答案:

答案 0 :(得分:0)

这可能是HTTP Simple Table Server的一个很好的用例,因为这是在多个JMeter引擎之间共享值的唯一方法。

您可以使用普通HTTP Request采样器添加新条目或读取现有条目,如果您需要增加__intSum() function可以使用的计数器值

您可以使用JMeter Plugins Manager

安装HTTP简单表服务器