Skip to content

Commit

Permalink
test: disable historically flakey test until we can triage the cause
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Nov 5, 2019
1 parent 63e8fb5 commit 29e5ef7
Showing 1 changed file with 134 additions and 130 deletions.
264 changes: 134 additions & 130 deletions test/core/functional/rs_mocks/all_servers_close_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,145 +165,149 @@ describe('ReplSet All Servers Close (mocks)', function() {
}
});

it('Successfully come back from a dead replicaset that has been unavailable for a long time', {
metadata: {
requires: {
generators: true,
topology: 'single'
}
},

test: function(done) {
var electionIds = [new ObjectId(), new ObjectId()];
var die = false;

// Default message fields
var defaultFields = Object.assign({}, mock.DEFAULT_ISMASTER, {
setName: 'rs',
setVersion: 1,
electionId: electionIds[0],
hosts: ['localhost:34000', 'localhost:34001', 'localhost:34002'],
arbiters: ['localhost:34002']
});

// Primary server states
var primary = [
Object.assign({}, defaultFields, {
ismaster: true,
secondary: false,
me: 'localhost:34000',
primary: 'localhost:34000',
tags: { loc: 'ny' }
})
];

// Primary server states
var firstSecondary = [
Object.assign({}, defaultFields, {
ismaster: false,
secondary: true,
me: 'localhost:34001',
primary: 'localhost:34000',
tags: { loc: 'sf' }
})
];

// Primary server states
var arbiter = [
Object.assign({}, defaultFields, {
ismaster: false,
secondary: false,
arbiterOnly: true,
me: 'localhost:34002',
primary: 'localhost:34000'
})
];

// Boot the mock
co(function*() {
const primaryServer = yield mock.createServer(34000, 'localhost');
const firstSecondaryServer = yield mock.createServer(34001, 'localhost');
const arbiterServer = yield mock.createServer(34002, 'localhost');

primaryServer.setMessageHandler(request => {
if (die) {
request.connection.destroy();
} else {
var doc = request.document;
if (doc.ismaster) {
request.reply(primary[0]);
}
}
// NOTE: notoriously flakey test, skipped until we have time to triage
it.skip(
'Successfully come back from a dead replicaset that has been unavailable for a long time',
{
metadata: {
requires: {
generators: true,
topology: 'single'
}
},

test: function(done) {
var electionIds = [new ObjectId(), new ObjectId()];
var die = false;

// Default message fields
var defaultFields = Object.assign({}, mock.DEFAULT_ISMASTER, {
setName: 'rs',
setVersion: 1,
electionId: electionIds[0],
hosts: ['localhost:34000', 'localhost:34001', 'localhost:34002'],
arbiters: ['localhost:34002']
});

firstSecondaryServer.setMessageHandler(request => {
if (die) {
request.connection.destroy();
} else {
var doc = request.document;
if (doc.ismaster) {
request.reply(firstSecondary[0]);
// Primary server states
var primary = [
Object.assign({}, defaultFields, {
ismaster: true,
secondary: false,
me: 'localhost:34000',
primary: 'localhost:34000',
tags: { loc: 'ny' }
})
];

// Primary server states
var firstSecondary = [
Object.assign({}, defaultFields, {
ismaster: false,
secondary: true,
me: 'localhost:34001',
primary: 'localhost:34000',
tags: { loc: 'sf' }
})
];

// Primary server states
var arbiter = [
Object.assign({}, defaultFields, {
ismaster: false,
secondary: false,
arbiterOnly: true,
me: 'localhost:34002',
primary: 'localhost:34000'
})
];

// Boot the mock
co(function*() {
const primaryServer = yield mock.createServer(34000, 'localhost');
const firstSecondaryServer = yield mock.createServer(34001, 'localhost');
const arbiterServer = yield mock.createServer(34002, 'localhost');

primaryServer.setMessageHandler(request => {
if (die) {
request.connection.destroy();
} else {
var doc = request.document;
if (doc.ismaster) {
request.reply(primary[0]);
}
}
}
});

arbiterServer.setMessageHandler(request => {
if (die) {
request.connection.destroy();
} else {
var doc = request.document;
if (doc.ismaster) {
request.reply(arbiter[0]);
});

firstSecondaryServer.setMessageHandler(request => {
if (die) {
request.connection.destroy();
} else {
var doc = request.document;
if (doc.ismaster) {
request.reply(firstSecondary[0]);
}
}
}
});

// Attempt to connect
var server = new ReplSet(
[
{ host: 'localhost', port: 34000 },
{ host: 'localhost', port: 34001 },
{ host: 'localhost', port: 34002 }
],
{
setName: 'rs',
connectionTimeout: 5000,
socketTimeout: 5000,
haInterval: 100,
size: 1
}
);
});

arbiterServer.setMessageHandler(request => {
if (die) {
request.connection.destroy();
} else {
var doc = request.document;
if (doc.ismaster) {
request.reply(arbiter[0]);
}
}
});

// Attempt to connect
var server = new ReplSet(
[
{ host: 'localhost', port: 34000 },
{ host: 'localhost', port: 34001 },
{ host: 'localhost', port: 34002 }
],
{
setName: 'rs',
connectionTimeout: 5000,
socketTimeout: 5000,
haInterval: 100,
size: 1
}
);

server.on('connect', function() {
setTimeout(function() {
die = true;
server.on('connect', function() {
setTimeout(function() {
die = true;

var intervalId = setInterval(function() {
server.command('admin.$cmd', { ismaster: true }, function() {});
}, 500);
var intervalId = setInterval(function() {
server.command('admin.$cmd', { ismaster: true }, function() {});
}, 500);

setTimeout(function() {
die = false;
setTimeout(function() {
clearInterval(intervalId);

server.command('admin.$cmd', { ismaster: true }, function(err, r) {
expect(r).to.exist;
expect(err).to.be.null;
expect(server.s.replicaSetState.primary).to.not.be.null;
expect(server.s.replicaSetState.secondaries).to.have.length(1);
expect(server.s.replicaSetState.arbiters).to.have.length(1);
die = false;
setTimeout(function() {
clearInterval(intervalId);

server.command('admin.$cmd', { ismaster: true }, function(err, r) {
expect(r).to.exist;
expect(err).to.be.null;
expect(server.s.replicaSetState.primary).to.not.be.null;
expect(server.s.replicaSetState.secondaries).to.have.length(1);
expect(server.s.replicaSetState.arbiters).to.have.length(1);

server.destroy();
done();
});
}, 1500);
}, 1000);
}, 500);
});

server.destroy();
done();
});
}, 1500);
}, 1000);
}, 500);
server.connect();
});

server.connect();
});
}
}
});
);
});

0 comments on commit 29e5ef7

Please sign in to comment.