/* Client sends a request with payload, server reads then returns a response
   payload and status. */
static void test_invoke_request_response_with_payload(
    grpc_end2end_test_config config) {
  grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
  request_response_with_payload(f);
  end_test(&f);
  config.tear_down_data(&f);
}
static void test_invoke_10_request_response_with_payload(
    grpc_end2end_test_config config) {
  int i;
  grpc_end2end_test_fixture f = begin_test(config, __FUNCTION__, NULL, NULL);
  for (i = 0; i < 10; i++) {
    request_response_with_payload(f);
  }
  end_test(&f);
  config.tear_down_data(&f);
}
Example #3
0
static void test_load_reporting_hook(grpc_end2end_test_config config) {
  /* TODO(dgq): this test is currently a noop until LR is fully defined.
   * Leaving the rest here, as it'll likely be reusable. */

  /* Introduce load reporting for the server through its arguments */
  grpc_arg arg = grpc_load_reporting_enable_arg();
  grpc_channel_args *lr_server_args =
      grpc_channel_args_copy_and_add(NULL, &arg, 1);

  grpc_end2end_test_fixture f =
      begin_test(config, "test_load_reporting_hook", NULL, lr_server_args);

  const char *method_name = "/gRPCFTW";
  const char *request_msg = "the msg from the client";
  const char *response_msg = "... and the response from the server";

  grpc_metadata initial_lr_metadata;
  grpc_metadata trailing_lr_metadata;

  initial_lr_metadata.key = GRPC_MDSTR_LB_TOKEN;
  initial_lr_metadata.value = grpc_slice_from_static_string("client-token");
  memset(&initial_lr_metadata.internal_data, 0,
         sizeof(initial_lr_metadata.internal_data));

  trailing_lr_metadata.key = GRPC_MDSTR_LB_COST_BIN;
  trailing_lr_metadata.value = grpc_slice_from_static_string("server-token");
  memset(&trailing_lr_metadata.internal_data, 0,
         sizeof(trailing_lr_metadata.internal_data));

  request_response_with_payload(config, f, method_name, request_msg,
                                response_msg, &initial_lr_metadata,
                                &trailing_lr_metadata);
  end_test(&f);
  {
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_channel_args_destroy(&exec_ctx, lr_server_args);
    grpc_exec_ctx_finish(&exec_ctx);
  }
  config.tear_down_data(&f);
}