-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
test: adding a multi-envoy test #20016
Changes from 1 commit
1a608f7
951803c
2486a11
8c1e2cc
fa6cb9e
6eedd48
3dfd2f3
ec3d21b
a9a478d
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "test/integration/http_protocol_integration.h" | ||
|
||
namespace Envoy { | ||
namespace { | ||
|
||
class MultiEnvoyTest : public HttpProtocolIntegrationTest { | ||
public: | ||
// Create an envoy in front of the original Envoy. | ||
void createL1Envoy(); | ||
~MultiEnvoyTest() { test_server_.reset(); } | ||
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. nit: destructors usually come before other methods. I'm mildly surprised this doesn't need to be marked override, but C++ is weird. 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. it probably does and clang tidy will catch me :-P Will fix. |
||
|
||
IntegrationTestServerPtr l1_server_; | ||
Thread::SkipAsserts skip_; | ||
}; | ||
|
||
void MultiEnvoyTest::createL1Envoy() { | ||
std::vector<uint32_t> ports; | ||
std::vector<uint32_t> zero; | ||
int l2_port = lookupPort("http"); | ||
for (auto& upstream : fake_upstreams_) { | ||
if (upstream->localAddress()->ip()) { | ||
ports.push_back(l2_port); | ||
zero.push_back(0); | ||
} | ||
} | ||
ConfigHelper l1_helper(version_, *api_, | ||
MessageUtil::getJsonStringFromMessageOrDie(config_helper_.bootstrap())); | ||
l1_helper.setPorts(zero, true); // Zero out ports set by config_helper_'s finalize(); | ||
const std::string bootstrap_path = finalizeConfigWithPorts(l1_helper, ports, use_lds_); | ||
|
||
std::vector<std::string> named_ports; | ||
const auto& static_resources = config_helper_.bootstrap().static_resources(); | ||
named_ports.reserve(static_resources.listeners_size()); | ||
for (int i = 0; i < static_resources.listeners_size(); ++i) { | ||
named_ports.push_back(static_resources.listeners(i).name() + "_l1"); | ||
} | ||
createGeneratedApiTestServer(bootstrap_path, named_ports, {false, true, false}, false, | ||
l1_server_); | ||
} | ||
|
||
INSTANTIATE_TEST_SUITE_P(IpVersions, MultiEnvoyTest, | ||
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams( | ||
{Http::CodecType::HTTP1}, {Http::CodecType::HTTP1})), | ||
HttpProtocolIntegrationTest::protocolTestParamsToString); | ||
|
||
// A simple test to make sure that traffic can flow between client - L1 - L2 - upstream. | ||
// This test does not currently support mixed protocol hops, or much of the other envoy test | ||
// framework knobs. | ||
TEST_P(MultiEnvoyTest, SimpleRequestAndResponse) { | ||
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. Nice! Would it also make sense (perhaps as a follow up?) to have a test in which we create 2 distinct Envoy instances, both in front of the same (or different, I suppose) upstreams. Then we could verify that requests flow through both, close one, and verify that the other still works? 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. yeah I also plan on having tests where I tear down the L2 and verify the L1 500s correctly, or tear down L1 and make sure I can talk directly to L2 -> client, to ensure lifetime issues are really sorted and regression tested against. 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. Having some tests that verify different shutdown ordering would be useful I think, just to make sure that they can exist independently of each other |
||
config_helper_.addRuntimeOverride("envoy.restart_features.no_runtime_singleton", "true"); | ||
initialize(); | ||
createL1Envoy(); | ||
|
||
codec_client_ = makeHttpConnection(lookupPort("http_l1")); | ||
auto response = | ||
sendRequestAndWaitForResponse(default_request_headers_, 0, default_response_headers_, 0); | ||
EXPECT_EQ(1, test_server_->counter("http.config_test.rq_total")); | ||
EXPECT_EQ(1, l1_server_->counter("http.config_test.rq_total")); | ||
|
||
l1_server_.reset(); | ||
} | ||
|
||
} // namespace | ||
} // namespace Envoy |
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.
I would have expected this to delegate to InstanceImpl::runtime(). But does that not work because ValidationInstance does not extend InstanceImpl?
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.
exactly. arguably I should do the same restart flag checks here, but I'lll get there in the PR I flip the runtime guard true by default.