Add generic c++ integration test for uniform extension behavior. #533
Add generic c++ integration test for uniform extension behavior. #533mum4k merged 19 commits intoenvoyproxy:masterfrom
Conversation
- Extracts shared needs between tested extensions. - Sanitized api, better naming. - Doc comments. - Support for testing POST request methods and entity bodies to check the alternative flow that will trigger in extensions when using that. Prelude to envoyproxy#512, which includes it and provides a means to see the end goal. Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…r-prelude Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…r-prelude Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…r-prelude Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Split out from envoyproxy#512 Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com> ------ Prerequisite: - [ ] Land envoyproxy#517
…r-prelude Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…lude-3 Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
2900d37 to
97322d8
Compare
…r-prelude Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…lude-3 Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…r-prelude-3 Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Switch tests for these extensions to use the recent shared test facilities. Eliminate tests we generalized in envoyproxy#533. Split out from envoyproxy#512 Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
|
@wjuan-AFK please review and assign back to me once done. |
…r-prelude-3 Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
|
Can't reproduce the clang-tidy failure locally, and in CI it doesn't state a specific complaint. |
|
🔨 rebuilding |
|
Yup, clang-tidy flaked in CI for this PR, which is unusual :-( Filed #546 to put in on the radar. |
test/server/http_filter_base_test.cc
Outdated
| // - Bad request-level json configuration. | ||
| // We will be low on functional expectations for the extensions, but this will catch hangs and | ||
| // ensure that bad configuration handling is in-place. | ||
| TEST_P(HttpFilterBaseIntegrationTest, BasicExtensionFlows) { |
There was a problem hiding this comment.
Should we split these into separate tests? I'm not sure what the preference in the code base is, but it seems like each chunk is testing a different behaviour and might deserve a separate test?
There was a problem hiding this comment.
I can see your point, and in general I agree that the clearer test names that arise out of more finely grained separate tests are better.
But in this case, when splitting this, up we would have to duplicate the parameter unpacking for the TEST_P params across the newly split up tests and/or add facilities to help with that.
This was also sort of pre-existing (as we can eliminate three different instances of similar code in the test code for three extensions).
So personally I lean towards the compact version as is is now. With the context above, are you comfortable with leaving this as-is?
There was a problem hiding this comment.
Yeah, makes sense to me.
test/server/http_filter_base_test.cc
Outdated
| EXPECT_EQ("200", response->headers().Status()->value().getStringView()); | ||
| EXPECT_TRUE(response->body().empty()); | ||
|
|
||
| const std::string kBadConfigErrorSentinel = |
There was a problem hiding this comment.
Why not use status instead of doing this substring check?
There was a problem hiding this comment.
We do check the http response code, but then also look for this substring in the response body because we know it should look like that if the extension under test is using the shared configuration handling code. Does that sound good?
There was a problem hiding this comment.
Yes. That also makes sense.
test/server/http_filter_base_test.cc
Outdated
|
|
||
| namespace Nighthawk { | ||
|
|
||
| using namespace testing; |
There was a problem hiding this comment.
Do we need this, since most symbols from the namespace are qualified? E.g. ::testing::Combine.
If you do prefer to shorten them, can we list them explicitly instead of subscribing to the entire testing namespace which could cause a conflict and confuse someone in the future?
E.g. for symbols that repeat a lot we can:
using ::testing::Combine;
using ::testing::ValuesIn;
There was a problem hiding this comment.
Done; added an anonymous namespace as well based on that it can only benefit us.
test/server/http_filter_base_test.cc
Outdated
| // - Bad request-level json configuration. | ||
| // We will be low on functional expectations for the extensions, but this will catch hangs and | ||
| // ensure that bad configuration handling is in-place. | ||
| TEST_P(HttpFilterBaseIntegrationTest, BasicExtensionFlows) { |
There was a problem hiding this comment.
Adding to what @wjuan-AFK commented on - it would really help if we can separate these into individual test cases - one per behavior. Such approach simplifies future code changes, because it ensures that the tests won't be affected when a new behavior is added or that less tests are affected when a behavior is changed. Additionally when a behavior breaks, we get a clear signal which behavior broke, rather than a generic failure saying "the BasicExtensionFlows no longer works".
I see your point about duplicating the parameter unpacking. I wonder if we could place that into a separate helper function. If we figure out we can't, I think we should prefer more instances of smaller independent tests for individual behavior to shorter code that uses parametrised tests. In other words, if we need to drop the parametrised test approach and write few more test cases, I think that is a worthwhile price to pay for shorter and easier to maintain test cases.
Can we burn another cycle on this and see if we can find a win-win solution?
There was a problem hiding this comment.
I will take a look. Hopefully a convenient helper will suffice to support this, and then I can split these out into different tests. I'd like to avoid the need to drop parameterized testing here if we can: we would not only have to duplicate the test(s) for our three current extensions, but also require that for future extensions that would want to piggy back on this.
There was a problem hiding this comment.
Done in 5ff6d56.
@wjuan-AFK sorry, this was actually straight forward, and looking at the results, I rather like it better compared to what it was.
…r-prelude-3 Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
mum4k
left a comment
There was a problem hiding this comment.
Looks great, thank you for splitting them up.
Test basic behavioural properties of all test-server extensions. Any new extensions
may piggy-back on this by enlisting themselves. In a follow up we'll purge code
from the pre-existing tests that can now be deprecated.
Split out from #512
Signed-off-by: Otto van der Schaaf oschaaf@we-amp.com
Prerequisite: