Skip to content

Commit

Permalink
Migrating configs of integration tests to Envoy API v3. (#583)
Browse files Browse the repository at this point in the history
Verified that all integration tests pass after updating Envoy to commit `588d9344b31e6544869547c4bcd359b3b0f1d4cf`, so this PR unblocks #575. Our next steps will be adding a good warning and a compatibility flag for users of Nighthawk. If they do send configs with Envoy API v2, we will break by default, but allow them to continue with the compatibility flag.

Summary of performed changes:
- changing `config` to `typed_config` and listing the correct type.
- migrating from deprecated field `tls_context` to `transport_socket`.
- changing filter names to ones that match extension names in [extensions_build_config.bzl](https://github.com/envoyproxy/nighthawk/blob/master/extensions_build_config.bzl).
- cosmetic changes of enum value from `auto` to `AUTO`.

Also:
- updating README and help displayed by the CLI in regards to passing in the `--tls-context` flag since this behavior is mirrored by one of the edited integration tests.
- Adding the `test_request_source_plugin.py` integration test as a dependency of the `integration_test` py_binary which was forgotten before.

Works on #580

Signed-off-by: Jakub Sobon <mumak@google.com>
  • Loading branch information
mum4k authored Dec 2, 2020
1 parent 4d831ff commit d58d63a
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 59 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ any other value will allow client-side queuing of requests).
Transport socket configuration in json or compact yaml. Mutually
exclusive with --tls-context. Example (json):
{name:"envoy.transport_sockets.tls"
,typed_config:{"@type":"type.googleapis.com/envoy.api.v2.auth.Upstream
TlsContext"
,typed_config:{"@type":"type.googleapis.com/envoy.extensions.transport
_sockets.tls.v3.UpstreamTlsContext"
,common_tls_context:{tls_params:{cipher_suites:["-ALL:ECDHE-RSA-AES128
-SHA"]}}}}
Expand Down
3 changes: 2 additions & 1 deletion source/client/options_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ OptionsImpl::OptionsImpl(int argc, const char* const* argv) {
"Transport socket configuration in json or compact yaml. "
"Mutually exclusive with --tls-context. Example (json): "
"{name:\"envoy.transport_sockets.tls\",typed_config:{"
"\"@type\":\"type.googleapis.com/envoy.api.v2.auth.UpstreamTlsContext\","
"\"@type\":\"type.googleapis.com/"
"envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext\","
"common_tls_context:{tls_params:{cipher_suites:[\"-ALL:ECDHE-RSA-AES128-SHA\"]}}}}",
false, "", "string", cmd);

Expand Down
7 changes: 7 additions & 0 deletions test/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ py_library(
deps = [":integration_test_base"],
)

py_library(
name = "test_request_source_plugin_lib",
srcs = ["test_request_source_plugin.py"],
deps = [":integration_test_base"],
)

py_binary(
name = "integration_test",
srcs = ["integration_test.py"],
Expand All @@ -122,5 +128,6 @@ py_binary(
":test_integration_zipkin_lib",
":test_output_transform_lib",
":test_remote_execution_lib",
":test_request_source_plugin_lib",
],
)
15 changes: 9 additions & 6 deletions test/integration/configurations/nighthawk_http_origin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ static_resources:
port_value: 0
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
generate_request_id: false
codec_type: auto
codec_type: AUTO
stat_prefix: ingress_http
route_config:
name: local_route
Expand All @@ -26,10 +27,12 @@ static_resources:
- name: time-tracking
- name: dynamic-delay
- name: test-server
config:
typed_config:
"@type": type.googleapis.com/nighthawk.server.ResponseOptions
response_body_size: 10
response_headers:
- { header: { key: "x-nh", value: "1"}}
- name: envoy.router
config:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
dynamic_stats: false
36 changes: 21 additions & 15 deletions test/integration/configurations/nighthawk_https_origin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ static_resources:
port_value: 0
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
generate_request_id: false
codec_type: auto
codec_type: AUTO
stat_prefix: ingress_http
route_config:
name: local_route
Expand All @@ -24,19 +25,24 @@ static_resources:
- "*"
http_filters:
- name: test-server
config:
typed_config:
"@type": type.googleapis.com/nighthawk.server.ResponseOptions
response_body_size: 10
response_headers:
- { header: { key: "x-nh", value: "1" } }
- name: envoy.router
config:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
dynamic_stats: false
tls_context:
common_tls_context:
tls_certificates:
- certificate_chain:
inline_string: |
@inject-runfile:nighthawk/external/envoy/test/config/integration/certs/servercert.pem
private_key:
inline_string: |
@inject-runfile:nighthawk/external/envoy/test/config/integration/certs/serverkey.pem
transport_socket:
name: tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
common_tls_context:
tls_certificates:
- certificate_chain:
inline_string: |
@inject-runfile:nighthawk/external/envoy/test/config/integration/certs/servercert.pem
private_key:
inline_string: |
@inject-runfile:nighthawk/external/envoy/test/config/integration/certs/serverkey.pem
18 changes: 11 additions & 7 deletions test/integration/configurations/nighthawk_track_timings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ static_resources:
port_value: 0
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
generate_request_id: false
codec_type: auto
codec_type: AUTO
stat_prefix: ingress_http
route_config:
name: local_route
Expand All @@ -28,11 +29,14 @@ static_resources:
http_filters:
# Here we set up the time-tracking extension to emit request-arrival delta timings in a response header.
- name: time-tracking
config:
typed_config:
"@type": type.googleapis.com/nighthawk.server.ResponseOptions
emit_previous_request_delta_in_response_header: x-origin-request-receipt-delta
- name: test-server
config:
typed_config:
"@type": type.googleapis.com/nighthawk.server.ResponseOptions
response_body_size: 10
- name: envoy.router
config:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
dynamic_stats: false
34 changes: 20 additions & 14 deletions test/integration/configurations/sni_origin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static_resources:
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.api.v2.auth.DownstreamTlsContext
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
common_tls_context:
tls_certificates:
- certificate_chain:
Expand All @@ -36,7 +36,7 @@ static_resources:
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.api.v2.auth.DownstreamTlsContext
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
common_tls_context:
tls_certificates:
- certificate_chain:
Expand All @@ -46,10 +46,11 @@ static_resources:
inline_string: |
@inject-runfile:nighthawk/external/envoy/test/config/integration/certs/serverkey.pem
filters:
- name: envoy.http_connection_manager
config:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
generate_request_id: false
codec_type: auto
codec_type: AUTO
stat_prefix: ingress_http
route_config:
name: local_route
Expand All @@ -59,18 +60,21 @@ static_resources:
- "sni.com"
http_filters:
- name: test-server
config:
typed_config:
"@type": type.googleapis.com/nighthawk.server.ResponseOptions
response_body_size: 10
response_headers:
- { header: { key: "x-nh", value: "1"}}
- name: envoy.router
config:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
dynamic_stats: false
- filters:
- name: envoy.http_connection_manager
config:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
generate_request_id: false
codec_type: auto
codec_type: AUTO
stat_prefix: ingress_http
route_config:
name: local_route
Expand All @@ -80,10 +84,12 @@ static_resources:
- "*"
http_filters:
- name: test-server
config:
typed_config:
"@type": type.googleapis.com/nighthawk.server.ResponseOptions
response_body_size: 10
response_headers:
- { header: { key: "x-nh", value: "1"}}
- name: envoy.router
config:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
dynamic_stats: false
2 changes: 1 addition & 1 deletion test/integration/test_integration_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def _do_tls_configuration_test(https_test_server_fixture, cli_parameter, use_h2)
else:
json_template = "%s%s%s" % (
"{name:\"envoy.transport_sockets.tls\",typed_config:{",
"\"@type\":\"type.googleapis.com/envoy.api.v2.auth.UpstreamTlsContext\",",
"\"@type\":\"type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext\",",
"common_tls_context:{tls_params:{cipher_suites:[\"-ALL:%s\"]}}}}")

for cipher in [
Expand Down
28 changes: 15 additions & 13 deletions test/options_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ TEST_F(OptionsImplTest, AlmostAll) {
"--latency-response-header-name zz",
client_name_,
"{name:\"envoy.transport_sockets.tls\","
"typed_config:{\"@type\":\"type.googleapis.com/envoy.api.v2.auth.UpstreamTlsContext\","
"typed_config:{\"@type\":\"type.googleapis.com/"
"envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext\","
"common_tls_context:{tls_params:{"
"cipher_suites:[\"-ALL:ECDHE-RSA-AES256-GCM-SHA384\"]}}}}",
good_test_uri_, sink_json_1, sink_json_2));
Expand All @@ -142,18 +143,19 @@ TEST_F(OptionsImplTest, AlmostAll) {
const std::vector<std::string> expected_headers = {"f1:b1", "f2:b2", "f3:b3:b4"};
EXPECT_EQ(expected_headers, options->requestHeaders());
EXPECT_EQ(1234, options->requestBodySize());
EXPECT_EQ("name: \"envoy.transport_sockets.tls\"\n"
"typed_config {\n"
" [type.googleapis.com/envoy.api.v2.auth.UpstreamTlsContext] {\n"
" common_tls_context {\n"
" tls_params {\n"
" cipher_suites: \"-ALL:ECDHE-RSA-AES256-GCM-SHA384\"\n"
" }\n"
" }\n"
" }\n"
"}\n"
"183412668: \"envoy.api.v2.core.TransportSocket\"\n",
options->transportSocket().value().DebugString());
EXPECT_EQ(
"name: \"envoy.transport_sockets.tls\"\n"
"typed_config {\n"
" [type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext] {\n"
" common_tls_context {\n"
" tls_params {\n"
" cipher_suites: \"-ALL:ECDHE-RSA-AES256-GCM-SHA384\"\n"
" }\n"
" }\n"
" }\n"
"}\n"
"183412668: \"envoy.api.v2.core.TransportSocket\"\n",
options->transportSocket().value().DebugString());
EXPECT_EQ(10, options->maxPendingRequests());
EXPECT_EQ(11, options->maxActiveRequests());
EXPECT_EQ(12, options->maxRequestsPerConnection());
Expand Down

0 comments on commit d58d63a

Please sign in to comment.