-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor filter configuration to make the different test server filte…
…rs independent (#855) This is a followup to #852. In that change, we duplicated ResponseOptions onto separate DynamicDelayConfiguration and TimeTrackingConfiguration protos. However, this resulted in many fields on those protos that were not relevant to each filter. In this PR, we make it so that only the relevant fields exist on each proto. Resulting changes: 1. Moved DynamicDelayConfiguration and TimeTrackingConfiguration into their own files, and moved their fields into those protos directly. 2. In order to make request headers still work, there is now manual logic for taking in a ResponseOptions proto via json and cherrypicking the fields relevant to each filter. 3. The generic method computeEffectiveConfiguration was moved to each filter's anonymous namespace. 4. All configs, tests, and markdown files updated to use the new protos. 5. Some tests have been removed that are no longer necessary, or never provided additional coverage, including some that are less feasible now. - HeaderMerge was removed, but everything it tested for was moved into new unit tests of MergeJsonConfig. Signed-off-by: Nathan Perry <[email protected]>
- Loading branch information
dubious90
authored
Jun 7, 2022
1 parent
28955cd
commit 7290824
Showing
30 changed files
with
540 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Changelog | ||
|
||
All breaking changes to this project will be documented in this file, most | ||
recent changes at the top. | ||
|
||
## 0.5.0 | ||
|
||
In an effort to clean up the previous change and improve it, we re-modified the | ||
dynamic-delay and time-tracking filters to extricate their configuration | ||
entirely from | ||
[nighthawk.server.ResponseOptions](https://github.com/envoyproxy/nighthawk/blob/main/api/server/response_options.proto). The new configurations are: | ||
|
||
- [nighthawk.server.DynamicDelayConfiguration](https://github.com/envoyproxy/nighthawk/blob/main/api/server/dynamic_delay.proto) | ||
- [nighthawk.server.TimeTrackingConfiguration](https://github.com/envoyproxy/nighthawk/blob/main/api/server/time_tracking.proto) | ||
|
||
If you are converting from the previous configuration with | ||
`experimental_response_options`, such as: | ||
|
||
``` | ||
http_filters: | ||
- name: time-tracking | ||
typed_config: | ||
"@type": type.googleapis.com/nighthawk.server.TimeTrackingConfiguration | ||
experimental_response_options: | ||
emit_previous_request_delta_in_response_header: x-origin-request-receipt-delta | ||
- name: dynamic-delay | ||
typed_config: | ||
"@type": type.googleapis.com/nighthawk.server.DynamicDelayConfiguration | ||
experimental_response_options: | ||
static_delay: 1.33s | ||
- name: test-server | ||
typed_config: | ||
"@type": type.googleapis.com/nighthawk.server.ResponseOptions | ||
response_body_size: 10 | ||
static_delay: 1.33s | ||
emit_previous_request_delta_in_response_header: x-origin-request-receipt-delta | ||
v3_response_headers: | ||
- { header: { key: "x-nh", value: "1"}} | ||
``` | ||
|
||
You should now specify only fields related to each filter in their | ||
configuration, and you can do so at the top-level of those protos: | ||
|
||
``` | ||
http_filters: | ||
- name: time-tracking | ||
typed_config: | ||
"@type": type.googleapis.com/nighthawk.server.TimeTrackingConfiguration | ||
emit_previous_request_delta_in_response_header: x-origin-request-receipt-delta | ||
- name: dynamic-delay | ||
typed_config: | ||
"@type": type.googleapis.com/nighthawk.server.DynamicDelayConfiguration | ||
static_delay: 1.33s | ||
- name: test-server | ||
typed_config: | ||
"@type": type.googleapis.com/nighthawk.server.ResponseOptions | ||
response_body_size: 10 | ||
v3_response_headers: | ||
- { header: { key: "x-nh", value: "1"}} | ||
``` | ||
|
||
This change does NOT affect how headers update the base configurations. | ||
|
||
## 0.4.0 | ||
|
||
Due to | ||
[upstream envoy change](https://github.com/envoyproxy/nighthawk/commit/4919c54202329adc3875eb1bce074af33d54e26d), | ||
we modified the dynamic-delay and time-tracking filters' configuration protos | ||
to have their own configuration protos wrapping | ||
[nighthawk.server.ResponseOptions]([nighthawk.server.ResponseOptions](https://github.com/envoyproxy/nighthawk/blob/0.4.0/api/server/response_options.proto)). | ||
DynamicDelayConfiguration and TimeTrackingConfiguration definitions can be | ||
found at the bottom of that file as well. | ||
. | ||
|
||
For yaml bootstrap configuration files that defined | ||
[filter configuration](https://github.com/envoyproxy/nighthawk/blob/main/source/server/README.md#nighthawk-test-server) | ||
for the `test-server`, `dynamic-delay`, or `time-tracking` filters, if you | ||
previously had: | ||
|
||
``` | ||
http_filters: | ||
- name: time-tracking | ||
- name: dynamic-delay | ||
- name: test-server | ||
typed_config: | ||
"@type": type.googleapis.com/nighthawk.server.ResponseOptions | ||
response_body_size: 10 | ||
static_delay: 1.33s | ||
emit_previous_request_delta_in_response_header: x-origin-request-receipt-delta | ||
v3_response_headers: | ||
- { header: { key: "x-nh", value: "1"}} | ||
``` | ||
|
||
You should now explicitly specify the types and values of the protos as such, | ||
wrapping the `dynamic-delay` and `time-tracking` configurations in a new field, | ||
`experimental_response_options`: | ||
|
||
``` | ||
http_filters: | ||
- name: time-tracking | ||
typed_config: | ||
"@type": type.googleapis.com/nighthawk.server.TimeTrackingConfiguration | ||
experimental_response_options: | ||
emit_previous_request_delta_in_response_header: x-origin-request-receipt-delta | ||
- name: dynamic-delay | ||
typed_config: | ||
"@type": type.googleapis.com/nighthawk.server.DynamicDelayConfiguration | ||
experimental_response_options: | ||
static_delay: 1.33s | ||
- name: test-server | ||
typed_config: | ||
"@type": type.googleapis.com/nighthawk.server.ResponseOptions | ||
response_body_size: 10 | ||
static_delay: 1.33s | ||
emit_previous_request_delta_in_response_header: x-origin-request-receipt-delta | ||
v3_response_headers: | ||
- { header: { key: "x-nh", value: "1"}} | ||
``` | ||
|
||
This change does NOT affect how headers update the base configurations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Proto file supporting any configuration related to the dynamic delay filter. | ||
syntax = "proto3"; | ||
|
||
import "api/server/response_options.proto"; | ||
import "google/protobuf/duration.proto"; | ||
import "validate/validate.proto"; | ||
|
||
package nighthawk.server; | ||
|
||
// Configures the dynamic-delay filter. | ||
message DynamicDelayConfiguration { | ||
oneof oneof_delay_options { | ||
// Static delay duration. | ||
google.protobuf.Duration static_delay = 2 [(validate.rules).duration.gte.nanos = 0]; | ||
// Concurrency based linear delay configuration. | ||
ConcurrencyBasedLinearDelay concurrency_based_linear_delay = 3; | ||
} | ||
|
||
reserved 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Proto file supporting any configuration related to the time tracking filter. | ||
syntax = "proto3"; | ||
|
||
package nighthawk.server; | ||
|
||
// Configures the time-tracking filter. | ||
message TimeTrackingConfiguration { | ||
// If set, makes the extension include timing data in the supplied response header name. | ||
// For example, when set to "x-abc", and 3 requests are performed, the test server will respond | ||
// with: Response 1: No x-abc header because there's no previous response. Response 2: Header | ||
// x-abc: <ns elapsed between responses 2 and 1>. Response 3: Header x-abc: <ns elapsed between | ||
// responses 3 and 2>. | ||
string emit_previous_request_delta_in_response_header = 2; | ||
|
||
reserved 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.