Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: net/tools/quic/end_to_end_test.cc

Issue 789103013: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_unacked_packet_map.cc ('k') | net/tools/quic/quic_spdy_client_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <string> 6 #include <string>
7 #include <sys/epoll.h> 7 #include <sys/epoll.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 // Expect the default rtt of 100ms. 995 // Expect the default rtt of 100ms.
996 EXPECT_EQ(static_cast<int64>(100 * kNumMicrosPerMilli), 996 EXPECT_EQ(static_cast<int64>(100 * kNumMicrosPerMilli),
997 server_sent_packet_manager.GetRttStats()->initial_rtt_us()); 997 server_sent_packet_manager.GetRttStats()->initial_rtt_us());
998 // Ensure the bandwidth is valid. 998 // Ensure the bandwidth is valid.
999 client_sent_packet_manager.BandwidthEstimate(); 999 client_sent_packet_manager.BandwidthEstimate();
1000 server_sent_packet_manager.BandwidthEstimate(); 1000 server_sent_packet_manager.BandwidthEstimate();
1001 server_thread_->Resume(); 1001 server_thread_->Resume();
1002 } 1002 }
1003 1003
1004 TEST_P(EndToEndTest, 0ByteConnectionId) { 1004 TEST_P(EndToEndTest, 0ByteConnectionId) {
1005 ValueRestore<bool> old_flag(&FLAGS_allow_truncated_connection_ids_for_quic,
1006 true);
1007 client_config_.SetBytesForConnectionIdToSend(0); 1005 client_config_.SetBytesForConnectionIdToSend(0);
1008 ASSERT_TRUE(Initialize()); 1006 ASSERT_TRUE(Initialize());
1009 1007
1010 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 1008 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
1011 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 1009 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1012 1010
1013 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader( 1011 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader(
1014 client_->client()->session()->connection()); 1012 client_->client()->session()->connection());
1015 EXPECT_EQ(PACKET_0BYTE_CONNECTION_ID, 1013 EXPECT_EQ(PACKET_0BYTE_CONNECTION_ID,
1016 header->public_header.connection_id_length); 1014 header->public_header.connection_id_length);
1017 } 1015 }
1018 1016
1019 TEST_P(EndToEndTest, 1ByteConnectionId) { 1017 TEST_P(EndToEndTest, 1ByteConnectionId) {
1020 ValueRestore<bool> old_flag(&FLAGS_allow_truncated_connection_ids_for_quic,
1021 true);
1022 client_config_.SetBytesForConnectionIdToSend(1); 1018 client_config_.SetBytesForConnectionIdToSend(1);
1023 ASSERT_TRUE(Initialize()); 1019 ASSERT_TRUE(Initialize());
1024 1020
1025 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 1021 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
1026 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 1022 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1027 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader( 1023 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader(
1028 client_->client()->session()->connection()); 1024 client_->client()->session()->connection());
1029 EXPECT_EQ(PACKET_1BYTE_CONNECTION_ID, 1025 EXPECT_EQ(PACKET_1BYTE_CONNECTION_ID,
1030 header->public_header.connection_id_length); 1026 header->public_header.connection_id_length);
1031 } 1027 }
1032 1028
1033 TEST_P(EndToEndTest, 4ByteConnectionId) { 1029 TEST_P(EndToEndTest, 4ByteConnectionId) {
1034 ValueRestore<bool> old_flag(&FLAGS_allow_truncated_connection_ids_for_quic,
1035 true);
1036 client_config_.SetBytesForConnectionIdToSend(4); 1030 client_config_.SetBytesForConnectionIdToSend(4);
1037 ASSERT_TRUE(Initialize()); 1031 ASSERT_TRUE(Initialize());
1038 1032
1039 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 1033 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
1040 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 1034 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1041 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader( 1035 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader(
1042 client_->client()->session()->connection()); 1036 client_->client()->session()->connection());
1043 EXPECT_EQ(PACKET_4BYTE_CONNECTION_ID, 1037 EXPECT_EQ(PACKET_4BYTE_CONNECTION_ID,
1044 header->public_header.connection_id_length); 1038 header->public_header.connection_id_length);
1045 } 1039 }
1046 1040
1047 TEST_P(EndToEndTest, 8ByteConnectionId) { 1041 TEST_P(EndToEndTest, 8ByteConnectionId) {
1048 ValueRestore<bool> old_flag(&FLAGS_allow_truncated_connection_ids_for_quic,
1049 true);
1050 client_config_.SetBytesForConnectionIdToSend(8); 1042 client_config_.SetBytesForConnectionIdToSend(8);
1051 ASSERT_TRUE(Initialize()); 1043 ASSERT_TRUE(Initialize());
1052 1044
1053 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 1045 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
1054 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 1046 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1055 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader( 1047 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader(
1056 client_->client()->session()->connection()); 1048 client_->client()->session()->connection());
1057 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, 1049 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID,
1058 header->public_header.connection_id_length); 1050 header->public_header.connection_id_length);
1059 } 1051 }
1060 1052
1061 TEST_P(EndToEndTest, 15ByteConnectionId) { 1053 TEST_P(EndToEndTest, 15ByteConnectionId) {
1062 ValueRestore<bool> old_flag(&FLAGS_allow_truncated_connection_ids_for_quic,
1063 true);
1064 client_config_.SetBytesForConnectionIdToSend(15); 1054 client_config_.SetBytesForConnectionIdToSend(15);
1065 ASSERT_TRUE(Initialize()); 1055 ASSERT_TRUE(Initialize());
1066 1056
1067 // Our server is permissive and allows for out of bounds values. 1057 // Our server is permissive and allows for out of bounds values.
1068 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 1058 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
1069 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 1059 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1070 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader( 1060 QuicPacketHeader* header = QuicConnectionPeer::GetLastHeader(
1071 client_->client()->session()->connection()); 1061 client_->client()->session()->connection());
1072 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, 1062 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID,
1073 header->public_header.connection_id_length); 1063 header->public_header.connection_id_length);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 QuicServerPeer::GetDispatcher(server_thread_->server()); 1361 QuicServerPeer::GetDispatcher(server_thread_->server());
1372 ASSERT_EQ(1u, dispatcher->session_map().size()); 1362 ASSERT_EQ(1u, dispatcher->session_map().size());
1373 const QuicSentPacketManager& client_sent_packet_manager = 1363 const QuicSentPacketManager& client_sent_packet_manager =
1374 client_->client()->session()->connection()->sent_packet_manager(); 1364 client_->client()->session()->connection()->sent_packet_manager();
1375 const QuicSentPacketManager& server_sent_packet_manager = 1365 const QuicSentPacketManager& server_sent_packet_manager =
1376 *GetSentPacketManagerFromFirstServerSession(); 1366 *GetSentPacketManagerFromFirstServerSession();
1377 EXPECT_TRUE(server_sent_packet_manager.using_pacing()); 1367 EXPECT_TRUE(server_sent_packet_manager.using_pacing());
1378 EXPECT_TRUE(client_sent_packet_manager.using_pacing()); 1368 EXPECT_TRUE(client_sent_packet_manager.using_pacing());
1379 } 1369 }
1380 1370
1371 // A TestAckNotifierDelegate verifies that its OnAckNotification method has been
1372 // called exactly once on destruction.
1373 class TestAckNotifierDelegate : public QuicAckNotifier::DelegateInterface {
1374 public:
1375 TestAckNotifierDelegate() {}
1376
1377 void OnAckNotification(int /*num_original_packets*/,
1378 int /*num_original_bytes*/,
1379 int /*num_retransmitted_packets*/,
1380 int /*num_retransmitted_bytes*/,
1381 QuicTime::Delta /*delta_largest_observed*/) override {
1382 ASSERT_FALSE(has_been_notified_);
1383 has_been_notified_ = true;
1384 }
1385
1386 bool has_been_notified() const { return has_been_notified_; }
1387
1388 protected:
1389 // Object is ref counted.
1390 ~TestAckNotifierDelegate() override { EXPECT_TRUE(has_been_notified_); }
1391
1392 private:
1393 bool has_been_notified_ = false;
1394 };
1395
1396 TEST_P(EndToEndTest, AckNotifierWithPacketLoss) {
1397 // Verify that even in the presence of packet loss, an AckNotifierDelegate
1398 // will get informed that the data it is interested in has been ACKed. This
1399 // tests end-to-end ACK notification, and demonstrates that retransmissions do
1400 // not break this functionality.
1401 ValueRestore<bool> old_flag(&FLAGS_quic_attach_ack_notifiers_to_packets,
1402 true);
1403
1404 SetPacketLossPercentage(5);
1405 ASSERT_TRUE(Initialize());
1406
1407 // Wait for the server SHLO before upping the packet loss.
1408 client_->client()->WaitForCryptoHandshakeConfirmed();
1409 SetPacketLossPercentage(30);
1410
1411 // Create a POST request and send the headers only.
1412 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
1413 request.set_has_complete_message(false);
1414 client_->SendMessage(request);
1415
1416 // The TestAckNotifierDelegate will cause a failure if not notified.
1417 scoped_refptr<TestAckNotifierDelegate> delegate(new TestAckNotifierDelegate);
1418
1419 // Test the AckNotifier's ability to track multiple packets by making the
1420 // request body exceed the size of a single packet.
1421 string request_string =
1422 "a request body bigger than one packet" + string(kMaxPacketSize, '.');
1423
1424 // Send the request, and register the delegate for ACKs.
1425 client_->SendData(request_string, true, delegate.get());
1426 client_->WaitForResponse();
1427 EXPECT_EQ(kFooResponseBody, client_->response_body());
1428 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1429
1430 // Send another request to flush out any pending ACKs on the server.
1431 client_->SendSynchronousRequest(request_string);
1432
1433 // Make sure the delegate does get the notification it expects.
1434 while (!delegate->has_been_notified()) {
1435 // Waits for up to 50 ms.
1436 client_->client()->WaitForEvents();
1437 }
1438 }
1439
1381 } // namespace 1440 } // namespace
1382 } // namespace test 1441 } // namespace test
1383 } // namespace tools 1442 } // namespace tools
1384 } // namespace net 1443 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_unacked_packet_map.cc ('k') | net/tools/quic/quic_spdy_client_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698