Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression tests for recent failures, move a test #1071

Merged
merged 4 commits into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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