More end to end test debugging

pull/504/head
murgatroid99 10 years ago
parent 7dcc363aa7
commit 7765906521
  1. 19
      src/node/ext/call.cc
  2. 4
      src/node/ext/call.h
  3. 11
      src/node/ext/completion_queue_async_worker.cc
  4. 2
      src/node/ext/server.cc
  5. 17
      src/node/test/end_to_end_test.js

@ -201,6 +201,8 @@ class SendMessageOp : public Op {
}
out->data.send_message = BufferToByteBuffer(value);
Persistent<Value> handle;
Handle<Value> temp = NanNew<Object>();
NanAssignPersistent(handle, temp);
NanAssignPersistent(handle, value);
handles->push_back(unique_ptr<PersistentHolder>(
new PersistentHolder(handle)));
@ -441,9 +443,14 @@ void DestroyTag(void *tag) {
delete tag_struct;
}
Call::Call(grpc_call *call) : wrapped_call(call) {}
Call::Call(grpc_call *call) : wrapped_call(call) {
gpr_log(GPR_DEBUG, "Constructing call, this: %p, pointer: %p", this, call);
}
Call::~Call() { grpc_call_destroy(wrapped_call); }
Call::~Call() {
gpr_log(GPR_DEBUG, "Destructing call, this: %p, pointer: %p", this, wrapped_call);
grpc_call_destroy(wrapped_call);
}
void Call::Init(Handle<Object> exports) {
NanScope();
@ -473,6 +480,7 @@ Handle<Value> Call::WrapStruct(grpc_call *call) {
if (call == NULL) {
return NanEscapeScope(NanNull());
}
gpr_log(GPR_DEBUG, "Wrapping call: %p", call);
const int argc = 1;
Handle<Value> argv[argc] = {External::New(reinterpret_cast<void *>(call))};
return NanEscapeScope(constructor->NewInstance(argc, argv));
@ -534,12 +542,13 @@ NAN_METHOD(Call::StartBatch) {
if (!args[1]->IsFunction()) {
return NanThrowError("startBatch's second argument must be a callback");
}
Handle<Function> callback_func = args[1].As<Function>();
NanCallback *callback = new NanCallback(callback_func);
Call *call = ObjectWrap::Unwrap<Call>(args.This());
std::vector<unique_ptr<PersistentHolder> > *handles =
new std::vector<unique_ptr<PersistentHolder> >();
std::vector<unique_ptr<NanUtf8String> > *strings =
new std::vector<unique_ptr<NanUtf8String> >();
Persistent<Value> handle;
Handle<Object> obj = args[0]->ToObject();
Handle<Array> keys = obj->GetOwnPropertyNames();
size_t nops = keys->Length();
@ -588,9 +597,7 @@ NAN_METHOD(Call::StartBatch) {
}
grpc_call_error error = grpc_call_start_batch(
call->wrapped_call, ops, nops, new struct tag(
new NanCallback(args[1].As<Function>()),
op_vector, handles,
strings));
callback, op_vector, handles, strings));
if (error != GRPC_CALL_OK) {
return NanThrowError("startBatch failed", error);
}

@ -57,8 +57,8 @@ class PersistentHolder {
}
~PersistentHolder() {
persist.Dispose();
}
NanDisposePersistent(persist);
}
private:
v8::Persistent<v8::Value> persist;

@ -35,6 +35,7 @@
#include <nan.h>
#include "grpc/grpc.h"
#include "grpc/support/log.h"
#include "grpc/support/time.h"
#include "completion_queue_async_worker.h"
#include "call.h"
@ -57,6 +58,7 @@ CompletionQueueAsyncWorker::~CompletionQueueAsyncWorker() {}
void CompletionQueueAsyncWorker::Execute() {
result = grpc_completion_queue_next(queue, gpr_inf_future);
gpr_log(GPR_DEBUG, "Handling response on call %p", result->call);
if (result->data.op_complete != GRPC_OP_OK) {
SetErrorMessage("The batch encountered an error");
}
@ -77,14 +79,15 @@ void CompletionQueueAsyncWorker::Init(Handle<Object> exports) {
void CompletionQueueAsyncWorker::HandleOKCallback() {
NanScope();
gpr_log(GPR_DEBUG, "Handling response on call %p", result->call);
NanCallback callback = GetTagCallback(result->tag);
Handle<Value> argv[] = {NanNull(), GetTagNodeValue(result->tag)};
callback.Call(2, argv);
DestroyTag(result->tag);
grpc_event_finish(result);
result = NULL;
callback.Call(2, argv);
}
void CompletionQueueAsyncWorker::HandleErrorCallback() {
@ -92,11 +95,11 @@ void CompletionQueueAsyncWorker::HandleErrorCallback() {
NanCallback callback = GetTagCallback(result->tag);
Handle<Value> argv[] = {NanError(ErrorMessage())};
callback.Call(1, argv);
DestroyTag(result->tag);
grpc_event_finish(result);
result = NULL;
callback.Call(1, argv);
}
} // namespace node

@ -43,6 +43,7 @@
#include <vector>
#include "grpc/grpc.h"
#include "grpc/grpc_security.h"
#include "grpc/support/log.h"
#include "call.h"
#include "completion_queue_async_worker.h"
#include "server_credentials.h"
@ -90,6 +91,7 @@ class NewCallOp : public Op {
return NanEscapeScope(NanNull());
}
Handle<Object> obj = NanNew<Object>();
gpr_log(GPR_DEBUG, "Wrapping server call: %p", call);
obj->Set(NanNew("call"), Call::WrapStruct(call));
obj->Set(NanNew("method"), NanNew(details.method));
obj->Set(NanNew("host"), NanNew(details.host));

@ -67,14 +67,14 @@ describe('end-to-end', function() {
after(function() {
server.shutdown();
});
it('should start and end a request without error', function(complete) {
it.skip('should start and end a request without error', function(complete) {
var done = multiDone(complete, 2);
var deadline = new Date();
deadline.setSeconds(deadline.getSeconds() + 3);
var status_text = 'xyz';
var call = new grpc.Call(channel,
'dummy_method',
deadline);
Infinity);
var client_batch = {};
client_batch[grpc.opType.SEND_INITIAL_METADATA] = {};
client_batch[grpc.opType.SEND_CLOSE_FROM_CLIENT] = true;
@ -85,6 +85,7 @@ describe('end-to-end', function() {
assert.deepEqual(response, {
'send metadata': true,
'client close': true,
'metadata': {},
'status': {
'code': grpc.status.OK,
'details': status_text,
@ -125,7 +126,7 @@ describe('end-to-end', function() {
var status_text = 'xyz';
var call = new grpc.Call(channel,
'dummy_method',
deadline);
Infinity);
var client_batch = {};
client_batch[grpc.opType.SEND_INITIAL_METADATA] = {
'client_key': ['client_value']
@ -138,7 +139,7 @@ describe('end-to-end', function() {
assert(response['send metadata']);
assert(response['client close']);
assert(response.hasOwnProperty('metadata'));
assert.strictEqual(response.metadata.server_key.toString(),
assert.strictEqual(response.metadata.server_key[0].toString(),
'server_value');
assert.deepEqual(response.status, {'code': grpc.status.OK,
'details': status_text,
@ -147,6 +148,7 @@ describe('end-to-end', function() {
});
server.requestCall(function(err, call_details) {
console.log("Server received new call");
var new_call = call_details['new call'];
assert.notEqual(new_call, null);
assert.strictEqual(new_call.metadata.client_key[0].toString(),
@ -174,7 +176,7 @@ describe('end-to-end', function() {
});
});
});
it.only('should send and receive data without error', function(complete) {
it('should send and receive data without error', function(complete) {
var req_text = 'client_request';
var reply_text = 'server_response';
var done = multiDone(complete, 2);
@ -183,7 +185,7 @@ describe('end-to-end', function() {
var status_text = 'success';
var call = new grpc.Call(channel,
'dummy_method',
deadline);
Infinity);
var client_batch = {};
client_batch[grpc.opType.SEND_INITIAL_METADATA] = {};
client_batch[grpc.opType.SEND_MESSAGE] = new Buffer(req_text);
@ -201,7 +203,6 @@ describe('end-to-end', function() {
assert.deepEqual(response.status, {'code': grpc.status.OK,
'details': status_text,
'metadata': {}});
console.log("OK status");
done();
});
@ -227,7 +228,7 @@ describe('end-to-end', function() {
response_batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true;
server_call.startBatch(response_batch, function(err, response) {
assert(response['send status']);
//assert(!response['cancelled']);
assert(!response['cancelled']);
done();
});
});

Loading…
Cancel
Save