diff options
Diffstat (limited to 'jstests/noPassthroughWithMongod/cursor_server_status_metrics.js')
-rw-r--r-- | jstests/noPassthroughWithMongod/cursor_server_status_metrics.js | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/jstests/noPassthroughWithMongod/cursor_server_status_metrics.js b/jstests/noPassthroughWithMongod/cursor_server_status_metrics.js index b8f8a240662..865809f63b2 100644 --- a/jstests/noPassthroughWithMongod/cursor_server_status_metrics.js +++ b/jstests/noPassthroughWithMongod/cursor_server_status_metrics.js @@ -2,85 +2,85 @@ * Tests for serverStatus metrics.cursor stats. */ (function() { - var coll = db[jsTest.name()]; - coll.drop(); - assert.writeOK(coll.insert({_id: 1})); - assert.writeOK(coll.insert({_id: 2})); - assert.writeOK(coll.insert({_id: 3})); +var coll = db[jsTest.name()]; +coll.drop(); +assert.writeOK(coll.insert({_id: 1})); +assert.writeOK(coll.insert({_id: 2})); +assert.writeOK(coll.insert({_id: 3})); - assert.eq(3, coll.find().count()); +assert.eq(3, coll.find().count()); - function getCurrentCursorsOpen() { - return db.serverStatus().metrics.cursor.open.total; - } +function getCurrentCursorsOpen() { + return db.serverStatus().metrics.cursor.open.total; +} - function getCurrentCursorsPinned() { - return db.serverStatus().metrics.cursor.open.pinned; - } +function getCurrentCursorsPinned() { + return db.serverStatus().metrics.cursor.open.pinned; +} - var initialTotalOpen = getCurrentCursorsOpen(); +var initialTotalOpen = getCurrentCursorsOpen(); - // We expect no pinned cursors - assert.eq(0, getCurrentCursorsPinned()); +// We expect no pinned cursors +assert.eq(0, getCurrentCursorsPinned()); - // Total open cursors should not have changed after exhausting a cursor. - assert.eq(3, coll.find().itcount()); - assert.eq(initialTotalOpen, getCurrentCursorsOpen()); - assert.eq(3, coll.find().batchSize(2).itcount()); - assert.eq(initialTotalOpen, getCurrentCursorsOpen()); - assert.eq(3, coll.find().batchSize(1).itcount()); - assert.eq(initialTotalOpen, getCurrentCursorsOpen()); +// Total open cursors should not have changed after exhausting a cursor. +assert.eq(3, coll.find().itcount()); +assert.eq(initialTotalOpen, getCurrentCursorsOpen()); +assert.eq(3, coll.find().batchSize(2).itcount()); +assert.eq(initialTotalOpen, getCurrentCursorsOpen()); +assert.eq(3, coll.find().batchSize(1).itcount()); +assert.eq(initialTotalOpen, getCurrentCursorsOpen()); - assert.eq(3, coll.aggregate([]).itcount()); - assert.eq(initialTotalOpen, getCurrentCursorsOpen()); - assert.eq(3, coll.aggregate([], {cursor: {batchSize: 2}}).itcount()); - assert.eq(initialTotalOpen, getCurrentCursorsOpen()); - assert.eq(3, coll.aggregate([], {cursor: {batchSize: 1}}).itcount()); - assert.eq(initialTotalOpen, getCurrentCursorsOpen()); +assert.eq(3, coll.aggregate([]).itcount()); +assert.eq(initialTotalOpen, getCurrentCursorsOpen()); +assert.eq(3, coll.aggregate([], {cursor: {batchSize: 2}}).itcount()); +assert.eq(initialTotalOpen, getCurrentCursorsOpen()); +assert.eq(3, coll.aggregate([], {cursor: {batchSize: 1}}).itcount()); +assert.eq(initialTotalOpen, getCurrentCursorsOpen()); - // Total pinned cursors should remain zero exhausting a cursor. - assert.eq(3, coll.find().itcount()); - assert.eq(0, getCurrentCursorsPinned()); - assert.eq(3, coll.find().batchSize(2).itcount()); - assert.eq(0, getCurrentCursorsPinned()); - assert.eq(3, coll.find().batchSize(1).itcount()); - assert.eq(0, getCurrentCursorsPinned()); +// Total pinned cursors should remain zero exhausting a cursor. +assert.eq(3, coll.find().itcount()); +assert.eq(0, getCurrentCursorsPinned()); +assert.eq(3, coll.find().batchSize(2).itcount()); +assert.eq(0, getCurrentCursorsPinned()); +assert.eq(3, coll.find().batchSize(1).itcount()); +assert.eq(0, getCurrentCursorsPinned()); - assert.eq(3, coll.aggregate([]).itcount()); - assert.eq(0, getCurrentCursorsPinned()); - assert.eq(3, coll.aggregate([], {cursor: {batchSize: 2}}).itcount()); - assert.eq(0, getCurrentCursorsPinned()); - assert.eq(3, coll.aggregate([], {cursor: {batchSize: 1}}).itcount()); - assert.eq(0, getCurrentCursorsPinned()); +assert.eq(3, coll.aggregate([]).itcount()); +assert.eq(0, getCurrentCursorsPinned()); +assert.eq(3, coll.aggregate([], {cursor: {batchSize: 2}}).itcount()); +assert.eq(0, getCurrentCursorsPinned()); +assert.eq(3, coll.aggregate([], {cursor: {batchSize: 1}}).itcount()); +assert.eq(0, getCurrentCursorsPinned()); - // This cursor should remain open on the server, but not pinned. - var cursor = coll.find().batchSize(2); - cursor.next(); - assert.eq(initialTotalOpen + 1, getCurrentCursorsOpen()); - assert.eq(0, getCurrentCursorsPinned()); +// This cursor should remain open on the server, but not pinned. +var cursor = coll.find().batchSize(2); +cursor.next(); +assert.eq(initialTotalOpen + 1, getCurrentCursorsOpen()); +assert.eq(0, getCurrentCursorsPinned()); - // Same should be true after pulling the second document out of the cursor, since we haven't - // issued a getMore yet. - cursor.next(); - assert.eq(initialTotalOpen + 1, getCurrentCursorsOpen()); - assert.eq(0, getCurrentCursorsPinned()); +// Same should be true after pulling the second document out of the cursor, since we haven't +// issued a getMore yet. +cursor.next(); +assert.eq(initialTotalOpen + 1, getCurrentCursorsOpen()); +assert.eq(0, getCurrentCursorsPinned()); - // Cursor no longer reported as open after being exhausted. - cursor.next(); - assert(!cursor.hasNext()); - assert.eq(initialTotalOpen, getCurrentCursorsOpen()); - assert.eq(0, getCurrentCursorsPinned()); +// Cursor no longer reported as open after being exhausted. +cursor.next(); +assert(!cursor.hasNext()); +assert.eq(initialTotalOpen, getCurrentCursorsOpen()); +assert.eq(0, getCurrentCursorsPinned()); - // Same behavior expected for an aggregation cursor. - var cursor = coll.aggregate([], {cursor: {batchSize: 2}}); - cursor.next(); - assert.eq(initialTotalOpen + 1, getCurrentCursorsOpen()); - assert.eq(0, getCurrentCursorsPinned()); - cursor.next(); - assert.eq(initialTotalOpen + 1, getCurrentCursorsOpen()); - assert.eq(0, getCurrentCursorsPinned()); - cursor.next(); - assert(!cursor.hasNext()); - assert.eq(initialTotalOpen, getCurrentCursorsOpen()); - assert.eq(0, getCurrentCursorsPinned()); +// Same behavior expected for an aggregation cursor. +var cursor = coll.aggregate([], {cursor: {batchSize: 2}}); +cursor.next(); +assert.eq(initialTotalOpen + 1, getCurrentCursorsOpen()); +assert.eq(0, getCurrentCursorsPinned()); +cursor.next(); +assert.eq(initialTotalOpen + 1, getCurrentCursorsOpen()); +assert.eq(0, getCurrentCursorsPinned()); +cursor.next(); +assert(!cursor.hasNext()); +assert.eq(initialTotalOpen, getCurrentCursorsOpen()); +assert.eq(0, getCurrentCursorsPinned()); }()); |