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
1 change: 0 additions & 1 deletion test/common/router/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ envoy_cc_test(
external_deps = ["abseil_optional"],
deps = [
"//source/common/buffer:buffer_lib",
"//source/common/config:filter_json_lib",
"//source/common/network:utility_lib",
"//source/common/router:router_lib",
"//source/common/upstream:upstream_includes",
Expand Down
34 changes: 17 additions & 17 deletions test/common/router/router_upstream_log_test.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <ctime>
#include <regex>

#include "common/config/filter_json.h"
#include "common/network/utility.h"
#include "common/router/router.h"
#include "common/upstream/upstream_impl.h"
Expand Down Expand Up @@ -34,17 +33,18 @@ namespace {

absl::optional<envoy::config::filter::accesslog::v2::AccessLog> testUpstreamLog() {
// Custom format without timestamps or durations.
const std::string json_string = R"EOF(
{
"path": "/dev/null",
"format": "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL% %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %REQ(:AUTHORITY)% %UPSTREAM_HOST% %RESP(X-UPSTREAM-HEADER)% %TRAILER(X-TRAILER)%\n"
}
const std::string yaml = R"EOF(
name: envoy.file_access_log
typed_config:
"@type": type.googleapis.com/envoy.config.accesslog.v2.FileAccessLog
format: "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL% %RESPONSE_CODE%
%RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %REQ(:AUTHORITY)% %UPSTREAM_HOST%
%RESP(X-UPSTREAM-HEADER)% %TRAILER(X-TRAILER)%\n"
path: "/dev/null"
)EOF";

auto json_object_ptr = Json::Factory::loadFromString(json_string);

envoy::config::filter::accesslog::v2::AccessLog upstream_log;
Envoy::Config::FilterJson::translateAccessLog(*json_object_ptr, upstream_log);
MessageUtil::loadFromYaml(yaml, upstream_log);

return absl::optional<envoy::config::filter::accesslog::v2::AccessLog>(upstream_log);
}
Expand Down Expand Up @@ -256,17 +256,17 @@ TEST_F(RouterUpstreamLogTest, LogHeaders) {

// Test timestamps and durations are emitted.
TEST_F(RouterUpstreamLogTest, LogTimestampsAndDurations) {
const std::string json_string = R"EOF(
{
"path": "/dev/null",
"format": "[%START_TIME%] %REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL% %DURATION% %RESPONSE_DURATION% %REQUEST_DURATION%"
}
const std::string yaml = R"EOF(
name: envoy.file_access_log
typed_config:
"@type": type.googleapis.com/envoy.config.accesslog.v2.FileAccessLog
format: "[%START_TIME%] %REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%
%DURATION% %RESPONSE_DURATION% %REQUEST_DURATION%"
path: "/dev/null"
)EOF";

auto json_object_ptr = Json::Factory::loadFromString(json_string);

envoy::config::filter::accesslog::v2::AccessLog upstream_log;
Envoy::Config::FilterJson::translateAccessLog(*json_object_ptr, upstream_log);
MessageUtil::loadFromYaml(yaml, upstream_log);

init(absl::optional<envoy::config::filter::accesslog::v2::AccessLog>(upstream_log));
run(200, {{"x-envoy-original-path", "/foo"}}, {}, {});
Expand Down