mongodb - 如何使用groovy在JMeter上调用MongoDB查询的计数操作?
问题描述
我有一个查询如下,它正在使用 mongoDB
我需要在 JMeter 中执行此查询以获取对象计数。请注意,我正在使用 Groovy 脚本来执行相同的操作。
db.getCollection('collectionName').find({ $or: [ {"Service" :"AAA"}, {ServerName : "BBB"} ],
"ConnectionID" : "AAAA445789",
"CDDval" : "AGB"
});
Below is the code i am running in groovy and not giving the expected result like Mongodb query above.it is giving error javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
try {
MongoCollection<Document> collection = vars.getObject("collectionName");
Document result = collection.find("uuid" ,"{$or : [
{"Service": "AAA"},
{ServerName : "BBB"}
],
"ConnectionID" : "AAAA445789",
"CDDval" : "AGB"
"}).first;
vars.put("uuid", result.get("uuid").toString());
return "uuid=" + result.get("uuid") + " found";
}
catch (Exception e) {
SampleResult.setSuccessful(false);
SampleResult.setResponseCode("500");
SampleResult.setResponseMessage("Exception: " + e);
}
I have tried the using JMeter Groovy 2.4.13 but not getting correct respose, below is the code
解决方案
推荐阅读
- ios - 为什么 WKWebView 不使用 swift 在 iOS 中加载 pdf?
- python - Python索引错误使用生成器和yield
- swift - 如何在标签中添加动态文本字段?
- javascript - 导出默认组件和多个子组件
- c# - 创建一个接口并使用 SimpleIoc 注入
- php - 字符串过长导致错误 - “无法修改标头信息”
- javascript - 如何使图像适合简单的自动播放幻灯片?
- python - 尝试用python以两种方式计算列表列表中的重复项,但得到不同的答案
- java - 如何添加基于扫描仪创建多个扫描仪
- pandas - 如何使用 df.add_suffix 为 Pandas 中的重复列名添加后缀?