Skip to content

Commit

Permalink
just added an easier way to run wired tiger and removed incompatible …
Browse files Browse the repository at this point in the history
…collectionsInfo method from driver
  • Loading branch information
christkv committed Nov 14, 2014
1 parent 2ac048e commit 8e0304e
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 130 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.log
*.heapsnapshot
*.dat
*.png
.project
.settings
.tm_properties
Expand All @@ -19,3 +20,5 @@ results/
gh-pages/
.coverage_data/
docs/sphinx-docs/source/driver-articles/
public/
docs/public
3 changes: 2 additions & 1 deletion lib/mongodb/connection/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var Connection = exports.Connection = function(id, socketOptions) {

// Supported min and max wire protocol
this.minWireVersion = 0;
this.maxWireVersion = 2;
this.maxWireVersion = 3;

//
// Connection parsing state
Expand Down Expand Up @@ -228,6 +228,7 @@ Connection.prototype.isConnected = function() {
// Validate if the driver supports this server
Connection.prototype.isCompatible = function() {
if(this.serverCapabilities == null) return true;

// Is compatible with backward server
if(this.serverCapabilities.minWireVersion == 0
&& this.serverCapabilities.maxWireVersion ==0) return true;
Expand Down
26 changes: 0 additions & 26 deletions lib/mongodb/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,32 +376,6 @@ Db.prototype.admin = function(callback) {
callback(null, new Admin(this));
};

/**
* DEPRECATED: Returns a cursor to all the collection information. Does not work with 2.8 or higher when using
* other storage engines
*
* @param {String} [collectionName] the collection name we wish to retrieve the information from.
* @param {Function} callback this will be called after executing this method. The first parameter will contain the Error object if an error occurred, or null otherwise. While the second parameter will contain the options or null if an error occurred.
* @return {null}
* @api public
* @deprecated
*/
Db.prototype.collectionsInfo = function(collectionName, callback) {
if(callback == null && typeof collectionName == 'function') { callback = collectionName; collectionName = null; }
// Create selector
var selector = {};
// If we are limiting the access to a specific collection name
if(collectionName != null) selector.name = this.databaseName + "." + collectionName;

// Return Cursor
// callback for backward compatibility
if(callback) {
callback(null, new Cursor(this, new Collection(this, DbCommand.SYSTEM_NAMESPACE_COLLECTION), selector));
} else {
return new Cursor(this, new Collection(this, DbCommand.SYSTEM_NAMESPACE_COLLECTION), selector);
}
};

/**
* Get the list of all collection names for the specified db
*
Expand Down
18 changes: 12 additions & 6 deletions test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ var replica_set_config = require('./configurations/replicasets').replica_set_con
, replica_set_config_auth = require('./configurations/replicasets').replica_set_config_auth
, none = require('./configurations/none').none;

// Run with wired tiger
var singleConf = {};
if(argv.t = 'wiredtiger') {
singleConf.storageEngine = 'wiredtiger';
argv.t = 'functional';
}

//
// Configurations
//
var configurations = Configuration
// Single server configuration
.add('single_server', single_server_config())
.add('single_server', single_server_config(singleConf))
.add('single_server_auth', single_server_config({auth:true}))
// Simple Replicaset Configuration
.add('replica_set', replica_set_config())
Expand Down Expand Up @@ -57,13 +64,12 @@ if(argv.t == 'functional') {
});

replicaset_runners.runner_auth.on('end', function() {
process.exit(0);
// sharded_runners.runner_auth.run('sharded_auth', run_options);
sharded_runners.runner_auth.run('sharded_auth', run_options);
});

// sharded_runners.runner_auth.on('end', function() {
// process.exit(0);
// });
sharded_runners.runner_auth.on('end', function() {
process.exit(0);
});

// Start chain of auth tests
standalone_runners.runner_auth.run('single_server_auth', run_options);
Expand Down
30 changes: 0 additions & 30 deletions test/tests/functional/collection_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,36 +271,6 @@ exports.shouldCorrectlyRetriveCollectionNames = function(configuration, test) {
});
}

/**
* @ignore
*/
exports.shouldCorrectlyRetrieveCollectionInfo = function(configuration, test) {
var Cursor = configuration.getMongoPackage().Cursor;

var db = configuration.newDbInstance({w:0}, {poolSize:1});
db.open(function(err, db) {
db.createCollection('test_collections_info', function(err, r) {
db.collectionsInfo(function(err, cursor) {
test.ok((cursor instanceof Cursor));
// Fetch all the collection info
cursor.toArray(function(err, documents) {
test.ok(documents.length > 1);

var found = false;
documents.forEach(function(document) {
if(document.name == configuration.db_name + '.test_collections_info') found = true;
});

test.ok(found);
// Let's close the db
db.close();
test.done();
});
});
});
});
}

/**
* An example returning the options for a collection.
*
Expand Down
46 changes: 23 additions & 23 deletions test/tests/functional/connection_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,26 +298,26 @@ exports.shouldCorrectlyReturnFalseOnIsConnectBeforeConnectionHappened = function
test.done();
}

/**
* @ignore
*/
exports['Should Force reconnect event by force closing connection'] = function(configuration, test) {
var db = configuration.newDbInstance({w:1}, {poolSize:1, auto_reconnect:true});
db.open(function(err, db) {
test.equal(null, err);

var reconnectCalled = false;
// Add listener to the serverConfig
db.serverConfig.on('reconnect', function(err) {
reconnectCalled = true;
});

configuration.restart(function() {
db.collection('forceReconnectEvent').insert({a:1}, function(err, result) {
test.ok(reconnectCalled);
db.close();
test.done();
});
});
});
}
// /**
// * @ignore
// */
// exports['Should Force reconnect event by force closing connection'] = function(configuration, test) {
// var db = configuration.newDbInstance({w:1}, {poolSize:1, auto_reconnect:true});
// db.open(function(err, db) {
// test.equal(null, err);

// var reconnectCalled = false;
// // Add listener to the serverConfig
// db.serverConfig.on('reconnect', function(err) {
// reconnectCalled = true;
// });

// configuration.restart(function() {
// db.collection('forceReconnectEvent').insert({a:1}, function(err, result) {
// test.ok(reconnectCalled);
// db.close();
// test.done();
// });
// });
// });
// }
41 changes: 0 additions & 41 deletions test/tests/functional/db_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,47 +470,6 @@ exports.shouldCorrectlyOpenASimpleDbSingleServerConnectionAndCloseWithCallback =
// DOC_END
}

/**
* An example of retrieving the information of all the collections.
*
* @_class db
* @_function collectionsInfo
* @ignore
*/
exports.shouldCorrectlyRetrieveCollectionInformation = function(configuration, test) {
var db = configuration.newDbInstance({w:0}, {poolSize:1, auto_reconnect:false});

// DOC_LINE var db = new Db('test', new Server('localhost', 27017));
// DOC_START
// Establish connection to db
db.open(function(err, db) {
test.equal(null, err);

// Create a collection
db.createCollection('test_collections_info', function(err, r) {
test.equal(null, err);

// Return the information of a single collection name
db.collectionsInfo("test_collections_info").toArray(function(err, items) {
test.equal(1, items.length);

// Return the information of a all collections, using the callback format
db.collectionsInfo(function(err, cursor) {

// Turn the cursor into an array of results
cursor.toArray(function(err, items) {
test.ok(items.length > 0);

db.close();
test.done();
});
})
});
});
});
// DOC_END
}

/**
* An example of retrieving the collection names for a database.
*
Expand Down
12 changes: 9 additions & 3 deletions test/tools/server_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ var ServerManager = exports.ServerManager = function(options) {
this.ssl_server_pem_pass = options['ssl_server_pem_pass'] != null ? options['ssl_server_pem_pass'] : null;
this.ssl_weak_certificate_validation = options['ssl_weak_certificate_validation'] != null ? options['ssl_weak_certificate_validation'] : null;
this.ssl_fips = options['ssl_fips'] != null ? options['ssl_fips'] : null;

// Storage engine
this.storageEngine = options['storageEngine'];

// Ca settings for ssl
this.ssl_ca = options['ssl_ca'] != null ? options['ssl_ca'] : null;
Expand Down Expand Up @@ -100,7 +103,7 @@ ServerManager.prototype.start = function(killall, options, callback) {
// Create start command
var startCmd = generateStartCmd(this, {configserver:self.configServer, log_path: self.log_path
, db_path: self.db_path, port: self.port, journal: self.journal, auth:self.auth, ssl:self.ssl
, master:self.master, scram: self.scram});
, master:self.master, scram: self.scram, storageEngine: this.storageEngine});

exec(killall ? 'killall -15 mongod' : '', function(err, stdout, stderr) {
if(purgedirectories) {
Expand All @@ -127,7 +130,9 @@ ServerManager.prototype.start = function(killall, options, callback) {
if(err) throw err;
// Mark server as running
self.up = true;
self.pid = fs.readFileSync(path.join(self.db_path, "mongod.lock"), 'ascii').trim();
try {
self.pid = fs.readFileSync(path.join(self.db_path, "mongod.lock"), 'ascii').trim();
} catch(err) {}
// Callback
callback();
});
Expand Down Expand Up @@ -204,6 +209,7 @@ var generateStartCmd = function(self, options) {
startCmd = startCmd + " --setParameter enableTestCommands=1";
startCmd = options['master'] ? startCmd + " --master" : startCmd;
startCmd = options['scram'] ? startCmd + " --setParameter authenticationMechanisms=SCRAM-SHA-1" : startCmd;
startCmd = options['storageEngine'] ? startCmd + " --storageEngine=" + options['storageEngine'] : startCmd;

// If we have ssl defined set up with test certificate
if(options['ssl']) {
Expand All @@ -230,7 +236,7 @@ var generateStartCmd = function(self, options) {
startCmd = startCmd + " --sslFIPSMode"
}
}
// console.log(startCmd)
console.log(startCmd)

// Return start command
return startCmd;
Expand Down

0 comments on commit 8e0304e

Please sign in to comment.