|
|
@ -404,18 +404,18 @@ describe('Echo metadata', function() { |
|
|
|
server.forceShutdown(); |
|
|
|
server.forceShutdown(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('with unary call', function(done) { |
|
|
|
it('with unary call', function(done) { |
|
|
|
var call = client.unary({}, function(err, data) { |
|
|
|
var call = client.unary({}, metadata, function(err, data) { |
|
|
|
assert.ifError(err); |
|
|
|
assert.ifError(err); |
|
|
|
}, metadata); |
|
|
|
}); |
|
|
|
call.on('metadata', function(metadata) { |
|
|
|
call.on('metadata', function(metadata) { |
|
|
|
assert.deepEqual(metadata.get('key'), ['value']); |
|
|
|
assert.deepEqual(metadata.get('key'), ['value']); |
|
|
|
done(); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('with client stream call', function(done) { |
|
|
|
it('with client stream call', function(done) { |
|
|
|
var call = client.clientStream(function(err, data) { |
|
|
|
var call = client.clientStream(metadata, function(err, data) { |
|
|
|
assert.ifError(err); |
|
|
|
assert.ifError(err); |
|
|
|
}, metadata); |
|
|
|
}); |
|
|
|
call.on('metadata', function(metadata) { |
|
|
|
call.on('metadata', function(metadata) { |
|
|
|
assert.deepEqual(metadata.get('key'), ['value']); |
|
|
|
assert.deepEqual(metadata.get('key'), ['value']); |
|
|
|
done(); |
|
|
|
done(); |
|
|
@ -441,8 +441,8 @@ describe('Echo metadata', function() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('shows the correct user-agent string', function(done) { |
|
|
|
it('shows the correct user-agent string', function(done) { |
|
|
|
var version = require('../../../package.json').version; |
|
|
|
var version = require('../../../package.json').version; |
|
|
|
var call = client.unary({}, function(err, data) { assert.ifError(err); }, |
|
|
|
var call = client.unary({}, metadata, |
|
|
|
metadata); |
|
|
|
function(err, data) { assert.ifError(err); }); |
|
|
|
call.on('metadata', function(metadata) { |
|
|
|
call.on('metadata', function(metadata) { |
|
|
|
assert(_.startsWith(metadata.get('user-agent')[0], |
|
|
|
assert(_.startsWith(metadata.get('user-agent')[0], |
|
|
|
'grpc-node/' + version)); |
|
|
|
'grpc-node/' + version)); |
|
|
@ -452,8 +452,8 @@ describe('Echo metadata', function() { |
|
|
|
it('properly handles duplicate values', function(done) { |
|
|
|
it('properly handles duplicate values', function(done) { |
|
|
|
var dup_metadata = metadata.clone(); |
|
|
|
var dup_metadata = metadata.clone(); |
|
|
|
dup_metadata.add('key', 'value2'); |
|
|
|
dup_metadata.add('key', 'value2'); |
|
|
|
var call = client.unary({}, function(err, data) {assert.ifError(err); }, |
|
|
|
var call = client.unary({}, dup_metadata, |
|
|
|
dup_metadata); |
|
|
|
function(err, data) {assert.ifError(err); }); |
|
|
|
call.on('metadata', function(resp_metadata) { |
|
|
|
call.on('metadata', function(resp_metadata) { |
|
|
|
// Two arrays are equal iff their symmetric difference is empty
|
|
|
|
// Two arrays are equal iff their symmetric difference is empty
|
|
|
|
assert.deepEqual(_.xor(dup_metadata.get('key'), resp_metadata.get('key')), |
|
|
|
assert.deepEqual(_.xor(dup_metadata.get('key'), resp_metadata.get('key')), |
|
|
@ -954,7 +954,7 @@ describe('Call propagation', function() { |
|
|
|
done = multiDone(done, 2); |
|
|
|
done = multiDone(done, 2); |
|
|
|
var call; |
|
|
|
var call; |
|
|
|
proxy_impl.unary = function(parent, callback) { |
|
|
|
proxy_impl.unary = function(parent, callback) { |
|
|
|
client.unary(parent.request, function(err, value) { |
|
|
|
client.unary(parent.request, {parent: parent}, function(err, value) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
assert(err); |
|
|
|
assert(err); |
|
|
|
assert.strictEqual(err.code, grpc.status.CANCELLED); |
|
|
|
assert.strictEqual(err.code, grpc.status.CANCELLED); |
|
|
@ -962,7 +962,7 @@ describe('Call propagation', function() { |
|
|
|
callback(err, value); |
|
|
|
callback(err, value); |
|
|
|
done(); |
|
|
|
done(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, null, {parent: parent}); |
|
|
|
}); |
|
|
|
call.cancel(); |
|
|
|
call.cancel(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
proxy.addProtoService(test_service, proxy_impl); |
|
|
|
proxy.addProtoService(test_service, proxy_impl); |
|
|
@ -976,7 +976,7 @@ describe('Call propagation', function() { |
|
|
|
done = multiDone(done, 2); |
|
|
|
done = multiDone(done, 2); |
|
|
|
var call; |
|
|
|
var call; |
|
|
|
proxy_impl.clientStream = function(parent, callback) { |
|
|
|
proxy_impl.clientStream = function(parent, callback) { |
|
|
|
client.clientStream(function(err, value) { |
|
|
|
client.clientStream({parent: parent}, function(err, value) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
assert(err); |
|
|
|
assert(err); |
|
|
|
assert.strictEqual(err.code, grpc.status.CANCELLED); |
|
|
|
assert.strictEqual(err.code, grpc.status.CANCELLED); |
|
|
@ -984,7 +984,7 @@ describe('Call propagation', function() { |
|
|
|
callback(err, value); |
|
|
|
callback(err, value); |
|
|
|
done(); |
|
|
|
done(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, null, {parent: parent}); |
|
|
|
}); |
|
|
|
call.cancel(); |
|
|
|
call.cancel(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
proxy.addProtoService(test_service, proxy_impl); |
|
|
|
proxy.addProtoService(test_service, proxy_impl); |
|
|
@ -998,8 +998,7 @@ describe('Call propagation', function() { |
|
|
|
done = multiDone(done, 2); |
|
|
|
done = multiDone(done, 2); |
|
|
|
var call; |
|
|
|
var call; |
|
|
|
proxy_impl.serverStream = function(parent) { |
|
|
|
proxy_impl.serverStream = function(parent) { |
|
|
|
var child = client.serverStream(parent.request, null, |
|
|
|
var child = client.serverStream(parent.request, {parent: parent}); |
|
|
|
{parent: parent}); |
|
|
|
|
|
|
|
child.on('data', function() {}); |
|
|
|
child.on('data', function() {}); |
|
|
|
child.on('error', function(err) { |
|
|
|
child.on('error', function(err) { |
|
|
|
assert(err); |
|
|
|
assert(err); |
|
|
@ -1023,7 +1022,7 @@ describe('Call propagation', function() { |
|
|
|
done = multiDone(done, 2); |
|
|
|
done = multiDone(done, 2); |
|
|
|
var call; |
|
|
|
var call; |
|
|
|
proxy_impl.bidiStream = function(parent) { |
|
|
|
proxy_impl.bidiStream = function(parent) { |
|
|
|
var child = client.bidiStream(null, {parent: parent}); |
|
|
|
var child = client.bidiStream({parent: parent}); |
|
|
|
child.on('data', function() {}); |
|
|
|
child.on('data', function() {}); |
|
|
|
child.on('error', function(err) { |
|
|
|
child.on('error', function(err) { |
|
|
|
assert(err); |
|
|
|
assert(err); |
|
|
@ -1051,7 +1050,8 @@ describe('Call propagation', function() { |
|
|
|
it('With a client stream call', function(done) { |
|
|
|
it('With a client stream call', function(done) { |
|
|
|
done = multiDone(done, 2); |
|
|
|
done = multiDone(done, 2); |
|
|
|
proxy_impl.clientStream = function(parent, callback) { |
|
|
|
proxy_impl.clientStream = function(parent, callback) { |
|
|
|
client.clientStream(function(err, value) { |
|
|
|
var options = {parent: parent, propagate_flags: deadline_flags}; |
|
|
|
|
|
|
|
client.clientStream(options, function(err, value) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
assert(err); |
|
|
|
assert(err); |
|
|
|
assert(err.code === grpc.status.DEADLINE_EXCEEDED || |
|
|
|
assert(err.code === grpc.status.DEADLINE_EXCEEDED || |
|
|
@ -1060,7 +1060,7 @@ describe('Call propagation', function() { |
|
|
|
callback(err, value); |
|
|
|
callback(err, value); |
|
|
|
done(); |
|
|
|
done(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, null, {parent: parent, propagate_flags: deadline_flags}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
proxy.addProtoService(test_service, proxy_impl); |
|
|
|
proxy.addProtoService(test_service, proxy_impl); |
|
|
|
var proxy_port = proxy.bind('localhost:0', server_insecure_creds); |
|
|
|
var proxy_port = proxy.bind('localhost:0', server_insecure_creds); |
|
|
@ -1069,15 +1069,15 @@ describe('Call propagation', function() { |
|
|
|
grpc.credentials.createInsecure()); |
|
|
|
grpc.credentials.createInsecure()); |
|
|
|
var deadline = new Date(); |
|
|
|
var deadline = new Date(); |
|
|
|
deadline.setSeconds(deadline.getSeconds() + 1); |
|
|
|
deadline.setSeconds(deadline.getSeconds() + 1); |
|
|
|
proxy_client.clientStream(function(err, value) { |
|
|
|
proxy_client.clientStream({deadline: deadline}, function(err, value) { |
|
|
|
done(); |
|
|
|
done(); |
|
|
|
}, null, {deadline: deadline}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('With a bidi stream call', function(done) { |
|
|
|
it('With a bidi stream call', function(done) { |
|
|
|
done = multiDone(done, 2); |
|
|
|
done = multiDone(done, 2); |
|
|
|
proxy_impl.bidiStream = function(parent) { |
|
|
|
proxy_impl.bidiStream = function(parent) { |
|
|
|
var child = client.bidiStream( |
|
|
|
var child = client.bidiStream( |
|
|
|
null, {parent: parent, propagate_flags: deadline_flags}); |
|
|
|
{parent: parent, propagate_flags: deadline_flags}); |
|
|
|
child.on('data', function() {}); |
|
|
|
child.on('data', function() {}); |
|
|
|
child.on('error', function(err) { |
|
|
|
child.on('error', function(err) { |
|
|
|
assert(err); |
|
|
|
assert(err); |
|
|
@ -1093,7 +1093,7 @@ describe('Call propagation', function() { |
|
|
|
grpc.credentials.createInsecure()); |
|
|
|
grpc.credentials.createInsecure()); |
|
|
|
var deadline = new Date(); |
|
|
|
var deadline = new Date(); |
|
|
|
deadline.setSeconds(deadline.getSeconds() + 1); |
|
|
|
deadline.setSeconds(deadline.getSeconds() + 1); |
|
|
|
var call = proxy_client.bidiStream(null, {deadline: deadline}); |
|
|
|
var call = proxy_client.bidiStream({deadline: deadline}); |
|
|
|
call.on('data', function() {}); |
|
|
|
call.on('data', function() {}); |
|
|
|
call.on('error', function(err) { |
|
|
|
call.on('error', function(err) { |
|
|
|
done(); |
|
|
|
done(); |
|
|
|