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();
}
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.
* @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
*/
var test_cases = {
empty_unary: {run: emptyUnary},
large_unary: {run: largeUnary},
client_streaming: {run: clientStreaming},
server_streaming: {run: serverStreaming},
ping_pong: {run: pingPong},
empty_stream: {run: emptyStream},
cancel_after_begin: {run: cancelAfterBegin},
cancel_after_first_response: {run: cancelAfterFirstResponse},
timeout_on_sleeping_server: {run: timeoutOnSleepingServer},
custom_metadata: {run: customMetadata},
empty_unary: {run: emptyUnary,
Client: testProto.TestService},
large_unary: {run: largeUnary,
Client: testProto.TestService},
client_streaming: {run: clientStreaming,
Client: testProto.TestService},
server_streaming: {run: serverStreaming,
Client: testProto.TestService},
ping_pong: {run: pingPong,
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,
Client: testProto.TestService,
getCreds: getApplicationCreds},
service_account_creds: {run: serviceAccountCreds,
Client: testProto.TestService,
getCreds: getApplicationCreds},
jwt_token_creds: {run: jwtTokenCreds,
Client: testProto.TestService,
getCreds: getApplicationCreds},
oauth2_auth_token: {run: oauth2Test,
Client: testProto.TestService,
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) {
assert.ifError(err);
var client = new testProto.TestService(address, creds, options);
var client = new test.Client(address, creds, options);
test.run(client, done);
};

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

@ -94,4 +94,12 @@ describe('Interop tests', function() {
interop_client.runTest(port, name_override, 'custom_metadata',
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