Go to the documentation of this file.
21 #include <gmock/gmock.h>
22 #include <gtest/gtest.h>
24 #include "absl/strings/str_format.h"
72 ~HttpsCliTest()
override {
92 while (!predicate()) {
97 &
worker, NSecondsTime(1))));
109 g_argc, g_argv,
true );
127 struct RequestState {
128 explicit RequestState(HttpsCliTest*
test) :
test(
test) {}
141 RequestState* request_state =
static_cast<RequestState*
>(
arg);
143 "<html><head><title>Hello world!</title></head>"
144 "<body><p>This is a test</p></body></html>";
152 request_state->test->RunAndKick(
153 [request_state]() { request_state->done =
true; });
157 RequestState* request_state =
static_cast<RequestState*
>(
arg);
162 request_state->test->RunAndKick(
163 [request_state]() { request_state->done =
true; });
167 RequestState request_state(
this);
175 const_cast<char*
>(
"foo.test.google.fr"));
184 grpc_schedule_on_exec_ctx),
185 &request_state.response,
187 http_request->Start();
188 PollUntil([&request_state]() {
return request_state.done; },
189 AbslDeadlineSeconds(60));
192 TEST_F(HttpsCliTest, Post) {
193 RequestState request_state(
this);
199 req.body =
const_cast<char*
>(
"hello");
203 const_cast<char*
>(
"foo.test.google.fr"));
213 grpc_schedule_on_exec_ctx),
214 &request_state.response,
216 http_request->Start();
217 PollUntil([&request_state]() {
return request_state.done; },
218 AbslDeadlineSeconds(60));
226 TEST_F(HttpsCliTest, CancelGetDuringSSLHandshake) {
231 kWaitForClientToSendFirstBytes,
235 std::vector<std::thread>
threads;
241 RequestState request_state(
this);
247 const_cast<char*
>(
"foo.test.google.fr"));
250 "https", fake_http_server_ptr->
address(),
"/get",
256 grpc_schedule_on_exec_ctx),
257 &request_state.response,
263 http_request->Start();
270 http_request.reset();
274 PollUntil([&request_state]() {
return request_state.done; },
275 AbslDeadlineSeconds(60));
276 cancel_thread.join();
286 int main(
int argc,
char** argv) {
struct grpc_pollset_worker grpc_pollset_worker
std::chrono::duration< std::int_fast64_t > seconds
size_t grpc_pollset_size(void)
GPRAPI void gpr_mu_unlock(gpr_mu *mu)
grpc_pollset * grpc_polling_entity_pollset(grpc_polling_entity *pollent)
gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s)
absl::Time ToAbslTime(gpr_timespec ts)
return memset(p, 0, total)
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec< Args... > &format, const Args &... args)
static void SetUpTestSuite()
GPRAPI void gpr_free(void *ptr)
grpc_error_handle grpc_pollset_work(grpc_pollset *pollset, grpc_pollset_worker **worker, grpc_core::Timestamp deadline)
#define GRPC_LOG_IF_ERROR(what, error)
grpc_arg grpc_channel_arg_string_create(char *name, char *value)
static OrphanablePtr< HttpRequest > Post(URI uri, const grpc_channel_args *args, grpc_polling_entity *pollent, const grpc_http_request *request, Timestamp deadline, grpc_closure *on_done, grpc_http_response *response, RefCountedPtr< grpc_channel_credentials > channel_creds) GRPC_MUST_USE_RESULT
#define GRPC_CLOSURE_CREATE(cb, cb_arg, scheduler)
RefCountedPtr< grpc_channel_credentials > CreateHttpRequestSSLCredentials()
static uv_thread_t * threads
void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu)
GPRAPI void * gpr_zalloc(size_t size)
static GraphId Get(const IdMap &id, int num)
int main(int argc, char **argv)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG
def c_str(s, encoding='ascii')
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc_polling_entity grpc_polling_entity_create_from_pollset(grpc_pollset *pollset)
GPRAPI void gpr_sleep_until(gpr_timespec until)
GPRAPI void gpr_mu_lock(gpr_mu *mu)
void grpc_http_response_destroy(grpc_http_response *response)
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
grpc_error_handle grpc_pollset_kick(grpc_pollset *pollset, grpc_pollset_worker *specific_worker)
struct gpr_subprocess gpr_subprocess
ABSL_NAMESPACE_BEGIN Time Now()
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
static OrphanablePtr< HttpRequest > Get(URI uri, const grpc_channel_args *args, grpc_polling_entity *pollent, const grpc_http_request *request, Timestamp deadline, grpc_closure *on_done, grpc_http_response *response, RefCountedPtr< grpc_channel_credentials > channel_creds) GRPC_MUST_USE_RESULT
static void TearDownTestSuite()
grpc_core::ExecCtx exec_ctx
std::string grpc_error_std_string(grpc_error_handle error)
void grpc_pollset_shutdown(grpc_pollset *pollset, grpc_closure *closure)
static absl::StatusOr< URI > Create(std::string scheme, std::string authority, std::string path, std::vector< QueryParam > query_parameter_pairs, std::string fragment)
std::unique_ptr< T, Deleter > OrphanablePtr
static grpc_server * g_server
void gpr_subprocess_destroy(gpr_subprocess *p)
static ProcessReadResult CloseSocketUponCloseFromPeer(int bytes_received_size, int read_error, int s)
HttpRequestTestServer StartHttpRequestTestServer(int argc, char **argv, bool use_ssl)
GRPCAPI void grpc_init(void)
static Timestamp FromTimespecRoundUp(gpr_timespec t)
void grpc_pollset_destroy(grpc_pollset *pollset)
GRPCAPI void grpc_shutdown(void)
static uv_thread_t thread
#define GRPC_ERROR_IS_NONE(err)
#define TEST_F(test_fixture, test_name)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:14