Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/extensions/filters/http/kill_request/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_test",
"envoy_package",
)
load(
Expand Down Expand Up @@ -49,3 +50,13 @@ envoy_extension_cc_test(
"//test/integration:http_protocol_integration_lib",
],
)

envoy_cc_test(
name = "crash_integration_test",
srcs = ["crash_integration_test.cc"],
deps = [
"//source/extensions/filters/http/kill_request:kill_request_config",
"//test/integration:http_protocol_integration_lib",
"@envoy_api//envoy/extensions/filters/http/kill_request/v3:pkg_cc_proto",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "envoy/extensions/filters/http/kill_request/v3/kill_request.pb.h"

#include "test/integration/http_protocol_integration.h"

#include "gtest/gtest.h"

namespace Envoy {

Comment thread
htuch marked this conversation as resolved.
class CrashIntegrationTest : public Event::TestUsingSimulatedTime,
public HttpProtocolIntegrationTest {
protected:
void initializeFilter(const std::string& filter_config) {
config_helper_.addFilter(filter_config);
initialize();
}
};

// Tests should run with all protocols.
class CrashIntegrationTestAllProtocols : public CrashIntegrationTest {};
INSTANTIATE_TEST_SUITE_P(Protocols, CrashIntegrationTestAllProtocols,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

TEST_P(CrashIntegrationTestAllProtocols, UnwindsTrackedObjectStack) {
const std::string request_kill_config =
R"EOF(
name: envoy.filters.http.kill_request
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.kill_request.v3.KillRequest
probability:
numerator: 100
)EOF";
initializeFilter(request_kill_config);
codec_client_ = makeHttpConnection(makeClientConnection(lookupPort("http")));
const Http::TestRequestHeaderMapImpl request_headers{{":method", "GET"},
{":path", "/test"},
{":scheme", "http"},
{":authority", "host"},
{"x-envoy-kill-request", "true"}};
// We should have the following directly on the tracked object stack and should dump them on
// crash:
// - ActiveStream
// - Http(1|2)::ConnectionImpl
// - Network::ConnectionImpl
const std::string death_string = GetParam().downstream_protocol == Http::CodecClient::Type::HTTP2
? "ActiveStream.*Http2::ConnectionImpl.*ConnectionImpl"
: "ActiveStream.*Http1::ConnectionImpl.*ConnectionImpl";
EXPECT_DEATH(sendRequestAndWaitForResponse(request_headers, 0, default_response_headers_, 1024),
death_string);
}

TEST_P(CrashIntegrationTestAllProtocols, ResponseCrashDumpsTheCorrespondingRequest) {
const std::string response_kill_config =
R"EOF(
name: envoy.filters.http.kill_request
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.kill_request.v3.KillRequest
probability:
numerator: 100
direction: RESPONSE
)EOF";
initializeFilter(response_kill_config);
codec_client_ = makeHttpConnection(makeClientConnection(lookupPort("http")));

const Http::TestResponseHeaderMapImpl kill_response_headers = {{":status", "200"},
{"x-envoy-kill-request", "true"}};
// Check that we dump the downstream request
EXPECT_DEATH(
sendRequestAndWaitForResponse(default_request_headers_, 0, kill_response_headers, 1024),
"Dumping corresponding downstream request.*UpstreamRequest.*request_headers:");
}

} // namespace Envoy