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 <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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 // Calls server_thread_ Pause() and Resume(), which may only be called once | 467 // Calls server_thread_ Pause() and Resume(), which may only be called once |
468 // per test. | 468 // per test. |
469 void VerifyCleanConnection(bool /*had_packet_loss*/) { | 469 void VerifyCleanConnection(bool /*had_packet_loss*/) { |
470 QuicConnectionStats client_stats = | 470 QuicConnectionStats client_stats = |
471 client_->client()->session()->connection()->GetStats(); | 471 client_->client()->session()->connection()->GetStats(); |
472 // TODO(ianswett): Re-enable this check once b/19572432 is fixed. | 472 // TODO(ianswett): Re-enable this check once b/19572432 is fixed. |
473 // if (!had_packet_loss) { | 473 // if (!had_packet_loss) { |
474 // EXPECT_EQ(0u, client_stats.packets_lost); | 474 // EXPECT_EQ(0u, client_stats.packets_lost); |
475 // } | 475 // } |
476 EXPECT_EQ(0u, client_stats.packets_discarded); | 476 EXPECT_EQ(0u, client_stats.packets_discarded); |
477 EXPECT_EQ(0u, client_stats.packets_dropped); | 477 // When doing 0-RTT with stateless rejects, the encrypted requests cause |
| 478 // a retranmission of the SREJ packets which are dropped by the client. |
| 479 if (!BothSidesSupportStatelessRejects()) { |
| 480 EXPECT_EQ(0u, client_stats.packets_dropped); |
| 481 } |
478 EXPECT_EQ(client_stats.packets_received, client_stats.packets_processed); | 482 EXPECT_EQ(client_stats.packets_received, client_stats.packets_processed); |
479 | 483 |
480 const int num_expected_stateless_rejects = | 484 const int num_expected_stateless_rejects = |
481 (BothSidesSupportStatelessRejects() && | 485 (BothSidesSupportStatelessRejects() && |
482 client_->client()->session()->GetNumSentClientHellos() > 0) | 486 client_->client()->session()->GetNumSentClientHellos() > 0) |
483 ? 1 | 487 ? 1 |
484 : 0; | 488 : 0; |
485 EXPECT_EQ(num_expected_stateless_rejects, | 489 EXPECT_EQ(num_expected_stateless_rejects, |
486 client_->client()->num_stateless_rejects_received()); | 490 client_->client()->num_stateless_rejects_received()); |
487 | 491 |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 EXPECT_EQ(expected_num_hellos_latest_session, | 923 EXPECT_EQ(expected_num_hellos_latest_session, |
920 client_->client()->session()->GetNumSentClientHellos()); | 924 client_->client()->session()->GetNumSentClientHellos()); |
921 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | 925 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); |
922 | 926 |
923 VerifyCleanConnection(false); | 927 VerifyCleanConnection(false); |
924 } | 928 } |
925 | 929 |
926 TEST_P(EndToEndTest, StatelessRejectWithPacketLoss) { | 930 TEST_P(EndToEndTest, StatelessRejectWithPacketLoss) { |
927 // In this test, we intentionally drop the first packet from the | 931 // In this test, we intentionally drop the first packet from the |
928 // server, which corresponds with the initial REJ/SREJ response from | 932 // server, which corresponds with the initial REJ/SREJ response from |
929 // the server. The REJ case will succeed, due to redundancy in the | 933 // the server. |
930 // stateful handshake. The SREJ will fail, because there is | |
931 // (currently) no way to recover from a loss of the first SREJ, and | |
932 // all remaining state for the first handshake is black-holed on the | |
933 // time-wait list. | |
934 // TODO(jokulik): Once redundant SREJ support is added, this test | |
935 // should succeed. | |
936 server_writer_->set_fake_drop_first_n_packets(1); | 934 server_writer_->set_fake_drop_first_n_packets(1); |
937 // If this test will involve version negotiation then the version | 935 ASSERT_TRUE(Initialize()); |
938 // negotiation packet will be dropped, not the SREJ, and since the | |
939 // version negotiation packet will be retransmitted the test will | |
940 // succeed. | |
941 const bool will_succeed = | |
942 !BothSidesSupportStatelessRejects() || | |
943 negotiated_version_ != client_supported_versions_.front(); | |
944 ASSERT_EQ(will_succeed, Initialize()); | |
945 } | 936 } |
946 | 937 |
947 TEST_P(EndToEndTest, SetInitialReceivedConnectionOptions) { | 938 TEST_P(EndToEndTest, SetInitialReceivedConnectionOptions) { |
948 QuicTagVector initial_received_options; | 939 QuicTagVector initial_received_options; |
949 initial_received_options.push_back(kTBBR); | 940 initial_received_options.push_back(kTBBR); |
950 initial_received_options.push_back(kIW10); | 941 initial_received_options.push_back(kIW10); |
951 initial_received_options.push_back(kPRST); | 942 initial_received_options.push_back(kPRST); |
952 EXPECT_TRUE(server_config_.SetInitialReceivedConnectionOptions( | 943 EXPECT_TRUE(server_config_.SetInitialReceivedConnectionOptions( |
953 initial_received_options)); | 944 initial_received_options)); |
954 | 945 |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2110 // There will be buffered data to write in the client's stream. | 2101 // There will be buffered data to write in the client's stream. |
2111 ReliableQuicStream* stream = client_->client()->session()->GetStream(5); | 2102 ReliableQuicStream* stream = client_->client()->session()->GetStream(5); |
2112 EXPECT_TRUE(stream != nullptr && stream->HasBufferedData()); | 2103 EXPECT_TRUE(stream != nullptr && stream->HasBufferedData()); |
2113 } | 2104 } |
2114 } | 2105 } |
2115 | 2106 |
2116 } // namespace | 2107 } // namespace |
2117 } // namespace test | 2108 } // namespace test |
2118 } // namespace tools | 2109 } // namespace tools |
2119 } // namespace net | 2110 } // namespace net |
OLD | NEW |