forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcircuit_breakers_integration_test.cc
68 lines (49 loc) · 2.87 KB
/
circuit_breakers_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
#include "envoy/config/bootstrap/v3/bootstrap.pb.h"
#include "test/integration/http_protocol_integration.h"
namespace Envoy {
namespace {
class CircuitBreakersIntegrationTest : public HttpProtocolIntegrationTest {
public:
void initialize() override { HttpProtocolIntegrationTest::initialize(); }
};
INSTANTIATE_TEST_SUITE_P(Protocols, CircuitBreakersIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);
// This test checks that triggered max requests circuit breaker
// doesn't force outlier detectors to eject an upstream host.
// See https://github.com/envoyproxy/envoy/issues/25487
TEST_P(CircuitBreakersIntegrationTest, CircuitBreakersWithOutlierDetection) {
config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) {
auto* static_resources = bootstrap.mutable_static_resources();
auto* cluster = static_resources->mutable_clusters(0);
// Somewhat contrived with 0, but this is the simplest way to test right now.
auto* circuit_breakers = cluster->mutable_circuit_breakers();
circuit_breakers->add_thresholds()->mutable_max_requests()->set_value(0);
auto* outlier_detection = cluster->mutable_outlier_detection();
outlier_detection->mutable_consecutive_gateway_failure()->set_value(1);
outlier_detection->mutable_consecutive_5xx()->set_value(1);
outlier_detection->mutable_consecutive_local_origin_failure()->set_value(1);
outlier_detection->mutable_enforcing_consecutive_gateway_failure()->set_value(100);
outlier_detection->mutable_enforcing_consecutive_5xx()->set_value(100);
outlier_detection->mutable_enforcing_consecutive_local_origin_failure()->set_value(100);
outlier_detection->set_split_external_local_origin_errors(true);
outlier_detection->mutable_max_ejection_percent()->set_value(100);
outlier_detection->mutable_interval()->set_nanos(1);
outlier_detection->mutable_base_ejection_time()->set_seconds(3600);
outlier_detection->mutable_max_ejection_time()->set_seconds(3600);
});
initialize();
codec_client_ = makeHttpConnection(lookupPort("http"));
auto response = codec_client_->makeRequestWithBody(default_request_headers_, 1024);
test_server_->waitForGaugeEq("cluster.cluster_0.upstream_rq_active", 0);
test_server_->waitForGaugeEq("cluster.cluster_0.upstream_rq_pending_active", 0);
ASSERT_TRUE(response->waitForEndStream());
EXPECT_EQ("503", response->headers().getStatusValue());
test_server_->waitForCounterGe("cluster.cluster_0.upstream_rq_503", 1);
EXPECT_EQ(test_server_->counter("cluster.cluster_0.upstream_rq_pending_overflow")->value(), 1);
EXPECT_EQ(test_server_->counter("cluster.cluster_0.outlier_detection.ejections_enforced_total")
->value(),
0);
}
} // namespace
} // namespace Envoy