mirror of https://github.com/grpc/grpc-node.git
test: make connctivity test more robust
The key change here is forcing the final unary call to wait for the server to be ready. The native client was making the RPC, but didn't appear to have a valid connection at the time.
This commit is contained in:
parent
7c2bb2a237
commit
e9946c3f6c
|
@ -76,10 +76,12 @@ describe('Reconnection', function() {
|
|||
});
|
||||
});
|
||||
after(function() {
|
||||
client.close();
|
||||
server1.forceShutdown();
|
||||
server2.forceShutdown();
|
||||
});
|
||||
it('Should end with either OK or UNAVAILABLE when querying a server that is shutting down', function(done) {
|
||||
this.timeout(10000);
|
||||
let pendingCalls = 0;
|
||||
let testDone = false;
|
||||
let callInterval;
|
||||
|
@ -94,7 +96,8 @@ describe('Reconnection', function() {
|
|||
server2.bindAsync(`localhost:${port}`, serverCreds, (err) => {
|
||||
assert.ifError(err);
|
||||
server2.start();
|
||||
client.unary({}, (err, data) => {
|
||||
const metadata = new clientGrpc.Metadata({ waitForReady: true });
|
||||
client.unary({}, metadata, (err, data) => {
|
||||
assert.ifError(err);
|
||||
clearInterval(callInterval);
|
||||
testDone = true;
|
||||
|
@ -103,6 +106,7 @@ describe('Reconnection', function() {
|
|||
});
|
||||
});
|
||||
callInterval = setInterval(() => {
|
||||
assert.strictEqual(testDone, false);
|
||||
pendingCalls += 1;
|
||||
client.unary({}, (err, data) => {
|
||||
pendingCalls -= 1;
|
||||
|
|
Loading…
Reference in New Issue