xds_client_fuzzer: fix send message on a stream that does not exist yet (#31648)

pull/31636/head
Mark D. Roth 2 years ago committed by GitHub
parent 47b9a57de9
commit 2ff54946ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      test/core/xds/xds_client_corpora/send_message_to_client_before_stream_created
  2. 6
      test/core/xds/xds_transport_fake.cc

@ -0,0 +1,9 @@
bootstrap: "{\"xds_servers\": [{\"server_uri\":\"xds.example.com:443\", \"channel_creds\":[{\"type\": \"fake\"}]}]}"
actions {
send_message_to_client {
stream_id {
ads {
}
}
}
}

@ -224,6 +224,7 @@ FakeXdsTransportFactory::Create(
void FakeXdsTransportFactory::TriggerConnectionFailure( void FakeXdsTransportFactory::TriggerConnectionFailure(
const XdsBootstrap::XdsServer& server, absl::Status status) { const XdsBootstrap::XdsServer& server, absl::Status status) {
auto transport = GetTransport(server); auto transport = GetTransport(server);
if (transport == nullptr) return;
transport->TriggerConnectionFailure(std::move(status)); transport->TriggerConnectionFailure(std::move(status));
} }
@ -237,15 +238,14 @@ FakeXdsTransportFactory::WaitForStream(const XdsBootstrap::XdsServer& server,
const char* method, const char* method,
absl::Duration timeout) { absl::Duration timeout) {
auto transport = GetTransport(server); auto transport = GetTransport(server);
if (transport == nullptr) return nullptr;
return transport->WaitForStream(method, timeout); return transport->WaitForStream(method, timeout);
} }
RefCountedPtr<FakeXdsTransportFactory::FakeXdsTransport> RefCountedPtr<FakeXdsTransportFactory::FakeXdsTransport>
FakeXdsTransportFactory::GetTransport(const XdsBootstrap::XdsServer& server) { FakeXdsTransportFactory::GetTransport(const XdsBootstrap::XdsServer& server) {
MutexLock lock(&mu_); MutexLock lock(&mu_);
RefCountedPtr<FakeXdsTransport> transport = transport_map_[&server]; return transport_map_[&server];
GPR_ASSERT(transport != nullptr);
return transport;
} }
} // namespace grpc_core } // namespace grpc_core

Loading…
Cancel
Save