Skip to content

Add experimental "pedantic" fortio output formatter.#534

Merged
mum4k merged 7 commits intoenvoyproxy:masterfrom
oschaaf:fortio-pdentantic
Sep 17, 2020
Merged

Add experimental "pedantic" fortio output formatter.#534
mum4k merged 7 commits intoenvoyproxy:masterfrom
oschaaf:fortio-pdentantic

Conversation

@oschaaf
Copy link
Copy Markdown
Member

@oschaaf oschaaf commented Sep 14, 2020

Adds a post-processing step to massage the fortio output formatting
to more exactly reproduce Fortio's output, while leaving the
original output formatter intact for backwards compatibility purposes.

Fixes known issues #422 and #514. Experimental until we have
some confirmation that this can be marked as final / all issues have
been resolved.

Signed-off-by: Otto van der Schaaf oschaaf@we-amp.com

Adds a post-processing step to massage the fortio output formatting
to more exactly reproduce Fortio's output, while leaving the
original output formatter intact for backwards compatibility purposes.

Fixes known issues envoyproxy#422 and fixes envoyproxy#514. Experimental until we have
some conformation that this can be marked as final / all issues have
been resolved.

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@oschaaf oschaaf added the waiting-for-review A PR waiting for a review. label Sep 14, 2020
@oschaaf
Copy link
Copy Markdown
Member Author

oschaaf commented Sep 14, 2020

/cc @kushthedude @howardjohn

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@dubious90 dubious90 requested a review from eric846 September 14, 2020 15:39
@dubious90
Copy link
Copy Markdown
Contributor

@eric846 Please review and assign back to me once done.

kushthedude
kushthedude previously approved these changes Sep 15, 2020
Copy link
Copy Markdown
Contributor

@kushthedude kushthedude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for us!
/cc @leecalcote

@oschaaf
Copy link
Copy Markdown
Member Author

oschaaf commented Sep 15, 2020

Also /cc @carolynhu
this is pulled of in a backwards compatible manner, but when we upgrade, there'll
be a way to get rid of the workarounds for the fortio output more quirks in NH once this lands.

Comment on lines +197 to +201
"Min": 0.053798911,
"Max": 0.310886399,
"Sum": 4.156954618,
"Avg": 0.078433106,
"StdDev": 0.05052302,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move these fields (line 197 to line 201) up to under line 8 "Count" field as what fortio has?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is quite hard to pull off in the current approach. Looking at it, the proto json serialiser we use here alphabetically sorts this. I think it can do that, because after parsing the difference usually doesn't matter? Do you see a way that the re-ordering could cause trouble?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet. Just noticed the order is mismatch with fortio. Don't think it will cause any trouble.

},
{
"Percentile": 95,
"Value": 47353
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these value fake or real? as this is in seconds...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't come up with this test data, it's a copy of a pre-existing one modified to reflect the changes in here. If I interpret the file correctly, we're not looking at seconds, but rather a histogram of byte counts for the header?

@leecalcote
Copy link
Copy Markdown

@oschaaf thank you for today's call. Very much enjoyed it.

We can assist in verifying compatibility. Are the build artifacts of this PR (the container image) available?

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@oschaaf
Copy link
Copy Markdown
Member Author

oschaaf commented Sep 16, 2020

@oschaaf thank you for today's call. Very much enjoyed it.

We can assist in verifying compatibility. Are the build artifacts of this PR (the container image) available?

@leecalcote
Unfortunately, I think fresh images will only be pushed post-merge of this.
So to try this out one needs to manually build the docker image.
Having said that, it is ok to iterate on this while we have the feature marked as --experimental, as we don't
need to be backwards compatible while that is the case. So waiting until after the merge is viable too.

eric846
eric846 previously approved these changes Sep 17, 2020
Copy link
Copy Markdown
Contributor

@eric846 eric846 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mum4k mum4k self-assigned this Sep 17, 2020
// Fix two types of quirks. We disable linting because we use std::regex directly.
// This should be OK as the regular expression we use can be trusted.
// 1. We misdefined RequestedRPS as an int, whereas Fortio outputs that as a string.
res = std::regex_replace(res, std::regex(R"EOF("RequestedQPS"\: ([0-9]*))EOF"),
Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Member Author

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

double durationToSeconds(const Envoy::ProtobufWkt::Duration& duration) const;
};

class FortioPedanticOutputFormatterImpl : public FortioOutputFormatterImpl {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 2df8c2b

}

TEST_F(MediumOutputCollectorTest, FortioPedanticFormatter) {
const auto input_proto = loadProtoFromFile("test/test_data/output_formatter.medium.proto.gold");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "auto" here doesn't seem to hide redundant type information, so it might be better for the reader to spell it out.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here and in other spots in 2df8c2b

TEST_F(MediumOutputCollectorTest, FortioPedanticFormatter) {
const auto input_proto = loadProtoFromFile("test/test_data/output_formatter.medium.proto.gold");
FortioPedanticOutputFormatterImpl formatter;
expectEqualToGoldFile(formatter.formatProto(input_proto),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Member Author

@oschaaf oschaaf Sep 17, 2020

Choose a reason for hiding this comment

The 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.
We are now more or less forced to propagate that, as our new gold file is an amended version of the original one.
I punted this to #542 to track doing this, does that work for you?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works, thank you.

@mum4k mum4k added waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. and removed waiting-for-review A PR waiting for a review. labels Sep 17, 2020
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@oschaaf oschaaf added waiting-for-review A PR waiting for a review. and removed waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. labels Sep 17, 2020
TEST_F(MediumOutputCollectorTest, FortioPedanticFormatter) {
const auto input_proto = loadProtoFromFile("test/test_data/output_formatter.medium.proto.gold");
FortioPedanticOutputFormatterImpl formatter;
expectEqualToGoldFile(formatter.formatProto(input_proto),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works, thank you.

@mum4k mum4k merged commit 8b16dc1 into envoyproxy:master Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-for-review A PR waiting for a review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nighthawk fortio's output is discrepant then real fortio's output Fortio output slightly different than the real fortio

7 participants