mirror of https://github.com/grpc/grpc-node.git
Modified interop tests to handle binding to port 0
This commit is contained in:
parent
44220eb996
commit
61d9ffb231
|
@ -157,7 +157,8 @@ function handleHalfDuplex(call) {
|
||||||
* Get a server object bound to the given port
|
* Get a server object bound to the given port
|
||||||
* @param {string} port Port to which to bind
|
* @param {string} port Port to which to bind
|
||||||
* @param {boolean} tls Indicates that the bound port should use TLS
|
* @param {boolean} tls Indicates that the bound port should use TLS
|
||||||
* @return {Server} Server object bound to the support
|
* @return {{server: Server, port: number}} Server object bound to the support,
|
||||||
|
* and port number that the server is bound to
|
||||||
*/
|
*/
|
||||||
function getServer(port, tls) {
|
function getServer(port, tls) {
|
||||||
// TODO(mlumish): enable TLS functionality
|
// TODO(mlumish): enable TLS functionality
|
||||||
|
@ -183,8 +184,8 @@ function getServer(port, tls) {
|
||||||
halfDuplexCall: handleHalfDuplex
|
halfDuplexCall: handleHalfDuplex
|
||||||
}
|
}
|
||||||
}, options);
|
}, options);
|
||||||
server.bind('0.0.0.0:' + port, tls);
|
var port_num = server.bind('0.0.0.0:' + port, tls);
|
||||||
return server;
|
return {server: server, port: port_num};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
|
@ -192,8 +193,8 @@ if (require.main === module) {
|
||||||
var argv = parseArgs(process.argv, {
|
var argv = parseArgs(process.argv, {
|
||||||
string: ['port', 'use_tls']
|
string: ['port', 'use_tls']
|
||||||
});
|
});
|
||||||
var server = getServer(argv.port, argv.use_tls === 'true');
|
var server_obj = getServer(argv.port, argv.use_tls === 'true');
|
||||||
server.start();
|
server_obj.server.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,8 +34,6 @@
|
||||||
var interop_server = require('../interop/interop_server.js');
|
var interop_server = require('../interop/interop_server.js');
|
||||||
var interop_client = require('../interop/interop_client.js');
|
var interop_client = require('../interop/interop_client.js');
|
||||||
|
|
||||||
var port_picker = require('../port_picker');
|
|
||||||
|
|
||||||
var server;
|
var server;
|
||||||
|
|
||||||
var port;
|
var port;
|
||||||
|
@ -44,12 +42,11 @@ var name_override = 'foo.test.google.com';
|
||||||
|
|
||||||
describe('Interop tests', function() {
|
describe('Interop tests', function() {
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
port_picker.nextAvailablePort(function(addr) {
|
var server_obj = interop_server.getServer(0, true);
|
||||||
server = interop_server.getServer(addr.substring(addr.indexOf(':') + 1), true);
|
server = server_obj.server;
|
||||||
server.listen();
|
server.listen();
|
||||||
port = addr;
|
port = 'localhost:' + server_obj.port;
|
||||||
done();
|
done();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
// This depends on not using a binary stream
|
// This depends on not using a binary stream
|
||||||
it.skip('should pass empty_unary', function(done) {
|
it.skip('should pass empty_unary', function(done) {
|
||||||
|
|
Loading…
Reference in New Issue