Skip to content

Commit

Permalink
Merge pull request #1071 from murgatroid99/grpc-js_regression_tests
Browse files Browse the repository at this point in the history
Add regression tests for recent failures, move a test
  • Loading branch information
murgatroid99 authored Oct 22, 2019
2 parents 97ed462 + 8a212ba commit fafe8fb
Show file tree
Hide file tree
Showing 6 changed files with 694 additions and 649 deletions.
4 changes: 3 additions & 1 deletion test/any_grpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ const serverImpl = getImplementation('_server_implementation');

module.exports = {
client: clientImpl,
server: serverImpl
server: serverImpl,
clientName: global._client_implementation,
serverName: global._server_implementation
};
108 changes: 55 additions & 53 deletions test/api/connectivity_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,64 +58,66 @@ const serviceImpl = {
}
};

describe('Reconnection', function() {
let server1;
let server2;
let port;
before(function(done) {
server1 = new serverGrpc.Server();
server1.addService(TestService, serviceImpl);
server2 = new serverGrpc.Server();
server2.addService(TestService, serviceImpl);
server1.bindAsync('localhost:0', serverCreds, (err, _port) => {
assert.ifError(err);
server1.start();
port = _port;
client = new TestServiceClient(`localhost:${port}`, clientCreds);
done();
});
});
after(function() {
client.close();
server1.forceShutdown();
server2.forceShutdown();
});
it.skip('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;
function maybeDone() {
if (testDone && pendingCalls === 0) {
describe(`${anyGrpc.clientName} client -> ${anyGrpc.serverName} server`, function() {
describe('Reconnection', function() {
let server1;
let server2;
let port;
before(function(done) {
server1 = new serverGrpc.Server();
server1.addService(TestService, serviceImpl);
server2 = new serverGrpc.Server();
server2.addService(TestService, serviceImpl);
server1.bindAsync('localhost:0', serverCreds, (err, _port) => {
assert.ifError(err);
server1.start();
port = _port;
client = new TestServiceClient(`localhost:${port}`, clientCreds);
done();
}
};
client.unary({}, (err, data) => {
assert.ifError(err);
server1.tryShutdown(() => {
server2.bindAsync(`localhost:${port}`, serverCreds, (err) => {
assert.ifError(err);
server2.start();
const metadata = new clientGrpc.Metadata({ waitForReady: true });
client.unary({}, metadata, (err, data) => {
});
});
after(function() {
client.close();
server1.forceShutdown();
server2.forceShutdown();
});
it.skip('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;
function maybeDone() {
if (testDone && pendingCalls === 0) {
done();
}
};
client.unary({}, (err, data) => {
assert.ifError(err);
server1.tryShutdown(() => {
server2.bindAsync(`localhost:${port}`, serverCreds, (err) => {
assert.ifError(err);
clearInterval(callInterval);
testDone = true;
maybeDone();
server2.start();
const metadata = new clientGrpc.Metadata({ waitForReady: true });
client.unary({}, metadata, (err, data) => {
assert.ifError(err);
clearInterval(callInterval);
testDone = true;
maybeDone();
});
});
});
callInterval = setInterval(() => {
assert.strictEqual(testDone, false);
pendingCalls += 1;
client.unary({}, (err, data) => {
pendingCalls -= 1;
if (err) {
assert.strictEqual(err.code, clientGrpc.status.UNAVAILABLE);
}
maybeDone();
});
}, 0);
});
callInterval = setInterval(() => {
assert.strictEqual(testDone, false);
pendingCalls += 1;
client.unary({}, (err, data) => {
pendingCalls -= 1;
if (err) {
assert.strictEqual(err.code, clientGrpc.status.UNAVAILABLE);
}
maybeDone();
});
}, 0);
});
});
});
Loading

0 comments on commit fafe8fb

Please sign in to comment.