Exemplo n.º 1
0
static void run_test(const char *response_payload,
                     size_t response_payload_length,
                     grpc_status_code expected_status,
                     const char *expected_detail) {
  test_tcp_server test_server;
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
  gpr_event ev;

  grpc_init();
  gpr_event_init(&ev);
  server_port = grpc_pick_unused_port_or_die();
  test_tcp_server_init(&test_server, on_connect, &test_server);
  test_tcp_server_start(&test_server, server_port);
  state.response_payload = response_payload;
  state.response_payload_length = response_payload_length;

  /* poll server until sending out the response */
  poll_server_until_read_done(&test_server, &ev);
  start_rpc(server_port, expected_status, expected_detail);
  gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME));

  /* clean up */
  grpc_endpoint_shutdown(&exec_ctx, state.tcp);
  grpc_endpoint_destroy(&exec_ctx, state.tcp);
  grpc_exec_ctx_finish(&exec_ctx);
  cleanup_rpc();
  test_tcp_server_destroy(&test_server);

  grpc_shutdown();
}
Exemplo n.º 2
0
void reconnect_server_init(reconnect_server *server) {
  test_tcp_server_init(&server->tcp_server, on_connect, server);
  server->head = NULL;
  server->tail = NULL;
  server->peer = NULL;
  server->max_reconnect_backoff_ms = 0;
}
static void run_test(void (*test)(test_tcp_server *server, int secure),
                     int secure) {
  test_tcp_server test_server;
  server_port = grpc_pick_unused_port_or_die();
  test_tcp_server_init(&test_server, on_connect, &test_server);
  test_tcp_server_start(&test_server, server_port);
  test(&test_server, secure);
  test_tcp_server_destroy(&test_server);
}
Exemplo n.º 4
0
void reconnect_server_init(reconnect_server *server) {
  test_tcp_server_init(&server->tcp_server, on_connect, server);
  server->head = NULL;
  server->tail = NULL;
  server->peer = NULL;
}