Added remaining implementable node interop tests, except compression

pull/3746/head
murgatroid99 9 years ago
parent 30df27aee1
commit b8ceb7c550
  1. 78
      src/node/interop/interop_client.js
  2. 2
      src/node/src/server.js
  3. 8
      src/node/test/interop_sanity_test.js

@ -338,6 +338,41 @@ function customMetadata(client, done) {
stream.end(); stream.end();
} }
function statusCodeAndMessage(client, done) {
done = multiDone(done, 2);
var arg = {
response_status: {
code: 2,
message: "test status message"
}
};
client.unaryCall(arg, function(err, resp) {
assert(err);
assert.strictEqual(err.code, 2);
assert.strictEqual(err.message, "test status message");
done();
});
var duplex = client.fullDuplexCall();
duplex.on('status', function(status) {
assert(status);
assert.strictEqual(status.code, 2);
assert.strictEqual(status.details, "test status message");
done();
});
duplex.on('error', function(){});
duplex.write(arg);
duplex.end();
}
function unimplementedMethod(client, done) {
client.unimplementedCall({}, function(err, resp) {
assert(err);
assert.strictEqual(err.code, grpc.status.UNIMPLEMENTED);
assert(!err.message);
done();
});
}
/** /**
* Run one of the authentication tests. * Run one of the authentication tests.
* @param {string} expected_user The expected username in the response * @param {string} expected_user The expected username in the response
@ -459,25 +494,44 @@ function getOauth2Creds(scope, callback) {
* Map from test case names to test functions * Map from test case names to test functions
*/ */
var test_cases = { var test_cases = {
empty_unary: {run: emptyUnary}, empty_unary: {run: emptyUnary,
large_unary: {run: largeUnary}, Client: testProto.TestService},
client_streaming: {run: clientStreaming}, large_unary: {run: largeUnary,
server_streaming: {run: serverStreaming}, Client: testProto.TestService},
ping_pong: {run: pingPong}, client_streaming: {run: clientStreaming,
empty_stream: {run: emptyStream}, Client: testProto.TestService},
cancel_after_begin: {run: cancelAfterBegin}, server_streaming: {run: serverStreaming,
cancel_after_first_response: {run: cancelAfterFirstResponse}, Client: testProto.TestService},
timeout_on_sleeping_server: {run: timeoutOnSleepingServer}, ping_pong: {run: pingPong,
custom_metadata: {run: customMetadata}, Client: testProto.TestService},
empty_stream: {run: emptyStream,
Client: testProto.TestService},
cancel_after_begin: {run: cancelAfterBegin,
Client: testProto.TestService},
cancel_after_first_response: {run: cancelAfterFirstResponse,
Client: testProto.TestService},
timeout_on_sleeping_server: {run: timeoutOnSleepingServer,
Client: testProto.TestService},
custom_metadata: {run: customMetadata,
Client: testProto.TestService},
status_code_and_message: {run: statusCodeAndMessage,
Client: testProto.TestService},
unimplemented_method: {run: unimplementedMethod,
Client: testProto.UnimplementedService},
compute_engine_creds: {run: computeEngineCreds, compute_engine_creds: {run: computeEngineCreds,
Client: testProto.TestService,
getCreds: getApplicationCreds}, getCreds: getApplicationCreds},
service_account_creds: {run: serviceAccountCreds, service_account_creds: {run: serviceAccountCreds,
Client: testProto.TestService,
getCreds: getApplicationCreds}, getCreds: getApplicationCreds},
jwt_token_creds: {run: jwtTokenCreds, jwt_token_creds: {run: jwtTokenCreds,
Client: testProto.TestService,
getCreds: getApplicationCreds}, getCreds: getApplicationCreds},
oauth2_auth_token: {run: oauth2Test, oauth2_auth_token: {run: oauth2Test,
Client: testProto.TestService,
getCreds: getOauth2Creds}, getCreds: getOauth2Creds},
per_rpc_creds: {run: perRpcAuthTest} per_rpc_creds: {run: perRpcAuthTest,
Client: testProto.TestService}
}; };
/** /**
@ -516,7 +570,7 @@ function runTest(address, host_override, test_case, tls, test_ca, done, extra) {
var execute = function(err, creds) { var execute = function(err, creds) {
assert.ifError(err); assert.ifError(err);
var client = new testProto.TestService(address, creds, options); var client = new test.Client(address, creds, options);
test.run(client, done); test.run(client, done);
}; };

@ -629,7 +629,7 @@ function Server(options) {
(new Metadata())._getCoreRepresentation(); (new Metadata())._getCoreRepresentation();
batch[grpc.opType.SEND_STATUS_FROM_SERVER] = { batch[grpc.opType.SEND_STATUS_FROM_SERVER] = {
code: grpc.status.UNIMPLEMENTED, code: grpc.status.UNIMPLEMENTED,
details: 'This method is not available on this server.', details: '',
metadata: {} metadata: {}
}; };
batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true; batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true;

@ -94,4 +94,12 @@ describe('Interop tests', function() {
interop_client.runTest(port, name_override, 'custom_metadata', interop_client.runTest(port, name_override, 'custom_metadata',
true, true, done); true, true, done);
}); });
it('should pass status_code_and_message', function(done) {
interop_client.runTest(port, name_override, 'status_code_and_message',
true, true, done);
});
it('should pass unimplemented_method', function(done) {
interop_client.runTest(port, name_override, 'unimplemented_method',
true, true, done);
});
}); });

Loading…
Cancel
Save