Skip to content

Commit

Permalink
Add load test for connection pool and fix issue, where connections we…
Browse files Browse the repository at this point in the history
…re marked as 'taken' too early
  • Loading branch information
ctavan committed Jan 30, 2012
1 parent d5c7427 commit 634d7d6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ PooledConnection.prototype.execute = function(query, args, executeCallback) {
callback(err, null);
} else {
try {
con.taken = true;
con.execute(query, args, function(err, result) {
con.taken = false;
var recoverableError = null;
Expand Down
43 changes: 43 additions & 0 deletions test/test_driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1008,3 +1008,46 @@ exports.testConnectionInPool = function(test, assert) {
}
});
};


exports.testPooledConnectionLoad = function(test, assert) {
var hosts = ['127.0.0.1:19170'];
var conn = new PooledConnection({'hosts': hosts, 'keyspace': 'Keyspace1'});

var count = 3000;

async.waterfall([
function(cb) {
conn.execute('TRUNCATE CfUtf8', [], cb);
},
function(res, cb) {
var executes = [];
for (var i = 0; i < count; i++) {
executes.push(function(parallelCb) {
var uuid = new UUID().toString();
conn.execute('UPDATE CfUtf8 SET ? = ? WHERE KEY = ?', [
'testCol',
'testVal',
uuid
], parallelCb);
});
}
async.parallel(executes, function(err) {
assert.ifError(err);
cb();
});
},
function(cb) {
conn.execute('SELECT COUNT(*) FROM CfUtf8', [], cb);
},
function(res, cb) {
assert.equal(res[0].colHash.count, count);
cb();
},
conn.shutdown.bind(conn)
],
function(err) {
assert.ifError(err);
test.finish();
});
};

0 comments on commit 634d7d6

Please sign in to comment.