【发布时间】:2015-12-02 09:58:07
【问题描述】:
(问题从Jmeter protobuf testing. Could not read Protobuf message继续) 我正在通过 Protobuf 协议测试应用程序。最初我使用 HTTP 采样器,但将二进制数据保存到字符串时出现问题。 解决方案是使用带有 HTTPClient 和 POST 请求的 Beanshell 采样器以及正文中的二进制数据:
byte[] data = null;
//...assign protobuf binary buffer to data...
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://127.0.0.1");
HttpEntity entity = new ByteArrayEntity(data);
post.setEntity(entity);
post.setHeader(HttpHeaders.CONTENT_TYPE, "application/octet-stream");
HttpResponse response=null;
try {
response = client.execute(post);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ResponseCode = response.getStatusLine().getStatusCode().toString();
//if some assert is true then
Issuccess = true;
ResponseMessage="Some Response Message";
因为我尝试为成千上万的并发用户提供高负载,所以我开始使用 JSR223+Grovy 采样器而不是 Beanshell 采样器(受这篇文章 https://blazemeter.com/blog/beanshell-vs-jsr223-vs-java-jmeter-scripting-its-performance 影响)
在测试期间,所有 JSR223 采样器的响应时间都有一个强劲的增长:
然后创建了一个新的测试计划并将所有 JSR223 替换为 Beanshell 采样器(没有重置选项)。图片没问题(同比例图):
那么如何识别 JSR223 的问题或修复它。另一个问题是,当 JST223+Grovy 提供这些问题时,为什么每个人都推荐使用它?
【问题讨论】: