From 877a7822743366d60acfed7b066dd0284826d41c Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 18 Dec 2024 20:01:05 -0800 Subject: [PATCH] x --- src/core/ext/transport/chaotic_good/frame.cc | 4 +- .../transport/chaotic_good/frame_header.cc | 2 +- .../chaotic_good/client_transport_test.cc | 41 +++---------------- .../chaotic_good/mock_frame_transport.cc | 5 ++- 4 files changed, 13 insertions(+), 39 deletions(-) diff --git a/src/core/ext/transport/chaotic_good/frame.cc b/src/core/ext/transport/chaotic_good/frame.cc index 4a3cfe50bebcb..057598a436376 100644 --- a/src/core/ext/transport/chaotic_good/frame.cc +++ b/src/core/ext/transport/chaotic_good/frame.cc @@ -331,7 +331,9 @@ absl::StatusOr ParseFrame(const FrameHeader& header, case FrameType::kBeginMessage: return DeserializeFrame(header, std::move(payload)); default: - return absl::InternalError("bah"); + return absl::InternalError( + absl::StrCat("Unknown frame type: ", header.ToString(), + " payload:", payload.Length(), "b")); } } diff --git a/src/core/ext/transport/chaotic_good/frame_header.cc b/src/core/ext/transport/chaotic_good/frame_header.cc index 1957d93fbbc57..ac42b7e5f742b 100644 --- a/src/core/ext/transport/chaotic_good/frame_header.cc +++ b/src/core/ext/transport/chaotic_good/frame_header.cc @@ -50,7 +50,7 @@ std::string FrameTypeString(FrameType type) { case FrameType::kMessageChunk: return "MessageChunk"; } - return absl::StrCat("Unknown[", static_cast(type), "]"); + return absl::StrCat("Unknown[0x", absl::Hex(static_cast(type)), "]"); } } // namespace chaotic_good diff --git a/test/core/transport/chaotic_good/client_transport_test.cc b/test/core/transport/chaotic_good/client_transport_test.cc index 4137137180f89..0836843066a58 100644 --- a/test/core/transport/chaotic_good/client_transport_test.cc +++ b/test/core/transport/chaotic_good/client_transport_test.cc @@ -57,12 +57,6 @@ namespace grpc_core { namespace chaotic_good { namespace testing { -class MockClientConnectionFactory : public ClientConnectionFactory { - public: - MOCK_METHOD(PendingConnection, Connect, (absl::string_view), (override)); - void Orphaned() final {} -}; - ClientMetadataHandle TestInitialMetadata() { auto md = Arena::MakePooledForOverwrite(); md->Set(HttpPathMetadata(), Slice::FromStaticString("/demo.Service/Step")); @@ -101,23 +95,8 @@ ChannelArgs MakeChannelArgs( std::move(event_engine)); } -template -Config MakeConfig(const ChannelArgs& channel_args, - PromiseEndpoints... promise_endpoints) { - Config config(channel_args); - auto name_endpoint = [i = 0]() mutable { return absl::StrCat(++i); }; - std::vector this_is_only_here_to_unpack_the_following_statement{ - (config.ServerAddPendingDataEndpoint( - ImmediateConnection(name_endpoint(), std::move(promise_endpoints))), - 0)...}; - return config; -} - TEST_F(TransportTest, AddOneStream) { - MockPromiseEndpoint control_endpoint(1000); - MockPromiseEndpoint data_endpoint(1001); - auto client_connection_factory = - MakeRefCounted>(); + MockFrameTransport frame_transport; static const std::string many_as(1024 * 1024, 'a'); const auto server_initial_metadata = EncodeProto("message: 'hello'"); @@ -142,22 +121,14 @@ TEST_F(TransportTest, AddOneStream) { .WillOnce(Return(false)); auto channel_args = MakeChannelArgs(event_engine()); auto transport = MakeOrphanable( - channel_args, std::move(control_endpoint.promise_endpoint), - MakeConfig(channel_args, std::move(data_endpoint.promise_endpoint)), - client_connection_factory); + channel_args, frame_transport, MessageChunker(0, 1)); auto call = MakeCall(TestInitialMetadata()); StrictMock> on_done; EXPECT_CALL(on_done, Call()); - control_endpoint.ExpectWrite( - {SerializedFrameHeader(FrameType::kClientInitialMetadata, 0, 1, - client_initial_metadata.length()), - client_initial_metadata.Copy()}, - nullptr); - control_endpoint.ExpectWrite( - {SerializedFrameHeader(FrameType::kMessage, 0, 1, 1), - EventEngineSlice::FromCopiedString("0"), - SerializedFrameHeader(FrameType::kClientEndOfStream, 0, 1, 0)}, - nullptr); + frame_transport.ExpectWrite(MakeProtoFrame( + 1, "path: '/demo.Service/Step'")); + frame_transport.ExpectWrite(MakeMessageFrame(1, many_as)); + frame_transport.ExpectWrite(ClientEndOfStreamFrame(1)); transport->StartCall(call.handler.StartCall()); call.initiator.SpawnGuarded("test-send", [initiator = call.initiator]() mutable { diff --git a/test/core/transport/chaotic_good/mock_frame_transport.cc b/test/core/transport/chaotic_good/mock_frame_transport.cc index e70b16285f9f7..6d058a68534f4 100644 --- a/test/core/transport/chaotic_good/mock_frame_transport.cc +++ b/test/core/transport/chaotic_good/mock_frame_transport.cc @@ -73,9 +73,10 @@ void MockFrameTransport::StartWriting( void MockFrameTransport::Read(Frame frame) { SliceBuffer buffer; auto& frame_interface = absl::ConvertVariantTo(frame); + LOG(INFO) << "Read " << frame_interface.ToString(); + auto header = frame_interface.MakeHeader(); frame_interface.SerializePayload(buffer); - reader_.UnbufferedImmediateSend( - IncomingFrame(frame_interface.MakeHeader(), std::move(buffer))); + reader_.UnbufferedImmediateSend(IncomingFrame(header, std::move(buffer))); } } // namespace testing