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

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.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
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 QuicTag congestion_control_tag; 110 QuicTag congestion_control_tag;
111 }; 111 };
112 112
113 // Constructs various test permutations. 113 // Constructs various test permutations.
114 vector<TestParams> GetTestParams() { 114 vector<TestParams> GetTestParams() {
115 vector<TestParams> params; 115 vector<TestParams> params;
116 QuicVersionVector all_supported_versions = QuicSupportedVersions(); 116 QuicVersionVector all_supported_versions = QuicSupportedVersions();
117 // TODO(rtenneti): Add kTBBR after BBR code is checked in. 117 // TODO(rtenneti): Add kTBBR after BBR code is checked in.
118 // QuicTag congestion_control_tags[] = {kRENO, kTBBR, kQBIC}; 118 // QuicTag congestion_control_tags[] = {kRENO, kTBBR, kQBIC};
119 QuicTag congestion_control_tags[] = {kRENO, kQBIC}; 119 QuicTag congestion_control_tags[] = {kRENO, kQBIC};
120 QuicVersionVector spdy3_versions;
121 QuicVersionVector spdy4_versions;
122 for (QuicVersion version : all_supported_versions) {
123 if (version > QUIC_VERSION_23) {
124 spdy4_versions.push_back(version);
125 } else {
126 spdy3_versions.push_back(version);
127 }
128 }
120 for (size_t congestion_control_index = 0; 129 for (size_t congestion_control_index = 0;
121 congestion_control_index < arraysize(congestion_control_tags); 130 congestion_control_index < arraysize(congestion_control_tags);
122 congestion_control_index++) { 131 congestion_control_index++) {
123 QuicTag congestion_control_tag = 132 QuicTag congestion_control_tag =
124 congestion_control_tags[congestion_control_index]; 133 congestion_control_tags[congestion_control_index];
125 for (int use_fec = 0; use_fec < 2; ++use_fec) { 134 for (int use_fec = 0; use_fec < 2; ++use_fec) {
126 for (int use_pacing = 0; use_pacing < 2; ++use_pacing) { 135 for (int use_pacing = 0; use_pacing < 2; ++use_pacing) {
127 // Add an entry for server and client supporting all versions. 136 for (int spdy_version = 3; spdy_version <= 4; ++spdy_version) {
128 params.push_back(TestParams(all_supported_versions, 137 const QuicVersionVector* client_versions =
129 all_supported_versions, 138 spdy_version == 3 ? &spdy3_versions : &spdy4_versions;
130 all_supported_versions[0], 139 // Add an entry for server and client supporting all versions.
131 use_pacing != 0, 140 params.push_back(TestParams(*client_versions, all_supported_versions,
132 use_fec != 0, 141 (*client_versions)[0], use_pacing != 0,
133 congestion_control_tag)); 142 use_fec != 0, congestion_control_tag));
134 143
135 // Test client supporting all versions and server supporting 1 version. 144 // Test client supporting all versions and server supporting 1
136 // Simulate an old server and exercise version downgrade in the client. 145 // version.
137 // Protocol negotiation should occur. Skip the i = 0 case because it is 146 // Simulate an old server and exercise version downgrade in the
138 // essentially the same as the default case. 147 // client.
139 for (size_t i = 1; i < all_supported_versions.size(); ++i) { 148 // Protocol negotiation should occur. Skip the i = 0 case because it
140 QuicVersionVector server_supported_versions; 149 // is
141 server_supported_versions.push_back(all_supported_versions[i]); 150 // essentially the same as the default case.
142 params.push_back(TestParams(all_supported_versions, 151 for (QuicVersion version : *client_versions) {
143 server_supported_versions, 152 QuicVersionVector server_supported_versions;
144 server_supported_versions[0], 153 server_supported_versions.push_back(version);
145 use_pacing != 0, 154 params.push_back(
146 use_fec != 0, 155 TestParams(*client_versions, server_supported_versions,
147 congestion_control_tag)); 156 server_supported_versions[0], use_pacing != 0,
157 use_fec != 0, congestion_control_tag));
158 }
148 } 159 }
149 } 160 }
150 } 161 }
151 } 162 }
152 return params; 163 return params;
153 } 164 }
154 165
155 class ServerDelegate : public PacketDroppingTestWriter::Delegate { 166 class ServerDelegate : public PacketDroppingTestWriter::Delegate {
156 public: 167 public:
157 ServerDelegate(TestWriterFactory* writer_factory, 168 ServerDelegate(TestWriterFactory* writer_factory,
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 EXPECT_TRUE(server_sent_packet_manager.using_pacing()); 1378 EXPECT_TRUE(server_sent_packet_manager.using_pacing());
1368 EXPECT_TRUE(client_sent_packet_manager.using_pacing()); 1379 EXPECT_TRUE(client_sent_packet_manager.using_pacing());
1369 } 1380 }
1370 1381
1371 // A TestAckNotifierDelegate verifies that its OnAckNotification method has been 1382 // A TestAckNotifierDelegate verifies that its OnAckNotification method has been
1372 // called exactly once on destruction. 1383 // called exactly once on destruction.
1373 class TestAckNotifierDelegate : public QuicAckNotifier::DelegateInterface { 1384 class TestAckNotifierDelegate : public QuicAckNotifier::DelegateInterface {
1374 public: 1385 public:
1375 TestAckNotifierDelegate() {} 1386 TestAckNotifierDelegate() {}
1376 1387
1377 void OnAckNotification(int /*num_original_packets*/, 1388 void OnAckNotification(int /*num_retransmitted_packets*/,
1378 int /*num_original_bytes*/,
1379 int /*num_retransmitted_packets*/,
1380 int /*num_retransmitted_bytes*/, 1389 int /*num_retransmitted_bytes*/,
1381 QuicTime::Delta /*delta_largest_observed*/) override { 1390 QuicTime::Delta /*delta_largest_observed*/) override {
1382 ASSERT_FALSE(has_been_notified_); 1391 ASSERT_FALSE(has_been_notified_);
1383 has_been_notified_ = true; 1392 has_been_notified_ = true;
1384 } 1393 }
1385 1394
1386 bool has_been_notified() const { return has_been_notified_; } 1395 bool has_been_notified() const { return has_been_notified_; }
1387 1396
1388 protected: 1397 protected:
1389 // Object is ref counted. 1398 // Object is ref counted.
1390 ~TestAckNotifierDelegate() override { EXPECT_TRUE(has_been_notified_); } 1399 ~TestAckNotifierDelegate() override { EXPECT_TRUE(has_been_notified_); }
1391 1400
1392 private: 1401 private:
1393 bool has_been_notified_ = false; 1402 bool has_been_notified_ = false;
1394 }; 1403 };
1395 1404
1396 TEST_P(EndToEndTest, AckNotifierWithPacketLoss) { 1405 TEST_P(EndToEndTest, AckNotifierWithPacketLossAndBlockedSocket) {
1397 // Verify that even in the presence of packet loss, an AckNotifierDelegate 1406 // Verify that even in the presence of packet loss and occasionally blocked
1398 // will get informed that the data it is interested in has been ACKed. This 1407 // socket, an AckNotifierDelegate will get informed that the data it is
1399 // tests end-to-end ACK notification, and demonstrates that retransmissions do 1408 // interested in has been ACKed. This tests end-to-end ACK notification, and
1400 // not break this functionality. 1409 // demonstrates that retransmissions do not break this functionality.
1401 ValueRestore<bool> old_flag(&FLAGS_quic_attach_ack_notifiers_to_packets, 1410 ValueRestore<bool> old_flag(&FLAGS_quic_attach_ack_notifiers_to_packets,
1402 true); 1411 true);
1412 ValueRestore<bool> old_flag2(&FLAGS_quic_ack_notifier_informed_on_serialized,
1413 true);
1403 1414
1404 SetPacketLossPercentage(5); 1415 SetPacketLossPercentage(5);
1405 ASSERT_TRUE(Initialize()); 1416 ASSERT_TRUE(Initialize());
1406 1417
1407 // Wait for the server SHLO before upping the packet loss. 1418 // Wait for the server SHLO before upping the packet loss.
1408 client_->client()->WaitForCryptoHandshakeConfirmed(); 1419 client_->client()->WaitForCryptoHandshakeConfirmed();
1409 SetPacketLossPercentage(30); 1420 SetPacketLossPercentage(30);
1421 client_writer_->set_fake_blocked_socket_percentage(10);
1410 1422
1411 // Create a POST request and send the headers only. 1423 // Create a POST request and send the headers only.
1412 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo"); 1424 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
1413 request.set_has_complete_message(false); 1425 request.set_has_complete_message(false);
1414 client_->SendMessage(request); 1426 client_->SendMessage(request);
1415 1427
1416 // The TestAckNotifierDelegate will cause a failure if not notified. 1428 // The TestAckNotifierDelegate will cause a failure if not notified.
1417 scoped_refptr<TestAckNotifierDelegate> delegate(new TestAckNotifierDelegate); 1429 scoped_refptr<TestAckNotifierDelegate> delegate(new TestAckNotifierDelegate);
1418 1430
1419 // Test the AckNotifier's ability to track multiple packets by making the 1431 // Test the AckNotifier's ability to track multiple packets by making the
1420 // request body exceed the size of a single packet. 1432 // request body exceed the size of a single packet.
1421 string request_string = 1433 string request_string =
1422 "a request body bigger than one packet" + string(kMaxPacketSize, '.'); 1434 "a request body bigger than one packet" + string(kMaxPacketSize, '.');
1423 1435
1424 // Send the request, and register the delegate for ACKs. 1436 // Send the request, and register the delegate for ACKs.
1425 client_->SendData(request_string, true, delegate.get()); 1437 client_->SendData(request_string, true, delegate.get());
1426 client_->WaitForResponse(); 1438 client_->WaitForResponse();
1427 EXPECT_EQ(kFooResponseBody, client_->response_body()); 1439 EXPECT_EQ(kFooResponseBody, client_->response_body());
1428 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 1440 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1429 1441
1430 // Send another request to flush out any pending ACKs on the server. 1442 // Send another request to flush out any pending ACKs on the server.
1431 client_->SendSynchronousRequest(request_string); 1443 client_->SendSynchronousRequest(request_string);
1432 1444
1445 // Pause the server to avoid races.
1446 server_thread_->Pause();
1433 // Make sure the delegate does get the notification it expects. 1447 // Make sure the delegate does get the notification it expects.
1434 while (!delegate->has_been_notified()) { 1448 while (!delegate->has_been_notified()) {
1435 // Waits for up to 50 ms. 1449 // Waits for up to 50 ms.
1436 client_->client()->WaitForEvents(); 1450 client_->client()->WaitForEvents();
1437 } 1451 }
1452 server_thread_->Resume();
1438 } 1453 }
1439 1454
1440 } // namespace 1455 } // namespace
1441 } // namespace test 1456 } // namespace test
1442 } // namespace tools 1457 } // namespace tools
1443 } // namespace net 1458 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698