diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-04-28 15:14:40 -0700 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-04-28 15:14:40 -0700 |
commit | 3b05a123c4437a5ebb603d4829a141aad9b651aa (patch) | |
tree | 56f2f0b8b97dbbf8abeae5d1be30bc197091903f /test/core/end2end | |
parent | 8b1d98998b52177c76da9908e87c407e3184269c (diff) |
Test progress
Diffstat (limited to 'test/core/end2end')
-rw-r--r-- | test/core/end2end/tests/max_concurrent_streams.c | 145 |
1 files changed, 109 insertions, 36 deletions
diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index a8245e31f2..c693ff8053 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -204,6 +204,18 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { cq_verifier *v_client; cq_verifier *v_server; grpc_event *ev; + grpc_call_details call_details; + grpc_metadata_array request_metadata_recv; + grpc_metadata_array initial_metadata_recv1; + grpc_metadata_array trailing_metadata_recv1; + grpc_metadata_array initial_metadata_recv2; + grpc_metadata_array trailing_metadata_recv2; + grpc_status_code status1; + char *details1 = NULL; + size_t details_capacity1 = 0; + grpc_status_code status2; + char *details2 = NULL; + size_t details_capacity2 = 0; server_arg.key = GRPC_ARG_MAX_CONCURRENT_STREAMS; server_arg.type = GRPC_ARG_INTEGER; @@ -216,6 +228,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { v_client = cq_verifier_create(f.client_cq); v_server = cq_verifier_create(f.server_cq); + grpc_metadata_array_init(&request_metadata_recv); + /* perform a ping-pong to ensure that settings have had a chance to round trip */ simple_request_body(f); @@ -225,68 +239,127 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { /* start two requests - ensuring that the second is not accepted until the first completes */ deadline = five_seconds_time(); - c1 = grpc_channel_create_call_old(f.client, "/alpha", "foo.test.google.fr", - deadline); - GPR_ASSERT(c1); - c2 = grpc_channel_create_call_old(f.client, "/beta", "foo.test.google.fr", - deadline); + c1 = grpc_channel_create_call(f.client, f.client_cq, "/alpha", + "foo.test.google.fr:1234", deadline); GPR_ASSERT(c1); + c2 = grpc_channel_create_call(f.client, f.client_cq, "/beta", + "foo.test.google.fr:1234", deadline); + GPR_ASSERT(c2); - GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(100))); + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s1, + &call_details, + &request_metadata_recv, + f.server_cq, tag(101))); - GPR_ASSERT(GRPC_CALL_OK == - grpc_call_invoke_old(c1, f.client_cq, tag(301), tag(302), 0)); - GPR_ASSERT(GRPC_CALL_OK == - grpc_call_invoke_old(c2, f.client_cq, tag(401), tag(402), 0)); - GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done_old(c1, tag(303))); - GPR_ASSERT(GRPC_CALL_OK == grpc_call_writes_done_old(c2, tag(403))); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op++; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata = &initial_metadata_recv; + op++; + GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c1, ops, op - ops, tag(301))); + + op = ops; + op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; + op->data.recv_status_on_client.status = &status; + op->data.recv_status_on_client.status_details = &details; + op->data.recv_status_on_client.status_details_capacity = &details_capacity; + op++; + GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c1, ops, op - ops, tag(302))); + + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op++; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata = &initial_metadata_recv; + op++; + op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; + op->data.recv_status_on_client.status = &status; + op->data.recv_status_on_client.status_details = &details; + op->data.recv_status_on_client.status_details_capacity = &details_capacity; + op++; + GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c2, ops, op - ops, tag(401))); + + op = ops; + op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; + op->data.recv_status_on_client.status = &status; + op->data.recv_status_on_client.status_details = &details; + op->data.recv_status_on_client.status_details_capacity = &details_capacity; + op++; + GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c2, ops, op - ops, tag(402))); ev = grpc_completion_queue_next( f.client_cq, gpr_time_add(gpr_now(), gpr_time_from_seconds(10))); GPR_ASSERT(ev); - GPR_ASSERT(ev->type == GRPC_FINISH_ACCEPTED); - GPR_ASSERT(ev->data.invoke_accepted == GRPC_OP_OK); + GPR_ASSERT(ev->type == GRPC_OP_COMPLETE); + GPR_ASSERT(ev->data.op_complete == GRPC_OP_OK); + GPR_ASSERT(ev->data.tag == tag(301) || ev->data.tag == tag(401)); /* The /alpha or /beta calls started above could be invoked (but NOT both); * check this here */ /* We'll get tag 303 or 403, we want 300, 400 */ - live_call = ((int)(gpr_intptr) ev->tag) - 3; + live_call = ((int)(gpr_intptr) ev->tag) - 1; grpc_event_finish(ev); - cq_expect_server_rpc_new(v_server, &s1, tag(100), - live_call == 300 ? "/alpha" : "/beta", - "foo.test.google.fr", deadline, NULL); + cq_expect_completion(v_server, tag(100), GRPC_OP_OK); cq_verify(v_server); - GPR_ASSERT(GRPC_CALL_OK == - grpc_call_server_accept_old(s1, f.server_cq, tag(102))); - GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata_old(s1, 0)); - cq_expect_client_metadata_read(v_client, tag(live_call + 1), NULL); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op++; + op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op->data.recv_close_on_server.cancelled = &was_cancelled; + op++; + GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102))); + + cq_expect_completion(v_client, tag(live_call + 1), NULL); cq_verify(v_client); - GPR_ASSERT(GRPC_CALL_OK == - grpc_call_start_write_status_old(s1, GRPC_STATUS_UNIMPLEMENTED, - "xyz", tag(103))); - cq_expect_finish_accepted(v_server, tag(103), GRPC_OP_OK); - cq_expect_finished(v_server, tag(102), NULL); + op = ops; + op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; + op->data.send_status_from_server.trailing_metadata_count = 0; + op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; + op->data.send_status_from_server.status_details = "xyz"; + op++; + GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(103))); + + cq_expect_completion(v_server, tag(103), GRPC_OP_OK); cq_verify(v_server); /* first request is finished, we should be able to start the second */ - cq_expect_finished_with_status(v_client, tag(live_call + 2), - GRPC_STATUS_UNIMPLEMENTED, "xyz", NULL); + cq_expect_completion(v_client, tag(live_call + 2), GRPC_OP_OK); live_call = (live_call == 300) ? 400 : 300; - cq_expect_finish_accepted(v_client, tag(live_call + 3), GRPC_OP_OK); + cq_expect_completion(v_client, tag(live_call + 3), GRPC_OP_OK); cq_verify(v_client); - GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call_old(f.server, tag(200))); - cq_expect_server_rpc_new(v_server, &s2, tag(200), + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(f.server, &s1, + &call_details, + &request_metadata_recv, + f.server_cq, tag(201))); + cq_expect_server_rpc_new(v_server, &s2, tag(201), live_call == 300 ? "/alpha" : "/beta", "foo.test.google.fr", deadline, NULL); cq_verify(v_server); - GPR_ASSERT(GRPC_CALL_OK == - grpc_call_server_accept_old(s2, f.server_cq, tag(202))); - GPR_ASSERT(GRPC_CALL_OK == grpc_call_server_end_initial_metadata_old(s2, 0)); - cq_expect_client_metadata_read(v_client, tag(live_call + 1), NULL); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op++; + op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op->data.recv_close_on_server.cancelled = &was_cancelled; + op++; + GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(202))); + + cq_expect_completion(v_client, tag(live_call + 1), NULL); cq_verify(v_client); GPR_ASSERT(GRPC_CALL_OK == |