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

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

Issue 126283002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed extra space Created 6 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/test_tools/test_task_runner.h ('k') | net/tools/quic/quic_client.h » ('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 <vector> 7 #include <vector>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 : server_hostname_("example.com"), 151 : server_hostname_("example.com"),
152 server_started_(false), 152 server_started_(false),
153 strike_register_no_startup_period_(false) { 153 strike_register_no_startup_period_(false) {
154 net::IPAddressNumber ip; 154 net::IPAddressNumber ip;
155 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip)); 155 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip));
156 server_address_ = IPEndPoint(ip, 0); 156 server_address_ = IPEndPoint(ip, 0);
157 157
158 client_supported_versions_ = GetParam().client_supported_versions; 158 client_supported_versions_ = GetParam().client_supported_versions;
159 server_supported_versions_ = GetParam().server_supported_versions; 159 server_supported_versions_ = GetParam().server_supported_versions;
160 negotiated_version_ = GetParam().negotiated_version; 160 negotiated_version_ = GetParam().negotiated_version;
161 FLAGS_limit_rto_increase_for_tests = true;
162 FLAGS_enable_quic_pacing = GetParam().use_pacing; 161 FLAGS_enable_quic_pacing = GetParam().use_pacing;
163 LOG(INFO) << "Using Configuration: " << GetParam(); 162 LOG(INFO) << "Using Configuration: " << GetParam();
164 163
165 client_config_.SetDefaults(); 164 client_config_.SetDefaults();
166 server_config_.SetDefaults(); 165 server_config_.SetDefaults();
167 server_config_.set_initial_round_trip_time_us(kMaxInitialRoundTripTimeUs, 166 server_config_.set_initial_round_trip_time_us(kMaxInitialRoundTripTimeUs,
168 0); 167 0);
169 168
170 QuicInMemoryCachePeer::ResetForTests(); 169 QuicInMemoryCachePeer::ResetForTests();
171 AddToCache("GET", "https://www.google.com/foo", 170 AddToCache("GET", "https://www.google.com/foo",
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 StringPiece response_code, 245 StringPiece response_code,
247 StringPiece response_detail, 246 StringPiece response_detail,
248 StringPiece body) { 247 StringPiece body) {
249 QuicInMemoryCache::GetInstance()->AddSimpleResponse( 248 QuicInMemoryCache::GetInstance()->AddSimpleResponse(
250 method, path, version, response_code, response_detail, body); 249 method, path, version, response_code, response_detail, body);
251 } 250 }
252 251
253 void SetPacketLossPercentage(int32 loss) { 252 void SetPacketLossPercentage(int32 loss) {
254 // TODO(rtenneti): enable when we can do random packet loss tests in 253 // TODO(rtenneti): enable when we can do random packet loss tests in
255 // chrome's tree. 254 // chrome's tree.
256 // client_writer_->set_fake_packet_loss_percentage(loss); 255 if (loss != 0 && loss != 100)
257 // server_writer_->set_fake_packet_loss_percentage(loss); 256 return;
257 client_writer_->set_fake_packet_loss_percentage(loss);
258 server_writer_->set_fake_packet_loss_percentage(loss);
258 } 259 }
259 260
260 void SetPacketSendDelay(QuicTime::Delta delay) { 261 void SetPacketSendDelay(QuicTime::Delta delay) {
261 // TODO(rtenneti): enable when we can do random packet send delay tests in 262 // TODO(rtenneti): enable when we can do random packet send delay tests in
262 // chrome's tree. 263 // chrome's tree.
263 // client_writer_->set_fake_packet_delay(delay); 264 // client_writer_->set_fake_packet_delay(delay);
264 // server_writer_->set_fake_packet_delay(delay); 265 // server_writer_->set_fake_packet_delay(delay);
265 } 266 }
266 267
267 void SetReorderPercentage(int32 reorder) { 268 void SetReorderPercentage(int32 reorder) {
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 for (int i = 0; i < max_streams; ++i) { 774 for (int i = 0; i < max_streams; ++i) {
774 EXPECT_LT(0, client_->SendRequest("/large_response")); 775 EXPECT_LT(0, client_->SendRequest("/large_response"));
775 } 776 }
776 777
777 // WaitForEvents waits 50ms and returns true if there are outstanding 778 // WaitForEvents waits 50ms and returns true if there are outstanding
778 // requests. 779 // requests.
779 while (client_->client()->WaitForEvents() == true) { 780 while (client_->client()->WaitForEvents() == true) {
780 } 781 }
781 } 782 }
782 783
784 TEST_P(EndToEndTest, StreamCancelErrorTest) {
785 ASSERT_TRUE(Initialize());
786 string small_body;
787 GenerateBody(&small_body, 256);
788
789 AddToCache("GET", "/small_response", "HTTP/1.1", "200", "OK", small_body);
790
791 client_->client()->WaitForCryptoHandshakeConfirmed();
792
793 QuicSession* session = client_->client()->session();
794 // Lose the request.
795 SetPacketLossPercentage(100);
796 EXPECT_LT(0, client_->SendRequest("/small_response"));
797 client_->client()->WaitForEvents();
798 // Transmit the cancel, and ensure the connection is torn down properly.
799 SetPacketLossPercentage(0);
800 QuicStreamId stream_id = negotiated_version_ > QUIC_VERSION_12 ? 5 : 3;
801 session->SendRstStream(stream_id, QUIC_STREAM_CANCELLED);
802
803 // WaitForEvents waits 50ms and returns true if there are outstanding
804 // requests.
805 while (client_->client()->WaitForEvents() == true) {
806 }
807 if (negotiated_version_ > QUIC_VERSION_12) {
808 // It should be completely fine to RST a stream before any data has bee
809 // received for that stream.
810 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error());
811 } else {
812 // Check that the connection is always properly closed
813 // from a stream being RST before headers are decompressed.
814 EXPECT_EQ(QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED,
815 client_->connection_error());
816 }
817 }
818
783 class WrongAddressWriter : public QuicTestWriter { 819 class WrongAddressWriter : public QuicTestWriter {
784 public: 820 public:
785 WrongAddressWriter() { 821 WrongAddressWriter() {
786 IPAddressNumber ip; 822 IPAddressNumber ip;
787 CHECK(net::ParseIPLiteralToNumber("127.0.0.2", &ip)); 823 CHECK(net::ParseIPLiteralToNumber("127.0.0.2", &ip));
788 self_address_ = IPEndPoint(ip, 0); 824 self_address_ = IPEndPoint(ip, 0);
789 } 825 }
790 826
791 virtual WriteResult WritePacket( 827 virtual WriteResult WritePacket(
792 const char* buffer, size_t buf_len, 828 const char* buffer, size_t buf_len,
(...skipping 27 matching lines...) Expand all
820 client_->SendSynchronousRequest("/bar"); 856 client_->SendSynchronousRequest("/bar");
821 857
822 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); 858 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error());
823 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error()); 859 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error());
824 } 860 }
825 861
826 } // namespace 862 } // namespace
827 } // namespace test 863 } // namespace test
828 } // namespace tools 864 } // namespace tools
829 } // namespace net 865 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/test_task_runner.h ('k') | net/tools/quic/quic_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698