| 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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 // TODO(rtenneti): enable when we can do random packet reorder tests in | 461 // TODO(rtenneti): enable when we can do random packet reorder tests in |
| 462 // chrome's tree. | 462 // chrome's tree. |
| 463 // client_writer_->set_fake_reorder_percentage(reorder); | 463 // client_writer_->set_fake_reorder_percentage(reorder); |
| 464 // server_writer_->set_fake_reorder_percentage(reorder); | 464 // server_writer_->set_fake_reorder_percentage(reorder); |
| 465 } | 465 } |
| 466 | 466 |
| 467 // Verifies that the client and server connections were both free of packets | 467 // Verifies that the client and server connections were both free of packets |
| 468 // being discarded, based on connection stats. | 468 // being discarded, based on connection stats. |
| 469 // Calls server_thread_ Pause() and Resume(), which may only be called once | 469 // Calls server_thread_ Pause() and Resume(), which may only be called once |
| 470 // per test. | 470 // per test. |
| 471 void VerifyCleanConnection(bool /*had_packet_loss*/) { | 471 void VerifyCleanConnection(bool had_packet_loss) { |
| 472 QuicConnectionStats client_stats = | 472 QuicConnectionStats client_stats = |
| 473 client_->client()->session()->connection()->GetStats(); | 473 client_->client()->session()->connection()->GetStats(); |
| 474 // TODO(ianswett): Re-enable this check once b/19572432 is fixed. | 474 if (FLAGS_quic_reply_to_rej && !had_packet_loss) { |
| 475 // if (!had_packet_loss) { | 475 EXPECT_EQ(0u, client_stats.packets_lost); |
| 476 // EXPECT_EQ(0u, client_stats.packets_lost); | 476 } |
| 477 // } | |
| 478 EXPECT_EQ(0u, client_stats.packets_discarded); | 477 EXPECT_EQ(0u, client_stats.packets_discarded); |
| 479 // When doing 0-RTT with stateless rejects, the encrypted requests cause | 478 // When doing 0-RTT with stateless rejects, the encrypted requests cause |
| 480 // a retranmission of the SREJ packets which are dropped by the client. | 479 // a retranmission of the SREJ packets which are dropped by the client. |
| 481 if (!BothSidesSupportStatelessRejects()) { | 480 if (!BothSidesSupportStatelessRejects()) { |
| 482 EXPECT_EQ(0u, client_stats.packets_dropped); | 481 EXPECT_EQ(0u, client_stats.packets_dropped); |
| 483 } | 482 } |
| 484 EXPECT_EQ(client_stats.packets_received, client_stats.packets_processed); | 483 EXPECT_EQ(client_stats.packets_received, client_stats.packets_processed); |
| 485 | 484 |
| 486 const int num_expected_stateless_rejects = | 485 const int num_expected_stateless_rejects = |
| 487 (BothSidesSupportStatelessRejects() && | 486 (BothSidesSupportStatelessRejects() && |
| 488 client_->client()->session()->GetNumSentClientHellos() > 0) | 487 client_->client()->session()->GetNumSentClientHellos() > 0) |
| 489 ? 1 | 488 ? 1 |
| 490 : 0; | 489 : 0; |
| 491 EXPECT_EQ(num_expected_stateless_rejects, | 490 EXPECT_EQ(num_expected_stateless_rejects, |
| 492 client_->client()->num_stateless_rejects_received()); | 491 client_->client()->num_stateless_rejects_received()); |
| 493 | 492 |
| 494 server_thread_->Pause(); | 493 server_thread_->Pause(); |
| 495 QuicDispatcher* dispatcher = | 494 QuicDispatcher* dispatcher = |
| 496 QuicServerPeer::GetDispatcher(server_thread_->server()); | 495 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 497 ASSERT_EQ(1u, dispatcher->session_map().size()); | 496 ASSERT_EQ(1u, dispatcher->session_map().size()); |
| 498 QuicSession* session = dispatcher->session_map().begin()->second; | 497 QuicSession* session = dispatcher->session_map().begin()->second; |
| 499 QuicConnectionStats server_stats = session->connection()->GetStats(); | 498 QuicConnectionStats server_stats = session->connection()->GetStats(); |
| 500 // TODO(ianswett): Re-enable this check once b/19572432 is fixed. | 499 if (FLAGS_quic_reply_to_rej && !had_packet_loss) { |
| 501 // if (!had_packet_loss) { | 500 EXPECT_EQ(0u, server_stats.packets_lost); |
| 502 // EXPECT_EQ(0u, server_stats.packets_lost); | 501 } |
| 503 // } | |
| 504 EXPECT_EQ(0u, server_stats.packets_discarded); | 502 EXPECT_EQ(0u, server_stats.packets_discarded); |
| 505 // TODO(ianswett): Restore the check for packets_dropped equals 0. | 503 // TODO(ianswett): Restore the check for packets_dropped equals 0. |
| 506 // The expect for packets received is equal to packets processed fails | 504 // The expect for packets received is equal to packets processed fails |
| 507 // due to version negotiation packets. | 505 // due to version negotiation packets. |
| 508 server_thread_->Resume(); | 506 server_thread_->Resume(); |
| 509 } | 507 } |
| 510 | 508 |
| 511 bool BothSidesSupportStatelessRejects() { | 509 bool BothSidesSupportStatelessRejects() { |
| 512 return (GetParam().server_uses_stateless_rejects_if_peer_supported && | 510 return (GetParam().server_uses_stateless_rejects_if_peer_supported && |
| 513 GetParam().client_supports_stateless_rejects); | 511 GetParam().client_supports_stateless_rejects); |
| (...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2222 string expected_body = "This is server push response body for " + url; | 2220 string expected_body = "This is server push response body for " + url; |
| 2223 string response_body = client_->SendSynchronousRequest(url); | 2221 string response_body = client_->SendSynchronousRequest(url); |
| 2224 DVLOG(1) << "response body " << response_body; | 2222 DVLOG(1) << "response body " << response_body; |
| 2225 EXPECT_EQ(expected_body, response_body); | 2223 EXPECT_EQ(expected_body, response_body); |
| 2226 } | 2224 } |
| 2227 } | 2225 } |
| 2228 | 2226 |
| 2229 } // namespace | 2227 } // namespace |
| 2230 } // namespace test | 2228 } // namespace test |
| 2231 } // namespace net | 2229 } // namespace net |
| OLD | NEW |