-
Notifications
You must be signed in to change notification settings - Fork 89
Add experimental "pedantic" fortio output formatter. #534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
694f87f
f7ac360
e0a2cbb
82e735c
5ab4890
ab74535
2df8c2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,5 +108,26 @@ class FortioOutputFormatterImpl : public OutputFormatterImpl { | |
| double durationToSeconds(const Envoy::ProtobufWkt::Duration& duration) const; | ||
| }; | ||
|
|
||
| /** | ||
| * Applies corrections to the output of the original FortioOutputFormatterImpl class, | ||
| * to make the output adhere better to Fortio's actual output. | ||
| * In particular, the proto json serializer outputs 64 bits integers as strings, whereas | ||
| * Fortio outputs them unquoted / as integers, trusting that consumers side can take that | ||
| * well. We also fix the RequestedQPS field which was defined as an integer, but gets | ||
| * represented as a string in Fortio's json output. | ||
| */ | ||
| class FortioPedanticOutputFormatterImpl : public FortioOutputFormatterImpl { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a comment on the class roughly explaining what it is for?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 2df8c2b |
||
| public: | ||
| /** | ||
| * Format Nighthawk's native output proto to Fortio's output format. | ||
| * This relies on the base class to provide the initial render, and applies | ||
| * post processing to make corrections afterwards. | ||
| * | ||
| * @param output Nighthawk's native output proto that will be transformed. | ||
| * @return std::string Fortio formatted json string. | ||
| */ | ||
| std::string formatProto(const nighthawk::client::Output& output) const override; | ||
| }; | ||
|
|
||
| } // namespace Client | ||
| } // namespace Nighthawk | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,7 +126,8 @@ TEST_F(OutputCollectorTest, GetLowerCaseOutputFormats) { | |
| auto output_formats = OutputFormatterImpl::getLowerCaseOutputFormats(); | ||
| // When you're looking at this code you probably just added an output format. | ||
| // This is to point out that you might want to update the list below and add a test above. | ||
| ASSERT_THAT(output_formats, ElementsAre("json", "human", "yaml", "dotted", "fortio")); | ||
| ASSERT_THAT(output_formats, ElementsAre("json", "human", "yaml", "dotted", "fortio", | ||
| "experimental_fortio_pedantic")); | ||
| } | ||
|
|
||
| class FortioOutputCollectorTest : public OutputCollectorTest { | ||
|
|
@@ -186,7 +187,8 @@ class MediumOutputCollectorTest : public OutputCollectorTest { | |
| }; | ||
|
|
||
| TEST_F(MediumOutputCollectorTest, FortioFormatter) { | ||
| const auto input_proto = loadProtoFromFile("test/test_data/output_formatter.medium.proto.gold"); | ||
| const nighthawk::client::Output input_proto = | ||
| loadProtoFromFile("test/test_data/output_formatter.medium.proto.gold"); | ||
| FortioOutputFormatterImpl formatter; | ||
| expectEqualToGoldFile(formatter.formatProto(input_proto), | ||
| "test/test_data/output_formatter.medium.fortio.gold"); | ||
|
|
@@ -202,7 +204,8 @@ TEST_F(MediumOutputCollectorTest, FortioFormatter0sJitterUniformGetsReflected) { | |
| } | ||
|
|
||
| TEST_F(MediumOutputCollectorTest, ConsoleOutputFormatter) { | ||
| const auto input_proto = loadProtoFromFile("test/test_data/percentile-column-overflow.json"); | ||
| const nighthawk::client::Output input_proto = | ||
| loadProtoFromFile("test/test_data/percentile-column-overflow.json"); | ||
| ConsoleOutputFormatterImpl formatter; | ||
| expectEqualToGoldFile(formatter.formatProto(input_proto), | ||
| "test/test_data/percentile-column-overflow.txt.gold"); | ||
|
|
@@ -224,5 +227,13 @@ TEST_F(StatidToNameTest, TestTranslations) { | |
| } | ||
| } | ||
|
|
||
| TEST_F(MediumOutputCollectorTest, FortioPedanticFormatter) { | ||
| const nighthawk::client::Output input_proto = | ||
| loadProtoFromFile("test/test_data/output_formatter.medium.proto.gold"); | ||
| FortioPedanticOutputFormatterImpl formatter; | ||
| expectEqualToGoldFile(formatter.formatProto(input_proto), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This golden file is fairly long which makes it hard for the reader to figure out which portions actually are relevant to this test and which are just noise. Any way we could cut it down to the minimum required to test this new behavior?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes sense, but is kind of pre-existing; I think the initial work for this just grabbed a raw arbitrary snapshot and included it for testing the origin fortio output formatter code.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That works, thank you. |
||
| "test/test_data/output_formatter.medium.fortio-noquirks.gold"); | ||
| } | ||
|
|
||
| } // namespace Client | ||
| } // namespace Nighthawk | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(optional) Would you mind including (in the comment) and example of the matched string? That usually helps when trying to understand regexes in code. This one is fairly trivial, so optional, but we could use one for the second regex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I always felt that regular expressions are kind of a write-only concept :-)
Done in 2df8c2b