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

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

Issue 849123003: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed extra blank line 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/test_tools/quic_test_utils.h ('k') | net/tools/quic/quic_server_session.cc » ('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 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 EXPECT_TRUE(server_sent_packet_manager.using_pacing()); 1367 EXPECT_TRUE(server_sent_packet_manager.using_pacing());
1368 EXPECT_TRUE(client_sent_packet_manager.using_pacing()); 1368 EXPECT_TRUE(client_sent_packet_manager.using_pacing());
1369 } 1369 }
1370 1370
1371 // A TestAckNotifierDelegate verifies that its OnAckNotification method has been 1371 // A TestAckNotifierDelegate verifies that its OnAckNotification method has been
1372 // called exactly once on destruction. 1372 // called exactly once on destruction.
1373 class TestAckNotifierDelegate : public QuicAckNotifier::DelegateInterface { 1373 class TestAckNotifierDelegate : public QuicAckNotifier::DelegateInterface {
1374 public: 1374 public:
1375 TestAckNotifierDelegate() {} 1375 TestAckNotifierDelegate() {}
1376 1376
1377 void OnAckNotification(int /*num_original_packets*/, 1377 void OnAckNotification(int /*num_retransmitted_packets*/,
1378 int /*num_original_bytes*/,
1379 int /*num_retransmitted_packets*/,
1380 int /*num_retransmitted_bytes*/, 1378 int /*num_retransmitted_bytes*/,
1381 QuicTime::Delta /*delta_largest_observed*/) override { 1379 QuicTime::Delta /*delta_largest_observed*/) override {
1382 ASSERT_FALSE(has_been_notified_); 1380 ASSERT_FALSE(has_been_notified_);
1383 has_been_notified_ = true; 1381 has_been_notified_ = true;
1384 } 1382 }
1385 1383
1386 bool has_been_notified() const { return has_been_notified_; } 1384 bool has_been_notified() const { return has_been_notified_; }
1387 1385
1388 protected: 1386 protected:
1389 // Object is ref counted. 1387 // Object is ref counted.
1390 ~TestAckNotifierDelegate() override { EXPECT_TRUE(has_been_notified_); } 1388 ~TestAckNotifierDelegate() override { EXPECT_TRUE(has_been_notified_); }
1391 1389
1392 private: 1390 private:
1393 bool has_been_notified_ = false; 1391 bool has_been_notified_ = false;
1394 }; 1392 };
1395 1393
1396 TEST_P(EndToEndTest, AckNotifierWithPacketLoss) { 1394 TEST_P(EndToEndTest, AckNotifierWithPacketLossAndBlockedSocket) {
1397 // Verify that even in the presence of packet loss, an AckNotifierDelegate 1395 // 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 1396 // socket, an AckNotifierDelegate will get informed that the data it is
1399 // tests end-to-end ACK notification, and demonstrates that retransmissions do 1397 // interested in has been ACKed. This tests end-to-end ACK notification, and
1400 // not break this functionality. 1398 // demonstrates that retransmissions do not break this functionality.
1401 ValueRestore<bool> old_flag(&FLAGS_quic_attach_ack_notifiers_to_packets, 1399 ValueRestore<bool> old_flag(&FLAGS_quic_attach_ack_notifiers_to_packets,
1402 true); 1400 true);
1401 ValueRestore<bool> old_flag2(&FLAGS_quic_ack_notifier_informed_on_serialized,
1402 true);
1403 1403
1404 SetPacketLossPercentage(5); 1404 SetPacketLossPercentage(5);
1405 ASSERT_TRUE(Initialize()); 1405 ASSERT_TRUE(Initialize());
1406 1406
1407 // Wait for the server SHLO before upping the packet loss. 1407 // Wait for the server SHLO before upping the packet loss.
1408 client_->client()->WaitForCryptoHandshakeConfirmed(); 1408 client_->client()->WaitForCryptoHandshakeConfirmed();
1409 SetPacketLossPercentage(30); 1409 SetPacketLossPercentage(30);
1410 client_writer_->set_fake_blocked_socket_percentage(10);
1410 1411
1411 // Create a POST request and send the headers only. 1412 // Create a POST request and send the headers only.
1412 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo"); 1413 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
1413 request.set_has_complete_message(false); 1414 request.set_has_complete_message(false);
1414 client_->SendMessage(request); 1415 client_->SendMessage(request);
1415 1416
1416 // The TestAckNotifierDelegate will cause a failure if not notified. 1417 // The TestAckNotifierDelegate will cause a failure if not notified.
1417 scoped_refptr<TestAckNotifierDelegate> delegate(new TestAckNotifierDelegate); 1418 scoped_refptr<TestAckNotifierDelegate> delegate(new TestAckNotifierDelegate);
1418 1419
1419 // Test the AckNotifier's ability to track multiple packets by making the 1420 // Test the AckNotifier's ability to track multiple packets by making the
1420 // request body exceed the size of a single packet. 1421 // request body exceed the size of a single packet.
1421 string request_string = 1422 string request_string =
1422 "a request body bigger than one packet" + string(kMaxPacketSize, '.'); 1423 "a request body bigger than one packet" + string(kMaxPacketSize, '.');
1423 1424
1424 // Send the request, and register the delegate for ACKs. 1425 // Send the request, and register the delegate for ACKs.
1425 client_->SendData(request_string, true, delegate.get()); 1426 client_->SendData(request_string, true, delegate.get());
1426 client_->WaitForResponse(); 1427 client_->WaitForResponse();
1427 EXPECT_EQ(kFooResponseBody, client_->response_body()); 1428 EXPECT_EQ(kFooResponseBody, client_->response_body());
1428 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 1429 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1429 1430
1430 // Send another request to flush out any pending ACKs on the server. 1431 // Send another request to flush out any pending ACKs on the server.
1431 client_->SendSynchronousRequest(request_string); 1432 client_->SendSynchronousRequest(request_string);
1432 1433
1434 // Pause the server to avoid races.
1435 server_thread_->Pause();
1433 // Make sure the delegate does get the notification it expects. 1436 // Make sure the delegate does get the notification it expects.
1434 while (!delegate->has_been_notified()) { 1437 while (!delegate->has_been_notified()) {
1435 // Waits for up to 50 ms. 1438 // Waits for up to 50 ms.
1436 client_->client()->WaitForEvents(); 1439 client_->client()->WaitForEvents();
1437 } 1440 }
1441 server_thread_->Resume();
1438 } 1442 }
1439 1443
1440 } // namespace 1444 } // namespace
1441 } // namespace test 1445 } // namespace test
1442 } // namespace tools 1446 } // namespace tools
1443 } // namespace net 1447 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/tools/quic/quic_server_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698