mirror of https://github.com/grpc/grpc-node.git
Connectivity test: ensure all calls end before ending the test
This commit is contained in:
parent
2e13f46141
commit
eb3c479e36
|
@ -76,6 +76,13 @@ describe('Reconnection', function() {
|
|||
server2.forceShutdown();
|
||||
});
|
||||
it('Should end with either OK or UNAVAILABLE when querying a server that is shutting down', function(done) {
|
||||
let pendingCalls = 0;
|
||||
let testDone = false;
|
||||
function maybeDone() {
|
||||
if (testDone && pendingCalls == 0) {
|
||||
done();
|
||||
}
|
||||
};
|
||||
client.unary({}, (err, data) => {
|
||||
assert.ifError(err);
|
||||
server1.tryShutdown(() => {
|
||||
|
@ -84,14 +91,18 @@ describe('Reconnection', function() {
|
|||
client.unary({}, (err, data) => {
|
||||
assert.ifError(err);
|
||||
clearInterval(callInterval);
|
||||
done();
|
||||
testDone = true;
|
||||
maybeDone();
|
||||
});
|
||||
});
|
||||
let callInterval = setInterval(() => {
|
||||
pendingCalls += 1;
|
||||
client.unary({}, (err, data) => {
|
||||
pendingCalls -= 1;
|
||||
if (err) {
|
||||
assert.strictEqual(err.code, clientGrpc.status.UNAVAILABLE);
|
||||
}
|
||||
maybeDone();
|
||||
});
|
||||
}, 0);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue