fix api_fuzzer for srv request

PiperOrigin-RevId: 650375294
pull/37143/head
Yijie Ma 5 months ago committed by Copybara-Service
parent 549460839b
commit f8fa4152b6
  1. 24
      test/core/end2end/fuzzers/api_fuzzer.cc
  2. 14
      test/core/end2end/fuzzers/api_fuzzer_corpus/testcase-6068690547703808

@ -212,7 +212,7 @@ class FuzzerDNSResolver : public grpc_core::DNSResolver {
} // namespace
grpc_ares_request* my_dns_lookup_ares(
grpc_ares_request* my_dns_lookup_hostname_ares(
const char* /*dns_server*/, const char* addr, const char* /*default_port*/,
grpc_pollset_set* /*interested_parties*/, grpc_closure* on_done,
std::unique_ptr<grpc_core::EndpointAddressesList>* addresses,
@ -229,8 +229,25 @@ grpc_ares_request* my_dns_lookup_ares(
return nullptr;
}
grpc_ares_request* my_dns_lookup_srv_ares(
const char* /*dns_server*/, const char* name,
grpc_pollset_set* /*interested_parties*/, grpc_closure* on_done,
std::unique_ptr<grpc_core::EndpointAddressesList>* balancer_addresses,
int /*query_timeout*/) {
addr_req r;
r.addr = gpr_strdup(name);
r.on_done = on_done;
r.addresses = balancer_addresses;
GetDefaultEventEngine()->RunAfter(grpc_core::Duration::Seconds(1), [r] {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
finish_resolve(r);
});
return nullptr;
}
static void my_cancel_ares_request(grpc_ares_request* request) {
CHECK_EQ(request, nullptr);
CHECK_NE(request, nullptr);
}
////////////////////////////////////////////////////////////////////////////////
@ -400,7 +417,8 @@ namespace testing {
ApiFuzzer::ApiFuzzer(const fuzzing_event_engine::Actions& actions)
: BasicFuzzer(actions) {
ResetDNSResolver(std::make_unique<FuzzerDNSResolver>(engine().get()));
grpc_dns_lookup_hostname_ares = my_dns_lookup_ares;
grpc_dns_lookup_hostname_ares = my_dns_lookup_hostname_ares;
grpc_dns_lookup_srv_ares = my_dns_lookup_srv_ares;
grpc_cancel_ares_request = my_cancel_ares_request;
CHECK_EQ(channel_, nullptr);

@ -0,0 +1,14 @@
actions {
create_channel {
target: "ugsix: "
channel_args {
args {
key: "grpc.dns_enable_srv_queries"
i: 101097569197329
}
}
}
}
actions {
check_connectivity: true
}
Loading…
Cancel
Save