| Index: net/tools/quic/end_to_end_test.cc
|
| diff --git a/net/tools/quic/end_to_end_test.cc b/net/tools/quic/end_to_end_test.cc
|
| index 60402db032d2ffd877b673aefb561c290a55efe8..384d4b12e6a1d97e7fbfbcd35a04f261dd79df03 100644
|
| --- a/net/tools/quic/end_to_end_test.cc
|
| +++ b/net/tools/quic/end_to_end_test.cc
|
| @@ -23,8 +23,10 @@
|
| #include "net/quic/quic_protocol.h"
|
| #include "net/quic/quic_sent_packet_manager.h"
|
| #include "net/quic/quic_server_id.h"
|
| +#include "net/quic/quic_utils.h"
|
| #include "net/quic/test_tools/quic_connection_peer.h"
|
| #include "net/quic/test_tools/quic_flow_controller_peer.h"
|
| +#include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
|
| #include "net/quic/test_tools/quic_session_peer.h"
|
| #include "net/quic/test_tools/quic_test_utils.h"
|
| #include "net/quic/test_tools/reliable_quic_stream_peer.h"
|
| @@ -52,6 +54,7 @@ using net::EpollServer;
|
| using net::test::GenerateBody;
|
| using net::test::QuicConnectionPeer;
|
| using net::test::QuicFlowControllerPeer;
|
| +using net::test::QuicSentPacketManagerPeer;
|
| using net::test::QuicSessionPeer;
|
| using net::test::ReliableQuicStreamPeer;
|
| using net::test::ValueRestore;
|
| @@ -77,12 +80,14 @@ struct TestParams {
|
| const QuicVersionVector& server_supported_versions,
|
| QuicVersion negotiated_version,
|
| bool use_pacing,
|
| - bool use_fec)
|
| + bool use_fec,
|
| + QuicTag congestion_control_tag)
|
| : client_supported_versions(client_supported_versions),
|
| server_supported_versions(server_supported_versions),
|
| negotiated_version(negotiated_version),
|
| use_pacing(use_pacing),
|
| - use_fec(use_fec) {
|
| + use_fec(use_fec),
|
| + congestion_control_tag(congestion_control_tag) {
|
| }
|
|
|
| friend ostream& operator<<(ostream& os, const TestParams& p) {
|
| @@ -92,7 +97,9 @@ struct TestParams {
|
| << QuicVersionVectorToString(p.client_supported_versions);
|
| os << " negotiated_version: " << QuicVersionToString(p.negotiated_version);
|
| os << " use_pacing: " << p.use_pacing;
|
| - os << " use_fec: " << p.use_fec << " }";
|
| + os << " use_fec: " << p.use_fec;
|
| + os << " congestion_control_tag: "
|
| + << QuicUtils::TagToString(p.congestion_control_tag) << " }";
|
| return os;
|
| }
|
|
|
| @@ -101,39 +108,51 @@ struct TestParams {
|
| QuicVersion negotiated_version;
|
| bool use_pacing;
|
| bool use_fec;
|
| + QuicTag congestion_control_tag;
|
| };
|
|
|
| // Constructs various test permutations.
|
| vector<TestParams> GetTestParams() {
|
| vector<TestParams> params;
|
| QuicVersionVector all_supported_versions = QuicSupportedVersions();
|
| - for (int use_fec = 0; use_fec < 2; ++use_fec) {
|
| - for (int use_pacing = 0; use_pacing < 2; ++use_pacing) {
|
| - // Add an entry for server and client supporting all versions.
|
| - params.push_back(TestParams(all_supported_versions,
|
| - all_supported_versions,
|
| - all_supported_versions[0],
|
| - use_pacing != 0,
|
| - use_fec != 0));
|
| -
|
| - // Test client supporting all versions and server supporting 1 version.
|
| - // Simulate an old server and exercise version downgrade in the client.
|
| - // Protocol negotiation should occur. Skip the i = 0 case because it is
|
| - // essentially the same as the default case.
|
| - for (size_t i = 1; i < all_supported_versions.size(); ++i) {
|
| - QuicVersionVector server_supported_versions;
|
| - server_supported_versions.push_back(all_supported_versions[i]);
|
| - if (all_supported_versions[i] >= QUIC_VERSION_18) {
|
| - // Until flow control is globally rolled out and we remove
|
| - // QUIC_VERSION_16, the server MUST support at least one QUIC version
|
| - // that does not use flow control.
|
| - server_supported_versions.push_back(QUIC_VERSION_16);
|
| - }
|
| + // TODO(rtenneti): Add kTBBR after BBR code is checked in.
|
| + // QuicTag congestion_control_tags[] = {kRENO, kTBBR, kQBIC};
|
| + QuicTag congestion_control_tags[] = {kRENO, kQBIC};
|
| + for (size_t congestion_control_index = 0;
|
| + congestion_control_index < arraysize(congestion_control_tags);
|
| + congestion_control_index++) {
|
| + QuicTag congestion_control_tag =
|
| + congestion_control_tags[congestion_control_index];
|
| + for (int use_fec = 0; use_fec < 2; ++use_fec) {
|
| + for (int use_pacing = 0; use_pacing < 2; ++use_pacing) {
|
| + // Add an entry for server and client supporting all versions.
|
| params.push_back(TestParams(all_supported_versions,
|
| - server_supported_versions,
|
| - server_supported_versions[0],
|
| + all_supported_versions,
|
| + all_supported_versions[0],
|
| use_pacing != 0,
|
| - use_fec != 0));
|
| + use_fec != 0,
|
| + congestion_control_tag));
|
| +
|
| + // Test client supporting all versions and server supporting 1 version.
|
| + // Simulate an old server and exercise version downgrade in the client.
|
| + // Protocol negotiation should occur. Skip the i = 0 case because it is
|
| + // essentially the same as the default case.
|
| + for (size_t i = 1; i < all_supported_versions.size(); ++i) {
|
| + QuicVersionVector server_supported_versions;
|
| + server_supported_versions.push_back(all_supported_versions[i]);
|
| + if (all_supported_versions[i] >= QUIC_VERSION_18) {
|
| + // Until flow control is globally rolled out and we remove
|
| + // QUIC_VERSION_16, the server MUST support at least one QUIC
|
| + // version that does not use flow control.
|
| + server_supported_versions.push_back(QUIC_VERSION_16);
|
| + }
|
| + params.push_back(TestParams(all_supported_versions,
|
| + server_supported_versions,
|
| + server_supported_versions[0],
|
| + use_pacing != 0,
|
| + use_fec != 0,
|
| + congestion_control_tag));
|
| + }
|
| }
|
| }
|
| }
|
| @@ -265,13 +284,28 @@ class EndToEndTest : public ::testing::TestWithParam<TestParams> {
|
| server_config_.SetInitialSessionFlowControlWindowToSend(window);
|
| }
|
|
|
| + const QuicSentPacketManager *
|
| + GetSentPacketManagerFromFirstServerSession() const {
|
| + QuicDispatcher* dispatcher =
|
| + QuicServerPeer::GetDispatcher(server_thread_->server());
|
| + QuicSession* session = dispatcher->session_map().begin()->second;
|
| + return &session->connection()->sent_packet_manager();
|
| + }
|
| +
|
| bool Initialize() {
|
| + QuicTagVector copt;
|
| +
|
| + // TODO(nimia): Consider setting the congestion control algorithm for the
|
| + // client as well according to the test parameter.
|
| + copt.push_back(GetParam().congestion_control_tag);
|
| +
|
| if (GetParam().use_fec) {
|
| // Set FEC config in client's connection options and in client session.
|
| - QuicTagVector copt;
|
| copt.push_back(kFHDR);
|
| - client_config_.SetConnectionOptionsToSend(copt);
|
| }
|
| +
|
| + client_config_.SetConnectionOptionsToSend(copt);
|
| +
|
| // Start the server first, because CreateQuicClient() attempts
|
| // to connect to the server.
|
| StartServer();
|
| @@ -864,6 +898,31 @@ TEST_P(EndToEndTest, NegotiateMaxOpenStreams) {
|
| EXPECT_EQ(QUIC_TOO_MANY_OPEN_STREAMS, client_->connection_error());
|
| }
|
|
|
| +TEST_P(EndToEndTest, NegotiateCongestionControl) {
|
| + ASSERT_TRUE(Initialize());
|
| + client_->client()->WaitForCryptoHandshakeConfirmed();
|
| +
|
| + CongestionControlType expected_congestion_control_type;
|
| + switch (GetParam().congestion_control_tag) {
|
| + case kRENO:
|
| + expected_congestion_control_type = kReno;
|
| + break;
|
| + case kTBBR:
|
| + expected_congestion_control_type = kBBR;
|
| + break;
|
| + case kQBIC:
|
| + expected_congestion_control_type = kCubic;
|
| + break;
|
| + default:
|
| + DLOG(FATAL) << "Unexpected congestion control tag";
|
| + }
|
| +
|
| + EXPECT_EQ(expected_congestion_control_type,
|
| + QuicSentPacketManagerPeer::GetCongestionControlAlgorithm(
|
| + *GetSentPacketManagerFromFirstServerSession())
|
| + ->GetCongestionControlType());
|
| +}
|
| +
|
| TEST_P(EndToEndTest, LimitMaxOpenStreams) {
|
| // Server limits the number of max streams to 2.
|
| server_config_.set_max_streams_per_connection(2, 2);
|
| @@ -893,11 +952,10 @@ TEST_P(EndToEndTest, DISABLED_LimitCongestionWindowAndRTT) {
|
| QuicDispatcher* dispatcher =
|
| QuicServerPeer::GetDispatcher(server_thread_->server());
|
| ASSERT_EQ(1u, dispatcher->session_map().size());
|
| - QuicSession* session = dispatcher->session_map().begin()->second;
|
| const QuicSentPacketManager& client_sent_packet_manager =
|
| client_->client()->session()->connection()->sent_packet_manager();
|
| const QuicSentPacketManager& server_sent_packet_manager =
|
| - session->connection()->sent_packet_manager();
|
| + *GetSentPacketManagerFromFirstServerSession();
|
|
|
| // The client shouldn't set it's initial window based on the negotiated value.
|
| EXPECT_EQ(kDefaultInitialWindow * kDefaultTCPMSS,
|
|
|