Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzzer: Make the logs more readable #29133

Merged
merged 3 commits into from
Aug 21, 2023
Merged
Changes from 1 commit
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
31 changes: 22 additions & 9 deletions test/common/http/codec_impl_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ class HttpStream : public LinkedObject<HttpStream> {
// explore these violations via MutateAction and SwapAction at the connection
// buffer level.
enum class StreamState : int { PendingHeaders, PendingDataOrTrailers, Closed };
static absl::string_view streamStateToString(StreamState state) {
KBaichoo marked this conversation as resolved.
Show resolved Hide resolved
switch (state) {
case StreamState::PendingHeaders:
static std::string pending_headers = "PendingHeaders";
return pending_headers;
case StreamState::PendingDataOrTrailers:
static std::string pending_data_or_trailers = "PendingDataOrTrailers";
return pending_data_or_trailers;
case StreamState::Closed:
static std::string closed = "Closed";
return closed;
}
}

struct DirectionalState {
// TODO(mattklein123): Split this more clearly into request and response directional state.
Expand Down Expand Up @@ -390,16 +403,16 @@ class HttpStream : public LinkedObject<HttpStream> {
void streamAction(const test::common::http::StreamAction& stream_action) {
switch (stream_action.stream_action_selector_case()) {
case test::common::http::StreamAction::kRequest: {
ENVOY_LOG_MISC(debug, "Request stream action on {} in state {} {}", stream_index_,
static_cast<int>(request_.stream_state_),
static_cast<int>(response_.stream_state_));
ENVOY_LOG_MISC(debug, "Request stream action on {} in state request({}) response({})",
stream_index_, streamStateToString(request_.stream_state_),
streamStateToString(response_.stream_state_));
stream_action_active_ = true;
if (stream_action.has_dispatching_action()) {
// Simulate some response action while dispatching request headers, data, or trailers. This
// may happen as a result of a filter sending a direct response.
ENVOY_LOG_MISC(debug, "Setting dispatching action on {} in state {} {}", stream_index_,
static_cast<int>(request_.stream_state_),
static_cast<int>(response_.stream_state_));
ENVOY_LOG_MISC(debug, "Setting dispatching action on {} in state request({}) response({})",
stream_index_, streamStateToString(request_.stream_state_),
streamStateToString(response_.stream_state_));
auto request_action = stream_action.dispatching_action().directional_action_selector_case();
if (request_action == test::common::http::DirectionalAction::kHeaders) {
EXPECT_CALL(request_.request_decoder_, decodeHeaders_(_, _))
Expand Down Expand Up @@ -438,9 +451,9 @@ class HttpStream : public LinkedObject<HttpStream> {
break;
}
case test::common::http::StreamAction::kResponse: {
ENVOY_LOG_MISC(debug, "Response stream action on {} in state {} {}", stream_index_,
static_cast<int>(request_.stream_state_),
static_cast<int>(response_.stream_state_));
ENVOY_LOG_MISC(debug, "Response stream action on {} in state request({}) response({})",
stream_index_, streamStateToString(request_.stream_state_),
streamStateToString(response_.stream_state_));
directionalAction(response_, stream_action.response());
break;
}
Expand Down
Loading