| OLD | NEW |
| 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 <sys/epoll.h> | 6 #include <sys/epoll.h> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 // TODO(rtenneti): enable when we can do random packet reorder tests in | 442 // TODO(rtenneti): enable when we can do random packet reorder tests in |
| 443 // chrome's tree. | 443 // chrome's tree. |
| 444 // client_writer_->set_fake_reorder_percentage(reorder); | 444 // client_writer_->set_fake_reorder_percentage(reorder); |
| 445 // server_writer_->set_fake_reorder_percentage(reorder); | 445 // server_writer_->set_fake_reorder_percentage(reorder); |
| 446 } | 446 } |
| 447 | 447 |
| 448 // Verifies that the client and server connections were both free of packets | 448 // Verifies that the client and server connections were both free of packets |
| 449 // being discarded, based on connection stats. | 449 // being discarded, based on connection stats. |
| 450 // Calls server_thread_ Pause() and Resume(), which may only be called once | 450 // Calls server_thread_ Pause() and Resume(), which may only be called once |
| 451 // per test. | 451 // per test. |
| 452 void VerifyCleanConnection(bool /*had_packet_loss*/) { | 452 void VerifyCleanConnection(bool had_packet_loss) { |
| 453 QuicConnectionStats client_stats = | 453 QuicConnectionStats client_stats = |
| 454 client_->client()->session()->connection()->GetStats(); | 454 client_->client()->session()->connection()->GetStats(); |
| 455 // TODO(ianswett): Re-enable this check once b/19572432 is fixed. | 455 if (FLAGS_quic_reply_to_rej && !had_packet_loss) { |
| 456 // if (!had_packet_loss) { | 456 EXPECT_EQ(0u, client_stats.packets_lost); |
| 457 // EXPECT_EQ(0u, client_stats.packets_lost); | 457 } |
| 458 // } | |
| 459 EXPECT_EQ(0u, client_stats.packets_discarded); | 458 EXPECT_EQ(0u, client_stats.packets_discarded); |
| 460 // When doing 0-RTT with stateless rejects, the encrypted requests cause | 459 // When doing 0-RTT with stateless rejects, the encrypted requests cause |
| 461 // a retranmission of the SREJ packets which are dropped by the client. | 460 // a retranmission of the SREJ packets which are dropped by the client. |
| 462 if (!BothSidesSupportStatelessRejects()) { | 461 if (!BothSidesSupportStatelessRejects()) { |
| 463 EXPECT_EQ(0u, client_stats.packets_dropped); | 462 EXPECT_EQ(0u, client_stats.packets_dropped); |
| 464 } | 463 } |
| 465 EXPECT_EQ(client_stats.packets_received, client_stats.packets_processed); | 464 EXPECT_EQ(client_stats.packets_received, client_stats.packets_processed); |
| 466 | 465 |
| 467 const int num_expected_stateless_rejects = | 466 const int num_expected_stateless_rejects = |
| 468 (BothSidesSupportStatelessRejects() && | 467 (BothSidesSupportStatelessRejects() && |
| 469 client_->client()->session()->GetNumSentClientHellos() > 0) | 468 client_->client()->session()->GetNumSentClientHellos() > 0) |
| 470 ? 1 | 469 ? 1 |
| 471 : 0; | 470 : 0; |
| 472 EXPECT_EQ(num_expected_stateless_rejects, | 471 EXPECT_EQ(num_expected_stateless_rejects, |
| 473 client_->client()->num_stateless_rejects_received()); | 472 client_->client()->num_stateless_rejects_received()); |
| 474 | 473 |
| 475 server_thread_->Pause(); | 474 server_thread_->Pause(); |
| 476 QuicDispatcher* dispatcher = | 475 QuicDispatcher* dispatcher = |
| 477 QuicServerPeer::GetDispatcher(server_thread_->server()); | 476 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 478 ASSERT_EQ(1u, dispatcher->session_map().size()); | 477 ASSERT_EQ(1u, dispatcher->session_map().size()); |
| 479 QuicSession* session = dispatcher->session_map().begin()->second; | 478 QuicSession* session = dispatcher->session_map().begin()->second; |
| 480 QuicConnectionStats server_stats = session->connection()->GetStats(); | 479 QuicConnectionStats server_stats = session->connection()->GetStats(); |
| 481 // TODO(ianswett): Re-enable this check once b/19572432 is fixed. | 480 if (FLAGS_quic_reply_to_rej && !had_packet_loss) { |
| 482 // if (!had_packet_loss) { | 481 EXPECT_EQ(0u, server_stats.packets_lost); |
| 483 // EXPECT_EQ(0u, server_stats.packets_lost); | 482 } |
| 484 // } | |
| 485 EXPECT_EQ(0u, server_stats.packets_discarded); | 483 EXPECT_EQ(0u, server_stats.packets_discarded); |
| 486 // TODO(ianswett): Restore the check for packets_dropped equals 0. | 484 // TODO(ianswett): Restore the check for packets_dropped equals 0. |
| 487 // The expect for packets received is equal to packets processed fails | 485 // The expect for packets received is equal to packets processed fails |
| 488 // due to version negotiation packets. | 486 // due to version negotiation packets. |
| 489 server_thread_->Resume(); | 487 server_thread_->Resume(); |
| 490 } | 488 } |
| 491 | 489 |
| 492 bool BothSidesSupportStatelessRejects() { | 490 bool BothSidesSupportStatelessRejects() { |
| 493 return (GetParam().server_uses_stateless_rejects_if_peer_supported && | 491 return (GetParam().server_uses_stateless_rejects_if_peer_supported && |
| 494 GetParam().client_supports_stateless_rejects); | 492 GetParam().client_supports_stateless_rejects); |
| (...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2447 bool fin = (i == request_body_size_bytes - 1); | 2445 bool fin = (i == request_body_size_bytes - 1); |
| 2448 client_->SendData(string(body.data(), kSizeBytes), fin); | 2446 client_->SendData(string(body.data(), kSizeBytes), fin); |
| 2449 client_->client()->WaitForEvents(); | 2447 client_->client()->WaitForEvents(); |
| 2450 } | 2448 } |
| 2451 VerifyCleanConnection(false); | 2449 VerifyCleanConnection(false); |
| 2452 } | 2450 } |
| 2453 | 2451 |
| 2454 } // namespace | 2452 } // namespace |
| 2455 } // namespace test | 2453 } // namespace test |
| 2456 } // namespace net | 2454 } // namespace net |
| OLD | NEW |