Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/integration/fake_upstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ void FakeStream::encodeHeaders(const Http::HeaderMapImpl& headers, bool end_stre
});
}

void FakeStream::encodeData(absl::string_view data, bool end_stream) {
parent_.connection().dispatcher().post([this, data, end_stream]() -> void {
Buffer::OwnedImpl fake_data(data.data(), data.size());
encoder_.encodeData(fake_data, end_stream);
});
}

void FakeStream::encodeData(uint64_t size, bool end_stream) {
parent_.connection().dispatcher().post([this, size, end_stream]() -> void {
Buffer::OwnedImpl data(std::string(size, 'a'));
Expand Down Expand Up @@ -138,6 +145,18 @@ AssertionResult FakeStream::waitForData(Event::Dispatcher& client_dispatcher, ui
return AssertionSuccess();
}

AssertionResult FakeStream::waitForData(Event::Dispatcher& client_dispatcher,
absl::string_view data, milliseconds timeout) {
auto succeeded = waitForData(client_dispatcher, data.length(), timeout);
if (succeeded) {
Buffer::OwnedImpl buffer(data.data(), data.length());
if (!TestUtility::buffersEqual(body(), buffer)) {
return AssertionFailure() << body().toString() << " not equal to " << data;
}
}
return succeeded;
}

AssertionResult FakeStream::waitForEndStream(Event::Dispatcher& client_dispatcher,
milliseconds timeout) {
Thread::LockGuard lock(lock_);
Expand Down
6 changes: 6 additions & 0 deletions test/integration/fake_upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class FakeStream : public Http::StreamDecoder,
void encodeHeaders(const Http::HeaderMapImpl& headers, bool end_stream);
void encodeData(uint64_t size, bool end_stream);
void encodeData(Buffer::Instance& data, bool end_stream);
void encodeData(absl::string_view data, bool end_stream);
void encodeTrailers(const Http::HeaderMapImpl& trailers);
void encodeResetStream();
const Http::HeaderMap& headers() { return *headers_; }
Expand All @@ -67,6 +68,11 @@ class FakeStream : public Http::StreamDecoder,
waitForData(Event::Dispatcher& client_dispatcher, uint64_t body_length,
std::chrono::milliseconds timeout = TestUtility::DefaultTimeout);

ABSL_MUST_USE_RESULT
testing::AssertionResult
waitForData(Event::Dispatcher& client_dispatcher, absl::string_view body,
std::chrono::milliseconds timeout = TestUtility::DefaultTimeout);

ABSL_MUST_USE_RESULT
testing::AssertionResult
waitForEndStream(Event::Dispatcher& client_dispatcher,
Expand Down
7 changes: 7 additions & 0 deletions test/integration/http_integration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ IntegrationCodecClient::makeRequestWithBody(const Http::HeaderMap& headers, uint
return response;
}

void IntegrationCodecClient::sendData(Http::StreamEncoder& encoder, absl::string_view data,
bool end_stream) {
Buffer::OwnedImpl buffer_data(data.data(), data.size());
encoder.encodeData(buffer_data, end_stream);
flushWrite();
}

void IntegrationCodecClient::sendData(Http::StreamEncoder& encoder, Buffer::Instance& data,
bool end_stream) {
encoder.encodeData(data, end_stream);
Expand Down
1 change: 1 addition & 0 deletions test/integration/http_integration.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class IntegrationCodecClient : public Http::CodecClientProd {
IntegrationStreamDecoderPtr makeRequestWithBody(const Http::HeaderMap& headers,
uint64_t body_size);
bool sawGoAway() { return saw_goaway_; }
void sendData(Http::StreamEncoder& encoder, absl::string_view data, bool end_stream);
void sendData(Http::StreamEncoder& encoder, Buffer::Instance& data, bool end_stream);
void sendData(Http::StreamEncoder& encoder, uint64_t size, bool end_stream);
void sendTrailers(Http::StreamEncoder& encoder, const Http::HeaderMap& trailers);
Expand Down
Loading