forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxds_integration_test.cc
85 lines (69 loc) · 3.38 KB
/
xds_integration_test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "test/integration/http_integration.h"
#include "test/integration/http_protocol_integration.h"
#include "test/test_common/environment.h"
#include "test/test_common/utility.h"
#include "gtest/gtest.h"
namespace Envoy {
namespace {
using testing::HasSubstr;
// This is a minimal litmus test for the v2 xDS APIs.
class XdsIntegrationTest : public testing::TestWithParam<Network::Address::IpVersion>,
public HttpIntegrationTest {
public:
XdsIntegrationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP2, GetParam()) {
setUpstreamProtocol(FakeHttpConnection::Type::HTTP2);
}
void createEnvoy() override {
registerPort("upstream_0", fake_upstreams_.back()->localAddress()->ip()->port());
createApiTestServer(
{
"test/config/integration/server_xds.bootstrap.yaml",
"test/config/integration/server_xds.cds.yaml",
"test/config/integration/server_xds.eds.yaml",
"test/config/integration/server_xds.lds.yaml",
"test/config/integration/server_xds.rds.yaml",
},
{"http"});
}
};
INSTANTIATE_TEST_SUITE_P(IpVersions, XdsIntegrationTest,
testing::ValuesIn(TestEnvironment::getIpVersionsForTest()),
TestUtility::ipTestParamsToString);
TEST_P(XdsIntegrationTest, RouterRequestAndResponseWithBodyNoBuffer) {
testRouterRequestAndResponseWithBody(1024, 512, false);
}
using LdsIntegrationTest = HttpProtocolIntegrationTest;
INSTANTIATE_TEST_SUITE_P(Protocols, LdsIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams(
{Http::CodecClient::Type::HTTP1}, {FakeHttpConnection::Type::HTTP1})),
HttpProtocolIntegrationTest::protocolTestParamsToString);
// Sample test making sure our config framework correctly reloads listeners.
TEST_P(LdsIntegrationTest, ReloadConfig) {
autonomous_upstream_ = true;
initialize();
// Given we're using LDS in this test, initialize() will not complete until
// the initial LDS file has loaded.
EXPECT_EQ(1, test_server_->counter("listener_manager.lds.update_success")->value());
fake_upstreams_[0]->set_allow_unexpected_disconnects(true);
// HTTP 1.0 is disabled by default.
std::string response;
sendRawHttpAndWaitForResponse(lookupPort("http"), "GET / HTTP/1.0\r\n\r\n", &response, true);
EXPECT_TRUE(response.find("HTTP/1.1 426 Upgrade Required\r\n") == 0);
// Create a new config with HTTP/1.0 proxying.
ConfigHelper new_config_helper(version_, *api_,
MessageUtil::getJsonStringFromMessage(config_helper_.bootstrap()));
new_config_helper.addConfigModifier(
[&](envoy::config::filter::network::http_connection_manager::v2::HttpConnectionManager& hcm) {
hcm.mutable_http_protocol_options()->set_accept_http_10(true);
hcm.mutable_http_protocol_options()->set_default_host_for_http_10("default.com");
});
// Create an LDS response with the new config, and reload config.
new_config_helper.setLds("1");
test_server_->waitForCounterGe("listener_manager.lds.update_success", 2);
// HTTP 1.0 should now be enabled.
std::string response2;
sendRawHttpAndWaitForResponse(lookupPort("http"), "GET / HTTP/1.0\r\n\r\n", &response2, false);
EXPECT_THAT(response2, HasSubstr("HTTP/1.0 200 OK\r\n"));
}
} // namespace
} // namespace Envoy