diff options
| author | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-18 10:54:08 +0000 |
|---|---|---|
| committer | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-18 10:54:08 +0000 |
| commit | a35da9f9ccc1124d9b6f4461c7216ffbb0285e2f (patch) | |
| tree | d5b4b8548caae36a20e1258a8341dab4b3d522d2 /node_modules/mongodb/test8.js | |
| parent | 16bbc66ebafc6f1a55e47dbda3f3c0f658fe715c (diff) | |
| parent | c1ce89359a7b54ec97b54ce577e5534c180c5c4b (diff) | |
merged
Diffstat (limited to 'node_modules/mongodb/test8.js')
| -rw-r--r-- | node_modules/mongodb/test8.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/node_modules/mongodb/test8.js b/node_modules/mongodb/test8.js new file mode 100644 index 0000000..5e31af4 --- /dev/null +++ b/node_modules/mongodb/test8.js @@ -0,0 +1,51 @@ +var mongodb = require("./"), + CoreConnection = mongodb.CoreConnection, + CoreServer = mongodb.CoreServer; + +var uri = "mongodb://foo:bar@ds021331-a0.mlab.com:21331,ds021331-a1.mlab.com:21331/driver-test?replicaSet=rs-ds021331"; +// mongostat -u foo -p bar --authenticationDatabase driver-test --host rs-ds021331/ds021331-a0.mlab.com:21331,ds021331-a1.mlab.com:21331 --discover +var options = {server: {socketOptions: {connectTimeoutMS: 5000, socketTimeoutMS: 15000}}} +var interval = 100; +var total = 1000; + +// console.dir(CoreConnection) +CoreConnection.enableConnectionAccounting(); +CoreServer.enableServerAccounting(); + +var openThenClose = function(count){ + var MongoClient = mongodb.MongoClient; + + MongoClient.connect(uri, options, function(err, db) { + if (err) { + console.error(Date() + " " + err) + } else { + console.error(Date() + " open :: " + count); + var descriptors = db.collection("some-collection").find(); + descriptors.toArray(function(err, docs){ + console.error(Date() + " found " + docs.length + " docs") + db.close(function(){ + console.error(Date() + " close :: " + count); + }); + }); + } + }); +}; + +var count = total; +// console.error(Date() + " starting up") +var intervalId = setInterval(function(){ + count = count - 1; + + if(count == 0) { + clearInterval(intervalId); + setTimeout(function() { + CoreConnection.disableConnectionAccounting(); + CoreServer.disableServerAccounting(); + console.log("============================= connections left") + console.dir(Object.keys(CoreConnection.connections())); + console.dir(Object.keys(CoreServer.servers())); + }, 5000); + } else { + openThenClose(count); + } +}, interval); |
