Skip to content

Commit 267cb56

Browse files
authored
test: deflaking unexpected disconnects permanently (envoyproxy#12939)
Allowing unexpected disconnects by default. Signed-off-by: Alyssa Wilk <[email protected]>
1 parent 2dfaf6e commit 267cb56

38 files changed

+10
-178
lines changed

test/extensions/clusters/aggregate/cluster_integration_test.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,8 @@ class AggregateIntegrationTest : public testing::TestWithParam<Network::Address:
132132

133133
fake_upstreams_.emplace_back(new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_,
134134
timeSystem(), enable_half_close_));
135-
fake_upstreams_[FirstUpstreamIndex]->set_allow_unexpected_disconnects(false);
136135
fake_upstreams_.emplace_back(new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_,
137136
timeSystem(), enable_half_close_));
138-
fake_upstreams_[SecondUpstreamIndex]->set_allow_unexpected_disconnects(false);
139137
cluster1_ = ConfigHelper::buildStaticCluster(
140138
FirstClusterName, fake_upstreams_[FirstUpstreamIndex]->localAddress()->ip()->port(),
141139
Network::Test::getLoopbackAddressString(GetParam()));
@@ -166,7 +164,6 @@ class AggregateIntegrationTest : public testing::TestWithParam<Network::Address:
166164
result = xds_connection_->waitForNewStream(*dispatcher_, xds_stream_);
167165
RELEASE_ASSERT(result, result.message());
168166
xds_stream_->startGrpcStream();
169-
fake_upstreams_[0]->set_allow_unexpected_disconnects(true);
170167
}
171168

172169
envoy::config::cluster::v3::Cluster cluster1_;

test/extensions/clusters/redis/redis_cluster_integration_test.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ class RedisClusterIntegrationTest : public testing::TestWithParam<Network::Addre
262262
const std::string& auth_password = "") {
263263
std::string cluster_slot_request = makeBulkStringArray({"CLUSTER", "SLOTS"});
264264

265-
fake_upstreams_[stream_index]->set_allow_unexpected_disconnects(true);
266-
267265
std::string proxied_cluster_slot_request;
268266

269267
FakeRawConnectionPtr fake_upstream_connection_;

test/extensions/filters/http/dynamic_forward_proxy/proxy_filter_integration_test.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,6 @@ TEST_P(ProxyFilterIntegrationTest, UpstreamTlsInvalidSAN) {
310310
upstream_tls_ = true;
311311
upstream_cert_name_ = "upstream";
312312
setup();
313-
// The upstream connection is going to fail handshake so make sure it can read and we expect
314-
// it to disconnect.
315-
fake_upstreams_[0]->set_allow_unexpected_disconnects(true);
316313
fake_upstreams_[0]->setReadDisableOnNewConnection(false);
317314

318315
codec_client_ = makeHttpConnection(lookupPort("http"));

test/extensions/filters/http/ext_authz/ext_authz_integration_test.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ class ExtAuthzHttpIntegrationTest : public HttpIntegrationTest,
369369
HttpIntegrationTest::createUpstreams();
370370
fake_upstreams_.emplace_back(
371371
new FakeUpstream(0, FakeHttpConnection::Type::HTTP1, version_, timeSystem()));
372-
fake_upstreams_[0]->set_allow_unexpected_disconnects(true);
373372
}
374373

375374
// By default, HTTP Service uses case sensitive string matcher.
@@ -591,7 +590,6 @@ class ExtAuthzLocalReplyIntegrationTest : public HttpIntegrationTest,
591590
HttpIntegrationTest::createUpstreams();
592591
fake_upstreams_.emplace_back(
593592
new FakeUpstream(0, FakeHttpConnection::Type::HTTP1, version_, timeSystem()));
594-
fake_upstreams_[0]->set_allow_unexpected_disconnects(true);
595593
}
596594

597595
void cleanup() {

test/extensions/filters/http/router/auto_sni_integration_test.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class AutoSniIntegrationTest : public testing::TestWithParam<Network::Address::I
4040
void createUpstreams() override {
4141
fake_upstreams_.emplace_back(new FakeUpstream(
4242
createUpstreamSslContext(), 0, FakeHttpConnection::Type::HTTP1, version_, timeSystem()));
43-
fake_upstreams_[0]->set_allow_unexpected_disconnects(true);
4443
}
4544

4645
Network::TransportSocketFactoryPtr createUpstreamSslContext() {

test/extensions/filters/http/squash/squash_filter_integration_test.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class SquashFilterIntegrationTest : public testing::TestWithParam<Network::Addre
7373
HttpIntegrationTest::createUpstreams();
7474
fake_upstreams_.emplace_back(
7575
new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_, timeSystem()));
76-
fake_upstreams_.back()->set_allow_unexpected_disconnects(true);
7776
}
7877

7978
/**

test/extensions/filters/network/thrift_proxy/integration_test.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ TEST_P(ThriftConnManagerIntegrationTest, EarlyClose) {
259259
request_bytes_.toString().substr(0, request_bytes_.length() - 5);
260260

261261
FakeUpstream* expected_upstream = getExpectedUpstream(false);
262-
expected_upstream->set_allow_unexpected_disconnects(true);
263262

264263
IntegrationTcpClientPtr tcp_client = makeTcpConnection(lookupPort("listener_0"));
265264
ASSERT_TRUE(tcp_client->write(partial_request));
@@ -377,7 +376,6 @@ TEST_P(ThriftConnManagerIntegrationTest, OnewayEarlyClosePartialRequest) {
377376
request_bytes_.toString().substr(0, request_bytes_.length() - 1);
378377

379378
FakeUpstream* expected_upstream = getExpectedUpstream(true);
380-
expected_upstream->set_allow_unexpected_disconnects(true);
381379

382380
IntegrationTcpClientPtr tcp_client = makeTcpConnection(lookupPort("listener_0"));
383381
ASSERT_TRUE(tcp_client->write(partial_request));

test/extensions/quic_listeners/quiche/integration/quic_http_integration_test.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,6 @@ TEST_P(QuicHttpIntegrationTest, TestDelayedConnectionTeardownTimeoutTrigger) {
325325

326326
initialize();
327327

328-
fake_upstreams_[0]->set_allow_unexpected_disconnects(true);
329-
330328
codec_client_ = makeHttpConnection(lookupPort("http"));
331329

332330
auto encoder_decoder =
@@ -482,7 +480,6 @@ TEST_P(QuicHttpIntegrationTest, ConnectionMigration) {
482480

483481
TEST_P(QuicHttpIntegrationTest, StopAcceptingConnectionsWhenOverloaded) {
484482
initialize();
485-
fake_upstreams_[0]->set_allow_unexpected_disconnects(true);
486483

487484
// Put envoy in overloaded state and check that it doesn't accept the new client connection.
488485
updateResource(file_updater_1_, 0.9);
@@ -522,7 +519,6 @@ TEST_P(QuicHttpIntegrationTest, StopAcceptingConnectionsWhenOverloaded) {
522519

523520
TEST_P(QuicHttpIntegrationTest, NoNewStreamsWhenOverloaded) {
524521
initialize();
525-
fake_upstreams_[0]->set_allow_unexpected_disconnects(true);
526522
updateResource(file_updater_1_, 0.7);
527523

528524
codec_client_ = makeHttpConnection(makeClientConnection((lookupPort("http"))));

test/extensions/stats_sinks/metrics_service/metrics_service_integration_test.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class MetricsServiceIntegrationTest : public Grpc::VersionedGrpcClientIntegratio
2828
HttpIntegrationTest::createUpstreams();
2929
fake_upstreams_.emplace_back(
3030
new FakeUpstream(0, FakeHttpConnection::Type::HTTP2, version_, timeSystem()));
31-
fake_upstreams_.back()->set_allow_unexpected_disconnects(true);
3231
}
3332

3433
void initialize() override {

test/integration/README.md

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -170,33 +170,4 @@ going on. If your failure mode isn't documented below, ideally some combination
170170
of cerr << logging and trace logs will help you sort out what is going on (and
171171
please add to this document as you figure it out!)
172172
173-
## Unexpected disconnects
174-
175-
As commented in `HttpIntegrationTest::cleanupUpstreamAndDownstream()`, the
176-
tear-down sequence between upstream, Envoy, and client is somewhat sensitive to
177-
ordering. If a given unit test does not use the provided member variables, for
178-
example opens multiple client or upstream connections, the test author should be
179-
aware of test best practices for clean-up which boil down to "Clean up upstream
180-
first".
181-
182-
Upstream connections run in their own threads, so if the client disconnects with
183-
open streams, there's a race where Envoy detects the disconnect, and kills the
184-
corresponding upstream stream, which is indistinguishable from an unexpected
185-
disconnect and triggers test failure. Because the client is run from the main
186-
thread, if upstream is closed first, the client will not detect the inverse
187-
close, so no test failure will occur.
188-
189-
## Unparented upstream connections
190-
191-
The most common failure mode here is if the test adds additional fake
192-
upstreams for *DS connections (ADS, EDS etc) which are not properly shut down
193-
(for a very sensitive test framework)
194-
195-
The failure mode here is that during test teardown one closes the DS connection
196-
and then shuts down Envoy. Unfortunately as Envoy is running in its own thread,
197-
it will try to re-establish the *DS connection, sometimes creating a connection
198-
which is then "unparented". The solution here is to explicitly allow Envoy
199-
reconnects before closing the connection, using
200-
201-
`my_ds_upstream_->set_allow_unexpected_disconnects(true);`
202173

0 commit comments

Comments
 (0)