I’m working with an application that handles the submission and processing of filings, and I’m trying to perform a load test where different users target different filings and perform different actions depending on the filings’ status. This information exists within an incredibly long JSON response that is sent from the server, which also contains all the information on all the filings. It is particularly convenient, however, that the fields I’m interested in are close enough to each other to try to correlate them.
我正在处理一个处理提交和处理文件的应用程序,我正在尝试执行负载测试,其中不同的用户针对不同的文件并根据文件的状态执行不同的操作。此信息存在于从服务器发送的令人难以置信的长JSON响应中,该响应还包含有关所有文件的所有信息。然而,特别方便的是,我感兴趣的领域彼此足够接近以试图将它们相关联。
The way I’m going about this is the following: I need to extract each filing’s ID number in order to target it, and I need to be able to randomly target filing IDs that are associated with a specific status. The structure of the response that I care about is as follows:
我的方法如下:我需要提取每个文件的ID号以便定位它,我需要能够随机定位与特定状态相关的文件ID。我关心的响应结构如下:
{
"responseObject":{
"baseFilingRequests":{
"^Value":[
{"fields":"[values]"},
{"fields":"[values]"},
{
"fields":"values",
"referencedListings":"[value]",
"id":"[value]",
"referenceId":"[value]",
"status":"[value]",
"filingName":"[value]",
"fields":"values",
},
{"fields":"[values]"},
{"fields":"[values]"}
]
}
}
}
So I figured I could just stick this expression in the RegEx and modify the status field for each thread group so each would target filings with a different status (STATUS_APPROVED, STATUS_REJECTED, and so on), and then just extract the ID of each filing it finds, using an expression like this:
所以我想我可以在RegEx中粘贴这个表达式并修改每个线程组的状态字段,这样每个线程组都会定位具有不同状态的文件(STATUS_APPROVED,STATUS_REJECTED等),然后只提取每个文件的ID使用如下表达式查找:
\"referencedListings\":null,\"id\":\"(.+?)\",\"referenceId\":\"\d\d\d\d\d\d\d\”,\"status\":\"STATUS[_]RECEIVED\",
However, the underscore is giving me trouble when trying to extract IDs of filings with the status I specify. Sometimes it captures a different status (capturing a filing ID that corresponds to a filing with a STATUS_CANCELLED status, instead of the STATUS_LOCKED that I specify), sometimes it captures an ID but it doesn't stop extracting there; it extracts as much of the response that comes after it as it can, inserts this massive string in the variable, and then attempts to use that as a filing ID in my later requests, generating null pointer exceptions. This behavior is erratic and seemingly random, and I am at a loss as to how to solve this.
但是,在尝试使用我指定的状态提取文件的ID时,下划线会给我带来麻烦。有时它会捕获不同的状态(捕获与具有STATUS_CANCELLED状态的归档相对应的归档ID,而不是我指定的STATUS_LOCKED),有时它会捕获ID,但它不会停止在那里提取;它尽可能地提取尽可能多的响应,在变量中插入这个大量的字符串,然后尝试在后来的请求中将其用作文件ID,生成空指针异常。这种行为是不稳定的,看似随意,我不知道如何解决这个问题。
I’ve tried escaping the character using backslashes, and just about every other syntax I’ve been able to think of, but this behavior persists. It is the underscore without a doubt because whenever I try the expression using only everything that comes before the underscore, the RegEx behaves consistently and predictably. But I can’t just omit it, because it’s part of the syntax of the status that I need to detect so I can filter filings accordingly, more so when statuses like STATUS_PENDING_UNLOCK contain two underscores and I need to be able to detect both.
我已经尝试使用反斜杠转义字符,以及我能够想到的几乎所有其他语法,但这种行为仍然存在。毫无疑问,它是下划线,因为每当我只使用下划线之前的所有内容尝试表达式时,RegEx的行为一致且可预测。但我不能省略它,因为它是我需要检测的状态语法的一部分所以我可以相应地过滤文件,更多的是当STATUS_PENDING_UNLOCK等状态包含两个下划线并且我需要能够检测两者时。
Any insight on this matter would be greatly appreciated.
任何有关此事的见解将不胜感激。
1 个解决方案
#1
0
Simply don't use regular expressions to perform correlation on JSON data (same applies to XML and HTML)
只是不要使用正则表达式来执行JSON数据的关联(同样适用于XML和HTML)
Starting from JMeter version 3.0 there is JSON Extractor which you can use to perform correlation using JSON Path language
从JMeter 3.0版开始,有JSON Extractor,您可以使用它来使用JSON Path语言执行关联
#1
0
Simply don't use regular expressions to perform correlation on JSON data (same applies to XML and HTML)
只是不要使用正则表达式来执行JSON数据的关联(同样适用于XML和HTML)
Starting from JMeter version 3.0 there is JSON Extractor which you can use to perform correlation using JSON Path language
从JMeter 3.0版开始,有JSON Extractor,您可以使用它来使用JSON Path语言执行关联