Chromium Code Reviews| 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 ef394b95f2453d21588a6cd1b170418d42ce7697..88788cca68b354dca035875ab0f7f491af9f0e30 100644 |
| --- a/net/tools/quic/end_to_end_test.cc |
| +++ b/net/tools/quic/end_to_end_test.cc |
| @@ -28,6 +28,7 @@ |
| #include "net/quic/test_tools/quic_test_utils.h" |
| #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
| #include "net/test/gtest_util.h" |
| +#include "net/tools/epoll_server/epoll_server.h" |
| #include "net/tools/quic/quic_epoll_connection_helper.h" |
| #include "net/tools/quic/quic_in_memory_cache.h" |
| #include "net/tools/quic/quic_packet_writer_wrapper.h" |
| @@ -46,6 +47,7 @@ |
| using base::StringPiece; |
| using base::WaitableEvent; |
| +using net::EpollServer; |
| using net::test::GenerateBody; |
| using net::test::QuicConnectionPeer; |
| using net::test::QuicSessionPeer; |
| @@ -481,7 +483,7 @@ TEST_P(EndToEndTest, DISABLED_LargePostNoPacketLoss) { |
| client_->client()->WaitForCryptoHandshakeConfirmed(); |
| - // 1 Mb body. |
| + // 1 MB body. |
| string body; |
| GenerateBody(&body, 1024 * 1024); |
| @@ -499,7 +501,7 @@ TEST_P(EndToEndTest, LargePostNoPacketLoss1sRTT) { |
| client_->client()->WaitForCryptoHandshakeConfirmed(); |
| - // 1 Mb body. |
| + // 100 KB body. |
| string body; |
| GenerateBody(&body, 100 * 1024); |
| @@ -521,7 +523,7 @@ TEST_P(EndToEndTest, LargePostWithPacketLoss) { |
| client_->client()->WaitForCryptoHandshakeConfirmed(); |
| SetPacketLossPercentage(30); |
| - // 10 Kb body. |
| + // 10 KB body. |
| string body; |
| GenerateBody(&body, 1024 * 10); |
| @@ -530,42 +532,42 @@ TEST_P(EndToEndTest, LargePostWithPacketLoss) { |
| request.AddBody(body, true); |
| EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
| + VerifyCleanConnection(true); |
| } |
| -TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) { |
| +TEST_P(EndToEndTest, LargePostWithPacketLossAndBlockedSocket) { |
| + // Connect with lower fake packet loss than we'd like to test. Until |
| + // b/10126687 is fixed, losing handshake packets is pretty brutal. |
| + SetPacketLossPercentage(5); |
| ASSERT_TRUE(Initialize()); |
| + // Wait for the server SHLO before upping the packet loss. |
| client_->client()->WaitForCryptoHandshakeConfirmed(); |
| - // Both of these must be called when the writer is not actively used. |
| - SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); |
| - SetReorderPercentage(30); |
| + SetPacketLossPercentage(10); |
| + client_writer_->set_fake_blocked_socket_percentage(10); |
| - // 1 Mb body. |
| + // 10 KB body. |
| string body; |
| - GenerateBody(&body, 1024 * 1024); |
| + GenerateBody(&body, 1024 * 10); |
| HTTPMessage request(HttpConstants::HTTP_1_1, |
| HttpConstants::POST, "/foo"); |
| request.AddBody(body, true); |
| EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
| - VerifyCleanConnection(true); |
| } |
| -TEST_P(EndToEndTest, LargePostWithPacketLossAndBlockedSocket) { |
| - // Connect with lower fake packet loss than we'd like to test. Until |
| - // b/10126687 is fixed, losing handshake packets is pretty brutal. |
| - SetPacketLossPercentage(5); |
| +TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) { |
| ASSERT_TRUE(Initialize()); |
| - // Wait for the server SHLO before upping the packet loss. |
| client_->client()->WaitForCryptoHandshakeConfirmed(); |
| - SetPacketLossPercentage(10); |
| - client_writer_->set_fake_blocked_socket_percentage(10); |
| + // Both of these must be called when the writer is not actively used. |
| + SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); |
| + SetReorderPercentage(30); |
| - // 10 Kb body. |
| + // 1 MB body. |
| string body; |
| - GenerateBody(&body, 1024 * 10); |
| + GenerateBody(&body, 1024 * 1024); |
| HTTPMessage request(HttpConstants::HTTP_1_1, |
| HttpConstants::POST, "/foo"); |
| @@ -655,19 +657,17 @@ TEST_P(EndToEndTest, LargePostFEC) { |
| VerifyCleanConnection(true); |
| } |
| -// TODO(rtenneti): DISABLED_LargePostLargeBuffer seems to be flaky. |
| -// http://crbug.com/370087. |
| -TEST_P(EndToEndTest, DISABLED_LargePostLargeBuffer) { |
| +TEST_P(EndToEndTest, LargePostSmallBandwidthLargeBuffer) { |
| ASSERT_TRUE(Initialize()); |
| SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1)); |
| - // 1Mbit per second with a 128k buffer from server to client. Wireless |
| + // 256KB per second with a 256k buffer from server to client. Wireless |
|
wtc
2014/05/13 18:49:23
Nit: 256k => 256KB ?
ramant (doing other things)
2014/05/14 05:33:29
Made this change in https://codereview.chromium.or
|
| // clients commonly have larger buffers, but our max CWND is 200. |
| server_writer_->set_max_bandwidth_and_buffer_size( |
| - QuicBandwidth::FromBytesPerSecond(256 * 1024), 128 * 1024); |
| + QuicBandwidth::FromBytesPerSecond(256 * 1024), 256 * 1024); |
| client_->client()->WaitForCryptoHandshakeConfirmed(); |
| - // 1 Mb body. |
| + // 1 MB body. |
| string body; |
| GenerateBody(&body, 1024 * 1024); |
| @@ -676,6 +676,8 @@ TEST_P(EndToEndTest, DISABLED_LargePostLargeBuffer) { |
| request.AddBody(body, true); |
| EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
| + // This connection will not drop packets, because the buffer size is larger |
| + // than the default receive window. |
| VerifyCleanConnection(false); |
| } |
| @@ -790,7 +792,7 @@ TEST_P(EndToEndTest, DISABLED_LimitCongestionWindowAndRTT) { |
| // Now use the negotiated limits with packet loss. |
| SetPacketLossPercentage(30); |
| - // 10 Kb body. |
| + // 10 KB body. |
| string body; |
| GenerateBody(&body, 1024 * 10); |
| @@ -953,7 +955,10 @@ class WrongAddressWriter : public QuicPacketWriterWrapper { |
| IPEndPoint self_address_; |
| }; |
| -TEST_P(EndToEndTest, ConnectionMigration) { |
| +TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) { |
| + // Tests that the client's IP can not change during an established QUIC |
| + // connection. If it changes, the connection is closed by the server as we do |
| + // not yet support IP migration. |
| ASSERT_TRUE(Initialize()); |
| EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| @@ -971,6 +976,59 @@ TEST_P(EndToEndTest, ConnectionMigration) { |
| EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error()); |
| } |
| +TEST_P(EndToEndTest, ConnectionMigrationClientPortChanged) { |
| + // Tests that the client's port can change during an established QUIC |
| + // connection, and that doing so does not result in the connection being |
| + // closed by the server. |
| + FLAGS_quic_allow_port_migration = true; |
| + |
| + ASSERT_TRUE(Initialize()); |
| + |
| + EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| + EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| + |
| + // Store the client address which was used to send the first request. |
| + IPEndPoint old_address = client_->client()->client_address(); |
| + |
| + // Stop listening on the old FD. |
| + EpollServer* eps = client_->client()->epoll_server(); |
| + int old_fd = client_->client()->fd(); |
| + eps->UnregisterFD(old_fd); |
| + close(old_fd); |
| + |
| + // Create a new socket, which will result in a new ephemeral port. |
| + QuicClientPeer::CreateUDPSocket(client_->client()); |
| + |
| + // The packet writer needs to be updated to use the new FD. |
| + client_->client()->CreateQuicPacketWriter(); |
| + |
| + // Change the internal state of the client and connection to use the new port, |
| + // this is done because in a real NAT rebinding the client wouldn't see any |
| + // port change, and so expects no change to incoming port. |
| + // This is kind of ugly, but needed as we are simply swapping out the client |
| + // FD rather than any more complex NAT rebinding simulation. |
| + int new_port = client_->client()->client_address().port(); |
| + QuicClientPeer::SetClientPort(client_->client(), new_port); |
| + QuicConnectionPeer::SetSelfAddress( |
| + client_->client()->session()->connection(), |
| + IPEndPoint( |
| + client_->client()->session()->connection()->self_address().address(), |
| + new_port)); |
| + |
| + // Register the new FD for epoll events. |
| + int new_fd = client_->client()->fd(); |
| + eps->RegisterFD(new_fd, client_->client(), EPOLLIN | EPOLLOUT | EPOLLET); |
| + |
| + // Send a second request, using the new FD. |
| + EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); |
| + EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| + |
| + // Verify that the client's ephemeral port is different. |
| + IPEndPoint new_address = client_->client()->client_address(); |
| + EXPECT_EQ(old_address.address(), new_address.address()); |
| + EXPECT_NE(old_address.port(), new_address.port()); |
| +} |
| + |
| TEST_P(EndToEndTest, DifferentFlowControlWindows) { |
| // Client and server can set different initial flow control receive windows. |
| // These are sent in CHLO/SHLO. Tests that these values are exchanged properly |