Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion source/server/listener_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ListenSocketFactoryImpl::ListenSocketFactoryImpl(

if (local_address_->type() == Network::Address::Type::Ip) {
if (socket_type == Network::Socket::Type::Datagram) {
ASSERT(bind_type_ == ListenerComponentFactory::BindType::ReusePort);
ASSERT(bind_type_ == ListenerComponentFactory::BindType::ReusePort || num_sockets == 1u);
}
} else {
if (local_address_->type() == Network::Address::Type::Pipe) {
Expand Down
7 changes: 7 additions & 0 deletions test/config/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,13 @@ void ConfigHelper::addSslConfig(const ServerSslOptions& options) {
}

void ConfigHelper::addQuicDownstreamTransportSocketConfig() {
for (auto& listener : *bootstrap_.mutable_static_resources()->mutable_listeners()) {
if (listener.udp_listener_config().has_quic_options()) {
// Disable SO_REUSEPORT, because it undesirably allows parallel test jobs to use the same
// port.
listener.mutable_enable_reuse_port()->set_value(false);
}
}
configDownstreamTransportSocketWithTls(
bootstrap_,
[](envoy::extensions::transport_sockets::tls::v3::CommonTlsContext& common_tls_context) {
Expand Down
40 changes: 33 additions & 7 deletions test/integration/quic_http_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ class QuicHttpIntegrationTest : public HttpIntegrationTest,
IntegrationCodecClientPtr makeRawHttpConnection(
Network::ClientConnectionPtr&& conn,
absl::optional<envoy::config::core::v3::Http2ProtocolOptions> http2_options) override {
ENVOY_LOG(debug, "Creating a new client {}",
conn->connectionInfoProvider().localAddress()->asStringView());
return makeRawHttp3Connection(std::move(conn), http2_options, true);
}

Expand Down Expand Up @@ -270,8 +272,24 @@ class QuicHttpIntegrationTest : public HttpIntegrationTest,
ASSERT(&transport_socket_factory_->clientContextConfig());
}

void setConcurrency(size_t concurrency) {
concurrency_ = concurrency;
if (concurrency > 1) {
config_helper_.addConfigModifier(
[=](envoy::config::bootstrap::v3::Bootstrap& bootstrap) -> void {
// SO_REUSEPORT is needed because concurrency > 1.
bootstrap.mutable_static_resources()
->mutable_listeners(0)
->mutable_enable_reuse_port()
->set_value(true);
});
}
}

void testMultipleQuicConnections() {
concurrency_ = 8;
// Enabling SO_REUSEPORT with 8 workers. Unfortunately this setting makes the test rarely flaky
// if it is configured to run with --runs_per_test=N where N > 1 but without --jobs=1.
setConcurrency(8);
initialize();
std::vector<IntegrationCodecClientPtr> codec_clients;
for (size_t i = 1; i <= concurrency_; ++i) {
Expand Down Expand Up @@ -318,7 +336,7 @@ class QuicHttpIntegrationTest : public HttpIntegrationTest,
{":authority", "host"}});
auto& request_encoder = encoder_decoder.first;
auto response = std::move(encoder_decoder.second);
codec_clients[i]->sendData(request_encoder, 0, true);
codec_clients[i]->sendData(request_encoder, 1000, true);
waitForNextUpstreamRequest();
upstream_request_->encodeHeaders(Http::TestResponseHeaderMapImpl{{":status", "200"},
{"set-cookie", "foo"},
Expand Down Expand Up @@ -480,15 +498,23 @@ TEST_P(QuicHttpIntegrationTest, MultipleQuicConnectionsNoBPF) {
// Tests that the packets from a connection with CID longer than 8 bytes are routed to the same
// worker.
TEST_P(QuicHttpIntegrationTest, MultiWorkerWithLongConnectionId) {
concurrency_ = 8;
setConcurrency(8);
config_helper_.addConfigModifier([=](envoy::config::bootstrap::v3::Bootstrap& bootstrap) -> void {
// SO_REUSEPORT is needed because concurrency > 1.
bootstrap.mutable_static_resources()
->mutable_listeners(0)
->mutable_enable_reuse_port()
->set_value(true);
});

initialize();
// Setup 9-byte CID for the next connection.
designated_connection_ids_.push_back(quic::test::TestConnectionIdNineBytesLong(2u));
testRouterHeaderOnlyRequestAndResponse();
}

TEST_P(QuicHttpIntegrationTest, PortMigration) {
concurrency_ = 2;
setConcurrency(2);
initialize();
uint32_t old_port = lookupPort("http");
codec_client_ = makeHttpConnection(old_port);
Expand Down Expand Up @@ -544,7 +570,7 @@ TEST_P(QuicHttpIntegrationTest, PortMigration) {
}

TEST_P(QuicHttpIntegrationTest, PortMigrationOnPathDegrading) {
concurrency_ = 2;
setConcurrency(2);
initialize();
client_quic_options_.mutable_num_timeouts_to_trigger_port_migration()->set_value(2);
uint32_t old_port = lookupPort("http");
Expand Down Expand Up @@ -587,7 +613,7 @@ TEST_P(QuicHttpIntegrationTest, PortMigrationOnPathDegrading) {
}

TEST_P(QuicHttpIntegrationTest, NoPortMigrationWithoutConfig) {
concurrency_ = 2;
setConcurrency(2);
initialize();
client_quic_options_.mutable_num_timeouts_to_trigger_port_migration()->set_value(0);
uint32_t old_port = lookupPort("http");
Expand Down Expand Up @@ -625,7 +651,7 @@ TEST_P(QuicHttpIntegrationTest, NoPortMigrationWithoutConfig) {
}

TEST_P(QuicHttpIntegrationTest, PortMigrationFailureOnPathDegrading) {
concurrency_ = 2;
setConcurrency(2);
validation_failure_on_path_response_ = true;
initialize();
uint32_t old_port = lookupPort("http");
Expand Down