Как вызвать операцию подсчета запроса MongoDB на JMeter, используя groovy? - PullRequest
1 голос
/ 30 сентября 2019

У меня есть запрос, как показано ниже, который работает на 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


...