diff options
Diffstat (limited to 'jstests/libs/profiler.js')
-rw-r--r-- | jstests/libs/profiler.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/jstests/libs/profiler.js b/jstests/libs/profiler.js index c0fc210c928..5d94050d775 100644 --- a/jstests/libs/profiler.js +++ b/jstests/libs/profiler.js @@ -2,8 +2,14 @@ // Retrieve latest system.profile entry. function getLatestProfilerEntry(inputDb, filter) { - var cursor = inputDb.system.profile.find(filter === null ? {} : filter); - return cursor.sort({$natural: -1}).next(); + if (filter === null) { + filter = {}; + } + var cursor = inputDb.system.profile.find(filter).sort({$natural: -1}); + assert( + cursor.hasNext(), + "could not find any entries in the profile collection matching filter: " + tojson(filter)); + return cursor.next(); } // Returns a string representing the wire protocol used for commands run on the given connection. @@ -23,4 +29,4 @@ function profilerHasSingleMatchingEntryOrThrow(inputDb, filter, errorMsgFilter, 1, "Expected exactly one op matching: " + tojson(filter) + " in profiler " + tojson(inputDb.system.profile.find(errorMsgFilter, errorMsgProj).toArray())); -}
\ No newline at end of file +} |