Test-server extension: use shared configuration base and test facilities#512
Conversation
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Will still fail the test because of mismatched expectations, but this will help merging master periodically in here to verify (almost) all is well. Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
|
@pamorgan please review and assign back to me once done. |
|
Peter is out of office and this PR has been delayed - @qqustc can you please review and assign back to me once done? |
|
Qin doesn't have the bandwidth for a review right now. @wjuan-AFK can you please review and assign back to me once done? |
| sendReply(); | ||
| if (!config_->maybeSendErrorReply(*decoder_callbacks_)) { | ||
| const auto effective_config = config_->getEffectiveConfiguration(); | ||
| if (effective_config.value()->echo_request_headers()) { |
There was a problem hiding this comment.
Should we check that the value is ok instead of just calling value() directly? Or do we prefer to throw an exception here?
There was a problem hiding this comment.
maybeSendErrorReply() will have returned true if the value wasn't OK, so we can't hit this.
There was a problem hiding this comment.
Ah, got it. I had missed the connection between getEffective config and maybeSendError.
| config_->computeEffectiveConfiguration(headers); | ||
| if (end_stream) { | ||
| sendReply(); | ||
| if (!config_->maybeSendErrorReply(*decoder_callbacks_)) { |
There was a problem hiding this comment.
I'm not sure that this is worth bothering with, but I did find it mildly confusing that the result of maybeSendErrorReply is true if it did send an error reply.
There was a problem hiding this comment.
Do you think that this would easier to read if bool maybeSendErrorReply() would be split up into bool haveErrorReply() and void sendErrorReply()?
There was a problem hiding this comment.
Probably. I'm not sure if I'm alone in feeling uncertain on which boolean value to expect from a maybe naming scheme though.
There was a problem hiding this comment.
What if we called it validateOrSendError.
There was a problem hiding this comment.
I was following up on this, I like the suggestion, but while doing that, I realised that the return value would have to be inverted. The maybeXXX "naming scheme" usually returns true iff it did what it said it might do (sendErrorReply() in this case). When we rename to validateOrSendError() the method should probably return true if the configuration was valid? I think this would still be a good change to make, but it would become a little intrusive as there's a bunch of places where this is used already. The good part is that when this PR gets merged, we are in a much better to position to make mechanical refactors like this across all extensions. Filed #558 to track following up.
|
|
||
| TEST_P(HttpTestServerIntegrationTest, TestMaxBoundaryLengthRequest) { | ||
| initializeFilterConfiguration(kDefaultProto); | ||
| const int max = 1024 * 1024 * 4; |
There was a problem hiding this comment.
Why do we define max this way? Is there another expression that would be equivalent?
There was a problem hiding this comment.
This equates to / could be expressed as 4194304, or 0x400000, but I was hoping that the way it is expressed now would be easiest to grok it as being the equivalent of 4MB for readers of this code?
|
|
||
| // Here we test config-level merging as well as its application at the response-header level. | ||
| TEST_F(HttpTestServerDecoderFilterTest, HeaderMerge) { | ||
| TEST(HttpTestServerDecoderFilterTest, HeaderMerge) { |
There was a problem hiding this comment.
I might be misunderstanding how this test works. Is there any chance this could be split into a couple separate cases being tested? It feels like it's trying to test several different kind of header merge.
There was a problem hiding this comment.
You're right, this test has organically grown as different contributors added to it, and splitting this up makes sense.
As this is pre-existing, I prefer to file an issue and address this in a follow up, would you be ok with that?
…refactoring-1 Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
|
LGTM |
…refactoring-1 Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
mum4k
left a comment
There was a problem hiding this comment.
Looks good, just one nit really.
| if (end_stream) { | ||
| sendReply(); | ||
| if (!config_->maybeSendErrorReply(*decoder_callbacks_)) { | ||
| const auto effective_config = config_->getEffectiveConfiguration(); |
There was a problem hiding this comment.
Can we replace the "auto" with a type for improved readability?
| return makeSingleRequest(addr, method, url, body, type, host, content_type, | ||
| request_header_delegate); | ||
| } | ||
| const std::string kDefaultProto = R"EOF( |
There was a problem hiding this comment.
(optional) It is typically not recommended to create globals of object that have non-trivial destructors, since c++ doesn't guarantee or specify the order in which these objects get destructed. So it is very easy to end up in an undefined state where object A depends on B, but B gets destructed before A. We had a lot of crashes of servers while attempting proper shutdown due to this.
A good trick around it is to ensure that the global never gets destructed. One way of doing that is what the original code had, i.e. a constexpr absl::string_view instead of an std::string.
Doesn't really matter here, since this is a test file, so optional. It's just something that triggers my muscle memory.
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
|
Also, added 2bcbb2b, which raises the coverage thresholds to match where we are now. |
Last in a series of PRs to fix #498
This is on par with what we did for the dynamic delay and timing extensions,
but this extension was slightly more complex to begin with, so saving the
best for last ;-)
Signed-off-by: Otto van der Schaaf oschaaf@we-amp.com
Original PR description:
A first step to deduplicate code across the c++ test server extensions, and help us handle
configuration and testing of behaviour consistently.
Intent was for this to be a functional no-op, but added testing uncovered
issues in request post body handling. this solves that, modulo an issue with larger
request bodies vs the dynamic delay filter, which would need further analysis.
Prerequisites: