Skip to content

Commit

Permalink
test(sharded): reduce some sharded errors
Browse files Browse the repository at this point in the history
Got this down to 3 errors
  • Loading branch information
daprahamian authored and mbroadst committed Jan 14, 2019
1 parent d4eae97 commit fcb3ec1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion test/environments.js
Expand Up @@ -131,7 +131,7 @@ class ShardedEnvironment extends EnvironmentBase {

this.host = 'localhost';
this.port = 51000;
this.url = 'mongodb://%slocalhost:51000/integration_tests';
this.url = 'mongodb://%slocalhost:51000,localhost:51001/integration_tests';
this.writeConcernMax = { w: 'majority', wtimeout: 30000 };
this.topology = function(host, port, options) {
options = options || {};
Expand Down
7 changes: 3 additions & 4 deletions test/functional/sharding_connection_tests.js
Expand Up @@ -18,7 +18,7 @@ describe('Sharding (Connection)', function() {
test: function(done) {
const configuration = this.configuration;

const url = `${configuration.url()}?w=1&readPreference=secondaryPreferred&readPreferenceTags=sf%3A1&readPreferenceTags=`;
const url = `${configuration.url()}?w=1&readPreference=secondaryPreferred&readPreferenceTags=sf%3A1`;

const client = configuration.newClient(url, { haInterval: 500, useNewUrlParser: true });

Expand Down Expand Up @@ -82,7 +82,7 @@ describe('Sharding (Connection)', function() {
test: function(done) {
const configuration = this.configuration;

const url = `${configuration.url()}?w=1&readPreference=secondaryPreferred&readPreferenceTags=sf%3A1&readPreferenceTags=`;
const url = `${configuration.url()}?w=1&readPreference=secondaryPreferred&readPreferenceTags=sf%3A1`;

const client = configuration.newClient(url, { useNewUrlParser: true, haInterval: 500 });
client.connect(function(err) {
Expand All @@ -95,7 +95,6 @@ describe('Sharding (Connection)', function() {

expect(topology).to.have.property('haInterval', 500);
expect(topology).to.have.property('bson').that.does.exist;
expect(topology).to.have.property('isMasterDoc').that.does.exist;

expect(topology)
.to.have.property('isConnected')
Expand Down Expand Up @@ -124,7 +123,7 @@ describe('Sharding (Connection)', function() {
// The actual test we wish to run
test: function(done) {
const configuration = this.configuration;
const url = `${configuration.url()}?w=1&readPreference=secondaryPreferred&readPreferenceTags=sf%3A1&readPreferenceTags=`;
const url = `${configuration.url()}?w=1&readPreference=secondaryPreferred&readPreferenceTags=sf%3A1`;

const client = configuration.newClient(url, { useNewUrlParser: true, reconnectTries: 10 });
client.connect(function(err) {
Expand Down
10 changes: 5 additions & 5 deletions test/functional/sharding_read_preference_tests.js
Expand Up @@ -21,15 +21,15 @@ describe('Sharding (Read Preference)', function() {
const configuration = this.configuration;

// Connect using the mongos connections
var client = new MongoClient(configuration.url(), { w: 0 });
var client = new MongoClient(configuration.url(), { w: 0, monitorCommands: true });
client.connect(function(err) {
expect(err).to.not.exist;
const db = client.db(configuration.db);

// Perform a simple insert into a collection
const collection = db.collection('shard_test1');
// Insert a simple doc
collection.insert({ test: 1 }, { w: 'majority', wtimeout: 10000 }, function(err) {
collection.insertOne({ test: 1 }, { w: 'majority', wtimeout: 10000 }, function(err) {
expect(err).to.not.exist;

// Set debug level for the driver
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('Sharding (Read Preference)', function() {
// Perform a simple insert into a collection
const collection = db.collection('shard_test2');
// Insert a simple doc
collection.insert({ test: 1 }, { w: 'majority', wtimeout: 10000 }, function(err) {
collection.insertOne({ test: 1 }, { w: 'majority', wtimeout: 10000 }, function(err) {
expect(err).to.not.exist;

// Set debug level for the driver
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('Sharding (Read Preference)', function() {
// Perform a simple insert into a collection
const collection = db.collection('shard_test3');
// Insert a simple doc
collection.insert({ test: 1 }, { w: 'majority', wtimeout: 10000 }, function(err) {
collection.insertOne({ test: 1 }, { w: 'majority', wtimeout: 10000 }, function(err) {
expect(err).to.not.exist;

// Set debug level for the driver
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('Sharding (Read Preference)', function() {
// Perform a simple insert into a collection
const collection = db.collection('shard_test4');
// Insert a simple doc
collection.insert({ test: 1 }, { w: 'majority', wtimeout: 10000 }, function(err) {
collection.insertOne({ test: 1 }, { w: 'majority', wtimeout: 10000 }, function(err) {
expect(err).to.not.exist;

// Set debug level for the driver
Expand Down

0 comments on commit fcb3ec1

Please sign in to comment.