Skip to content

Commit

Permalink
tests(data-planes) fix access logs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xbauquet committed Jun 20, 2020
1 parent 56f522a commit 19cb442
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/xds/envoy/listeners/access_log_configurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func convertLoggingBackend(mesh string, trafficDirection TrafficDirection, sourc
if backend.Format != "" {
formatString = backend.Format
}

format, err := accesslog.ParseFormat(formatString + "\n")

if err != nil {
return nil, errors.Wrapf(err, "invalid access log format string: %s", formatString)
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/xds/envoy/listeners/http_access_log_configurer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ var _ = Describe("HttpAccessLogConfigurer", func() {
- name: envoy.file_access_log
typedConfig:
'@type': type.googleapis.com/envoy.config.accesslog.v2.FileAccessLog
format: |
format: |+
[%START_TIME%] demo "%REQ(:method)% %REQ(x-envoy-original-path?:path)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(x-envoy-upstream-service-time)% "%REQ(x-forwarded-for)%" "%REQ(user-agent)%" "%REQ(x-request-id)%" "%REQ(:authority)%" "web" "backend" "192.168.0.1" "%UPSTREAM_HOST%"
path: /tmp/log
httpFilters:
- name: envoy.router
Expand Down Expand Up @@ -186,10 +187,11 @@ var _ = Describe("HttpAccessLogConfigurer", func() {
grpcService:
envoyGrpc:
clusterName: access_log_sink
logName: |
logName: |+
127.0.0.1:1234;[%START_TIME%] "%REQ(x-request-id)%" "%REQ(:authority)%" "%REQ(origin)%" "%REQ(content-type)%" "web" "backend" "192.168.0.1:0" "192.168.0.1" "%UPSTREAM_HOST%"
"%RESP(server):5%" "%TRAILER(grpc-message):7%" "DYNAMIC_METADATA(namespace:object:key):9" "FILTER_STATE(filter.state.key):12"
httpFilters:
- name: envoy.router
rds:
Expand Down
6 changes: 4 additions & 2 deletions pkg/xds/envoy/listeners/network_access_log_configurer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ var _ = Describe("NetworkAccessLogConfigurer", func() {
- name: envoy.file_access_log
typedConfig:
'@type': type.googleapis.com/envoy.config.accesslog.v2.FileAccessLog
format: |
format: |+
[%START_TIME%] %RESPONSE_FLAGS% demo 192.168.0.1(backend)->%UPSTREAM_HOST%(db) took %DURATION%ms, sent %BYTES_SENT% bytes, received: %BYTES_RECEIVED% bytes
path: /tmp/log
cluster: db
statPrefix: db
Expand Down Expand Up @@ -177,10 +178,11 @@ var _ = Describe("NetworkAccessLogConfigurer", func() {
grpcService:
envoyGrpc:
clusterName: access_log_sink
logName: |
logName: |+
127.0.0.1:1234;[%START_TIME%] "%REQ(x-request-id)%" "%REQ(:authority)%" "%REQ(origin)%" "%REQ(content-type)%" "backend" "db" "192.168.0.1:0" "192.168.0.1" "%UPSTREAM_HOST%
"%RESP(server):5%" "%TRAILER(grpc-message):7%" "DYNAMIC_METADATA(namespace:object:key):9" "FILTER_STATE(filter.state.key):12"
cluster: db
statPrefix: db
`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ resources:
- name: envoy.file_access_log
typedConfig:
'@type': type.googleapis.com/envoy.config.accesslog.v2.FileAccessLog
format: |
format: |+
[%START_TIME%] mesh1 "%REQ(:method)% %REQ(x-envoy-original-path?:path)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(x-envoy-upstream-service-time)% "%REQ(x-forwarded-for)%" "%REQ(user-agent)%" "%REQ(x-request-id)%" "%REQ(:authority)%" "gateway" "api-http" "10.0.0.1" "%UPSTREAM_HOST%"
path: /var/log
httpFilters:
- name: envoy.router
Expand Down Expand Up @@ -110,8 +111,9 @@ resources:
grpcService:
envoyGrpc:
clusterName: access_log_sink
logName: |
logName: |+
logstash:1234;[%START_TIME%] %RESPONSE_FLAGS% mesh1 10.0.0.1(gateway)->%UPSTREAM_HOST%(api-tcp) took %DURATION%ms, sent %BYTES_SENT% bytes, received: %BYTES_RECEIVED% bytes
cluster: api-tcp
statPrefix: api-tcp
name: outbound:127.0.0.1:40002
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ resources:
- name: envoy.file_access_log
typedConfig:
'@type': type.googleapis.com/envoy.config.accesslog.v2.FileAccessLog
format: |
format: |+
[%START_TIME%] mesh1 "%REQ(:method)% %REQ(x-envoy-original-path?:path)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(x-envoy-upstream-service-time)% "%REQ(x-forwarded-for)%" "%REQ(user-agent)%" "%REQ(x-request-id)%" "%REQ(:authority)%" "web" "api-http" "10.0.0.1" "%UPSTREAM_HOST%"
path: /var/log
httpFilters:
- name: envoy.router
Expand Down Expand Up @@ -118,8 +119,9 @@ resources:
grpcService:
envoyGrpc:
clusterName: access_log_sink
logName: |
logName: |+
logstash:1234;[%START_TIME%] %RESPONSE_FLAGS% mesh1 10.0.0.1(web)->%UPSTREAM_HOST%(api-tcp) took %DURATION%ms, sent %BYTES_SENT% bytes, received: %BYTES_RECEIVED% bytes
cluster: api-tcp
statPrefix: api-tcp
name: outbound:127.0.0.1:40002
Expand Down
3 changes: 2 additions & 1 deletion pkg/xds/generator/transparent_proxy_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ var _ = Describe("TransparentProxyGenerator", func() {
- name: envoy.file_access_log
typedConfig:
'@type': type.googleapis.com/envoy.config.accesslog.v2.FileAccessLog
format: |
format: |+
[%START_TIME%] %RESPONSE_FLAGS% default (unknown)->%UPSTREAM_HOST%(external) took %DURATION%ms, sent %BYTES_SENT% bytes, received: %BYTES_RECEIVED% bytes
path: /var/log
cluster: pass_through
statPrefix: pass_through
Expand Down

0 comments on commit 19cb442

Please sign in to comment.