From 19cb442be7845efa1f7553091782bc0702b5283f Mon Sep 17 00:00:00 2001 From: Xavier Bauquet Date: Tue, 16 Jun 2020 12:55:12 +0200 Subject: [PATCH] tests(data-planes) fix access logs tests --- pkg/xds/envoy/listeners/access_log_configurer.go | 2 +- pkg/xds/envoy/listeners/http_access_log_configurer_test.go | 6 ++++-- .../envoy/listeners/network_access_log_configurer_test.go | 6 ++++-- .../generator/testdata/outbound-proxy/03.envoy.golden.yaml | 6 ++++-- .../generator/testdata/outbound-proxy/04.envoy.golden.yaml | 6 ++++-- pkg/xds/generator/transparent_proxy_generator_test.go | 3 ++- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/pkg/xds/envoy/listeners/access_log_configurer.go b/pkg/xds/envoy/listeners/access_log_configurer.go index c8d515a60966..3b9c005bd4c2 100644 --- a/pkg/xds/envoy/listeners/access_log_configurer.go +++ b/pkg/xds/envoy/listeners/access_log_configurer.go @@ -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) } diff --git a/pkg/xds/envoy/listeners/http_access_log_configurer_test.go b/pkg/xds/envoy/listeners/http_access_log_configurer_test.go index 2ea0a618cd95..e2e8815bec16 100644 --- a/pkg/xds/envoy/listeners/http_access_log_configurer_test.go +++ b/pkg/xds/envoy/listeners/http_access_log_configurer_test.go @@ -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 @@ -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: diff --git a/pkg/xds/envoy/listeners/network_access_log_configurer_test.go b/pkg/xds/envoy/listeners/network_access_log_configurer_test.go index 49f568322754..c959d8a84da6 100644 --- a/pkg/xds/envoy/listeners/network_access_log_configurer_test.go +++ b/pkg/xds/envoy/listeners/network_access_log_configurer_test.go @@ -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 @@ -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 `, diff --git a/pkg/xds/generator/testdata/outbound-proxy/03.envoy.golden.yaml b/pkg/xds/generator/testdata/outbound-proxy/03.envoy.golden.yaml index 82a791580a9b..81881e1de66c 100644 --- a/pkg/xds/generator/testdata/outbound-proxy/03.envoy.golden.yaml +++ b/pkg/xds/generator/testdata/outbound-proxy/03.envoy.golden.yaml @@ -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 @@ -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 diff --git a/pkg/xds/generator/testdata/outbound-proxy/04.envoy.golden.yaml b/pkg/xds/generator/testdata/outbound-proxy/04.envoy.golden.yaml index 543cb7ea1ece..60f0c8feedb7 100644 --- a/pkg/xds/generator/testdata/outbound-proxy/04.envoy.golden.yaml +++ b/pkg/xds/generator/testdata/outbound-proxy/04.envoy.golden.yaml @@ -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 @@ -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 diff --git a/pkg/xds/generator/transparent_proxy_generator_test.go b/pkg/xds/generator/transparent_proxy_generator_test.go index 18c096075bcb..f300841c1500 100644 --- a/pkg/xds/generator/transparent_proxy_generator_test.go +++ b/pkg/xds/generator/transparent_proxy_generator_test.go @@ -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