| 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 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 WaitableEvent listening_; | 100 WaitableEvent listening_; |
| 101 WaitableEvent quit_; | 101 WaitableEvent quit_; |
| 102 base::Lock port_lock_; | 102 base::Lock port_lock_; |
| 103 QuicServer server_; | 103 QuicServer server_; |
| 104 IPEndPoint address_; | 104 IPEndPoint address_; |
| 105 int port_; | 105 int port_; |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(ServerThread); | 107 DISALLOW_COPY_AND_ASSIGN(ServerThread); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 class EndToEndTest : public ::testing::Test { | 110 class EndToEndTest : public ::testing::TestWithParam<QuicVersion> { |
| 111 public: |
| 112 static void SetUpTestCase() { |
| 113 QuicInMemoryCache::GetInstance()->ResetForTests(); |
| 114 } |
| 115 |
| 111 protected: | 116 protected: |
| 112 EndToEndTest() | 117 EndToEndTest() |
| 113 : server_hostname_("example.com"), | 118 : server_hostname_("example.com"), |
| 114 server_started_(false) { | 119 server_started_(false) { |
| 115 net::IPAddressNumber ip; | 120 net::IPAddressNumber ip; |
| 116 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip)); | 121 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip)); |
| 117 server_address_ = IPEndPoint(ip, 0); | 122 server_address_ = IPEndPoint(ip, 0); |
| 118 client_config_.SetDefaults(); | 123 client_config_.SetDefaults(); |
| 119 server_config_.SetDefaults(); | 124 server_config_.SetDefaults(); |
| 120 | 125 |
| 121 AddToCache("GET", kLargeRequest, "HTTP/1.1", "200", "OK", kFooResponseBody); | 126 AddToCache("GET", kLargeRequest, "HTTP/1.1", "200", "OK", kFooResponseBody); |
| 122 AddToCache("GET", "https://www.google.com/foo", | 127 AddToCache("GET", "https://www.google.com/foo", |
| 123 "HTTP/1.1", "200", "OK", kFooResponseBody); | 128 "HTTP/1.1", "200", "OK", kFooResponseBody); |
| 124 AddToCache("GET", "https://www.google.com/bar", | 129 AddToCache("GET", "https://www.google.com/bar", |
| 125 "HTTP/1.1", "200", "OK", kBarResponseBody); | 130 "HTTP/1.1", "200", "OK", kBarResponseBody); |
| 126 } | 131 version_ = GetParam(); |
| 127 | |
| 128 static void SetUpTestCase() { | |
| 129 QuicInMemoryCache::GetInstance()->ResetForTests(); | |
| 130 } | 132 } |
| 131 | 133 |
| 132 virtual QuicTestClient* CreateQuicClient() { | 134 virtual QuicTestClient* CreateQuicClient() { |
| 133 QuicTestClient* client = new QuicTestClient(server_address_, | 135 QuicTestClient* client = new QuicTestClient(server_address_, |
| 134 server_hostname_, | 136 server_hostname_, |
| 135 client_config_); | 137 client_config_, |
| 138 version_); |
| 136 client->Connect(); | 139 client->Connect(); |
| 137 return client; | 140 return client; |
| 138 } | 141 } |
| 139 | 142 |
| 140 virtual bool Initialize() { | 143 virtual bool Initialize() { |
| 141 // Start the server first, because CreateQuicClient() attempts | 144 // Start the server first, because CreateQuicClient() attempts |
| 142 // to connect to the server. | 145 // to connect to the server. |
| 143 StartServer(); | 146 StartServer(); |
| 144 client_.reset(CreateQuicClient()); | 147 client_.reset(CreateQuicClient()); |
| 145 return client_->client()->connected(); | 148 return client_->client()->connected(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 cache->AddResponse(request_headers, response_headers, body); | 201 cache->AddResponse(request_headers, response_headers, body); |
| 199 } | 202 } |
| 200 | 203 |
| 201 IPEndPoint server_address_; | 204 IPEndPoint server_address_; |
| 202 string server_hostname_; | 205 string server_hostname_; |
| 203 scoped_ptr<ServerThread> server_thread_; | 206 scoped_ptr<ServerThread> server_thread_; |
| 204 scoped_ptr<QuicTestClient> client_; | 207 scoped_ptr<QuicTestClient> client_; |
| 205 bool server_started_; | 208 bool server_started_; |
| 206 QuicConfig client_config_; | 209 QuicConfig client_config_; |
| 207 QuicConfig server_config_; | 210 QuicConfig server_config_; |
| 211 QuicVersion version_; |
| 208 }; | 212 }; |
| 209 | 213 |
| 210 TEST_F(EndToEndTest, SimpleRequestResponse) { | 214 // Run all end to end tests with QUIC version 6. |
| 215 INSTANTIATE_TEST_CASE_P(EndToEndTests, |
| 216 EndToEndTest, |
| 217 ::testing::Values(QUIC_VERSION_6)); |
| 218 |
| 219 TEST_P(EndToEndTest, SimpleRequestResponse) { |
| 211 // TODO(rtenneti): Delete this when NSS is supported. | 220 // TODO(rtenneti): Delete this when NSS is supported. |
| 212 if (!Aes128Gcm12Encrypter::IsSupported()) { | 221 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 213 LOG(INFO) << "AES GCM not supported. Test skipped."; | 222 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 214 return; | 223 return; |
| 215 } | 224 } |
| 216 | 225 |
| 217 ASSERT_TRUE(Initialize()); | 226 ASSERT_TRUE(Initialize()); |
| 218 | 227 |
| 219 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 228 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 220 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 229 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 221 } | 230 } |
| 222 | 231 |
| 223 // TODO(rch): figure out how to detect missing v6 supprt (like on the linux | 232 // TODO(rch): figure out how to detect missing v6 supprt (like on the linux |
| 224 // try bots) and selectively disable this test. | 233 // try bots) and selectively disable this test. |
| 225 TEST_F(EndToEndTest, DISABLED_SimpleRequestResponsev6) { | 234 TEST_P(EndToEndTest, DISABLED_SimpleRequestResponsev6) { |
| 226 // TODO(rtenneti): Delete this when NSS is supported. | 235 // TODO(rtenneti): Delete this when NSS is supported. |
| 227 if (!Aes128Gcm12Encrypter::IsSupported()) { | 236 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 228 LOG(INFO) << "AES GCM not supported. Test skipped."; | 237 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 229 return; | 238 return; |
| 230 } | 239 } |
| 231 | 240 |
| 232 IPAddressNumber ip; | 241 IPAddressNumber ip; |
| 233 CHECK(net::ParseIPLiteralToNumber("::1", &ip)); | 242 CHECK(net::ParseIPLiteralToNumber("::1", &ip)); |
| 234 server_address_ = IPEndPoint(ip, server_address_.port()); | 243 server_address_ = IPEndPoint(ip, server_address_.port()); |
| 235 ASSERT_TRUE(Initialize()); | 244 ASSERT_TRUE(Initialize()); |
| 236 | 245 |
| 237 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 246 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 238 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 247 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 239 } | 248 } |
| 240 | 249 |
| 241 TEST_F(EndToEndTest, SeparateFinPacket) { | 250 TEST_P(EndToEndTest, SeparateFinPacket) { |
| 242 // TODO(rtenneti): Delete this when NSS is supported. | 251 // TODO(rtenneti): Delete this when NSS is supported. |
| 243 if (!Aes128Gcm12Encrypter::IsSupported()) { | 252 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 244 LOG(INFO) << "AES GCM not supported. Test skipped."; | 253 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 245 return; | 254 return; |
| 246 } | 255 } |
| 247 | 256 |
| 248 ASSERT_TRUE(Initialize()); | 257 ASSERT_TRUE(Initialize()); |
| 249 | 258 |
| 250 HTTPMessage request(HttpConstants::HTTP_1_1, | 259 HTTPMessage request(HttpConstants::HTTP_1_1, |
| 251 HttpConstants::POST, "/foo"); | 260 HttpConstants::POST, "/foo"); |
| 252 request.set_has_complete_message(false); | 261 request.set_has_complete_message(false); |
| 253 | 262 |
| 254 client_->SendMessage(request); | 263 client_->SendMessage(request); |
| 255 | 264 |
| 256 client_->SendData(string(), true); | 265 client_->SendData(string(), true); |
| 257 | 266 |
| 258 client_->WaitForResponse(); | 267 client_->WaitForResponse(); |
| 259 EXPECT_EQ(kFooResponseBody, client_->response_body()); | 268 EXPECT_EQ(kFooResponseBody, client_->response_body()); |
| 260 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 269 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 261 | 270 |
| 262 request.AddBody("foo", true); | 271 request.AddBody("foo", true); |
| 263 | 272 |
| 264 client_->SendMessage(request); | 273 client_->SendMessage(request); |
| 265 client_->SendData(string(), true); | 274 client_->SendData(string(), true); |
| 266 client_->WaitForResponse(); | 275 client_->WaitForResponse(); |
| 267 EXPECT_EQ(kFooResponseBody, client_->response_body()); | 276 EXPECT_EQ(kFooResponseBody, client_->response_body()); |
| 268 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 277 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 269 } | 278 } |
| 270 | 279 |
| 271 TEST_F(EndToEndTest, MultipleRequestResponse) { | 280 TEST_P(EndToEndTest, MultipleRequestResponse) { |
| 272 // TODO(rtenneti): Delete this when NSS is supported. | 281 // TODO(rtenneti): Delete this when NSS is supported. |
| 273 if (!Aes128Gcm12Encrypter::IsSupported()) { | 282 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 274 LOG(INFO) << "AES GCM not supported. Test skipped."; | 283 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 275 return; | 284 return; |
| 276 } | 285 } |
| 277 | 286 |
| 278 ASSERT_TRUE(Initialize()); | 287 ASSERT_TRUE(Initialize()); |
| 279 | 288 |
| 280 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 289 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 281 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 290 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 282 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); | 291 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); |
| 283 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 292 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 284 } | 293 } |
| 285 | 294 |
| 286 TEST_F(EndToEndTest, MultipleClients) { | 295 TEST_P(EndToEndTest, MultipleClients) { |
| 287 // TODO(rtenneti): Delete this when NSS is supported. | 296 // TODO(rtenneti): Delete this when NSS is supported. |
| 288 if (!Aes128Gcm12Encrypter::IsSupported()) { | 297 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 289 LOG(INFO) << "AES GCM not supported. Test skipped."; | 298 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 290 return; | 299 return; |
| 291 } | 300 } |
| 292 | 301 |
| 293 ASSERT_TRUE(Initialize()); | 302 ASSERT_TRUE(Initialize()); |
| 294 scoped_ptr<QuicTestClient> client2(CreateQuicClient()); | 303 scoped_ptr<QuicTestClient> client2(CreateQuicClient()); |
| 295 | 304 |
| 296 HTTPMessage request(HttpConstants::HTTP_1_1, | 305 HTTPMessage request(HttpConstants::HTTP_1_1, |
| 297 HttpConstants::POST, "/foo"); | 306 HttpConstants::POST, "/foo"); |
| 298 request.AddHeader("content-length", "3"); | 307 request.AddHeader("content-length", "3"); |
| 299 request.set_has_complete_message(false); | 308 request.set_has_complete_message(false); |
| 300 | 309 |
| 301 client_->SendMessage(request); | 310 client_->SendMessage(request); |
| 302 client2->SendMessage(request); | 311 client2->SendMessage(request); |
| 303 | 312 |
| 304 client_->SendData("bar", true); | 313 client_->SendData("bar", true); |
| 305 client_->WaitForResponse(); | 314 client_->WaitForResponse(); |
| 306 EXPECT_EQ(kFooResponseBody, client_->response_body()); | 315 EXPECT_EQ(kFooResponseBody, client_->response_body()); |
| 307 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 316 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 308 | 317 |
| 309 client2->SendData("eep", true); | 318 client2->SendData("eep", true); |
| 310 client2->WaitForResponse(); | 319 client2->WaitForResponse(); |
| 311 EXPECT_EQ(kFooResponseBody, client2->response_body()); | 320 EXPECT_EQ(kFooResponseBody, client2->response_body()); |
| 312 EXPECT_EQ(200u, client2->response_headers()->parsed_response_code()); | 321 EXPECT_EQ(200u, client2->response_headers()->parsed_response_code()); |
| 313 } | 322 } |
| 314 | 323 |
| 315 TEST_F(EndToEndTest, RequestOverMultiplePackets) { | 324 TEST_P(EndToEndTest, RequestOverMultiplePackets) { |
| 316 // TODO(rtenneti): Delete this when NSS is supported. | 325 // TODO(rtenneti): Delete this when NSS is supported. |
| 317 if (!Aes128Gcm12Encrypter::IsSupported()) { | 326 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 318 LOG(INFO) << "AES GCM not supported. Test skipped."; | 327 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 319 return; | 328 return; |
| 320 } | 329 } |
| 321 | 330 |
| 322 ASSERT_TRUE(Initialize()); | 331 ASSERT_TRUE(Initialize()); |
| 323 // Set things up so we have a small payload, to guarantee fragmentation. | 332 // Set things up so we have a small payload, to guarantee fragmentation. |
| 324 // A congestion feedback frame can't be split into multiple packets, make sure | 333 // A congestion feedback frame can't be split into multiple packets, make sure |
| 325 // that our packet have room for at least this amount after the normal headers | 334 // that our packet have room for at least this amount after the normal headers |
| (...skipping 11 matching lines...) Expand all Loading... |
| 337 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, | 346 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, |
| 338 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP) + | 347 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP) + |
| 339 ciphertext_size; | 348 ciphertext_size; |
| 340 | 349 |
| 341 // Make sure our request is too large to fit in one packet. | 350 // Make sure our request is too large to fit in one packet. |
| 342 EXPECT_GT(strlen(kLargeRequest), min_payload_size); | 351 EXPECT_GT(strlen(kLargeRequest), min_payload_size); |
| 343 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest(kLargeRequest)); | 352 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest(kLargeRequest)); |
| 344 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 353 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 345 } | 354 } |
| 346 | 355 |
| 347 TEST_F(EndToEndTest, MultipleFramesRandomOrder) { | 356 TEST_P(EndToEndTest, MultipleFramesRandomOrder) { |
| 348 // TODO(rtenneti): Delete this when NSS is supported. | 357 // TODO(rtenneti): Delete this when NSS is supported. |
| 349 if (!Aes128Gcm12Encrypter::IsSupported()) { | 358 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 350 LOG(INFO) << "AES GCM not supported. Test skipped."; | 359 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 351 return; | 360 return; |
| 352 } | 361 } |
| 353 | 362 |
| 354 ASSERT_TRUE(Initialize()); | 363 ASSERT_TRUE(Initialize()); |
| 355 // Set things up so we have a small payload, to guarantee fragmentation. | 364 // Set things up so we have a small payload, to guarantee fragmentation. |
| 356 // A congestion feedback frame can't be split into multiple packets, make sure | 365 // A congestion feedback frame can't be split into multiple packets, make sure |
| 357 // that our packet have room for at least this amount after the normal headers | 366 // that our packet have room for at least this amount after the normal headers |
| (...skipping 12 matching lines...) Expand all Loading... |
| 370 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP) + | 379 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP) + |
| 371 ciphertext_size; | 380 ciphertext_size; |
| 372 client_->options()->random_reorder = true; | 381 client_->options()->random_reorder = true; |
| 373 | 382 |
| 374 // Make sure our request is too large to fit in one packet. | 383 // Make sure our request is too large to fit in one packet. |
| 375 EXPECT_GT(strlen(kLargeRequest), min_payload_size); | 384 EXPECT_GT(strlen(kLargeRequest), min_payload_size); |
| 376 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest(kLargeRequest)); | 385 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest(kLargeRequest)); |
| 377 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 386 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 378 } | 387 } |
| 379 | 388 |
| 380 TEST_F(EndToEndTest, PostMissingBytes) { | 389 TEST_P(EndToEndTest, PostMissingBytes) { |
| 381 // TODO(rtenneti): Delete this when NSS is supported. | 390 // TODO(rtenneti): Delete this when NSS is supported. |
| 382 if (!Aes128Gcm12Encrypter::IsSupported()) { | 391 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 383 LOG(INFO) << "AES GCM not supported. Test skipped."; | 392 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 384 return; | 393 return; |
| 385 } | 394 } |
| 386 | 395 |
| 387 ASSERT_TRUE(Initialize()); | 396 ASSERT_TRUE(Initialize()); |
| 388 | 397 |
| 389 // Add a content length header with no body. | 398 // Add a content length header with no body. |
| 390 HTTPMessage request(HttpConstants::HTTP_1_1, | 399 HTTPMessage request(HttpConstants::HTTP_1_1, |
| 391 HttpConstants::POST, "/foo"); | 400 HttpConstants::POST, "/foo"); |
| 392 request.AddHeader("content-length", "3"); | 401 request.AddHeader("content-length", "3"); |
| 393 request.set_skip_message_validation(true); | 402 request.set_skip_message_validation(true); |
| 394 | 403 |
| 395 // This should be detected as stream fin without complete request, | 404 // This should be detected as stream fin without complete request, |
| 396 // triggering an error response. | 405 // triggering an error response. |
| 397 client_->SendCustomSynchronousRequest(request); | 406 client_->SendCustomSynchronousRequest(request); |
| 398 EXPECT_EQ("bad", client_->response_body()); | 407 EXPECT_EQ("bad", client_->response_body()); |
| 399 EXPECT_EQ(500u, client_->response_headers()->parsed_response_code()); | 408 EXPECT_EQ(500u, client_->response_headers()->parsed_response_code()); |
| 400 } | 409 } |
| 401 | 410 |
| 402 TEST_F(EndToEndTest, LargePost) { | 411 TEST_P(EndToEndTest, LargePost) { |
| 403 // TODO(rtenneti): Delete this when NSS is supported. | 412 // TODO(rtenneti): Delete this when NSS is supported. |
| 404 if (!Aes128Gcm12Encrypter::IsSupported()) { | 413 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 405 LOG(INFO) << "AES GCM not supported. Test skipped."; | 414 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 406 return; | 415 return; |
| 407 } | 416 } |
| 408 | 417 |
| 409 // FLAGS_fake_packet_loss_percentage = 30; | 418 // FLAGS_fake_packet_loss_percentage = 30; |
| 410 ASSERT_TRUE(Initialize()); | 419 ASSERT_TRUE(Initialize()); |
| 411 | 420 |
| 412 string body; | 421 string body; |
| 413 GenerateBody(&body, 10240); | 422 GenerateBody(&body, 10240); |
| 414 | 423 |
| 415 HTTPMessage request(HttpConstants::HTTP_1_1, | 424 HTTPMessage request(HttpConstants::HTTP_1_1, |
| 416 HttpConstants::POST, "/foo"); | 425 HttpConstants::POST, "/foo"); |
| 417 request.AddBody(body, true); | 426 request.AddBody(body, true); |
| 418 | 427 |
| 419 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 428 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
| 420 } | 429 } |
| 421 | 430 |
| 422 // TODO(ianswett): Enable once b/9295090 is fixed. | 431 // TODO(ianswett): Enable once b/9295090 is fixed. |
| 423 TEST_F(EndToEndTest, DISABLED_LargePostFEC) { | 432 TEST_P(EndToEndTest, DISABLED_LargePostFEC) { |
| 424 // FLAGS_fake_packet_loss_percentage = 30; | 433 // FLAGS_fake_packet_loss_percentage = 30; |
| 425 ASSERT_TRUE(Initialize()); | 434 ASSERT_TRUE(Initialize()); |
| 426 client_->options()->max_packets_per_fec_group = 6; | 435 client_->options()->max_packets_per_fec_group = 6; |
| 427 | 436 |
| 428 // TODO(rtenneti): Delete this when NSS is supported. | 437 // TODO(rtenneti): Delete this when NSS is supported. |
| 429 if (!Aes128Gcm12Encrypter::IsSupported()) { | 438 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 430 LOG(INFO) << "AES GCM not supported. Test skipped."; | 439 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 431 return; | 440 return; |
| 432 } | 441 } |
| 433 | 442 |
| 434 // FLAGS_fake_packet_loss_percentage = 30; | 443 // FLAGS_fake_packet_loss_percentage = 30; |
| 435 ASSERT_TRUE(Initialize()); | 444 ASSERT_TRUE(Initialize()); |
| 436 client_->options()->max_packets_per_fec_group = 6; | 445 client_->options()->max_packets_per_fec_group = 6; |
| 437 | 446 |
| 438 string body; | 447 string body; |
| 439 GenerateBody(&body, 10240); | 448 GenerateBody(&body, 10240); |
| 440 | 449 |
| 441 HTTPMessage request(HttpConstants::HTTP_1_1, | 450 HTTPMessage request(HttpConstants::HTTP_1_1, |
| 442 HttpConstants::POST, "/foo"); | 451 HttpConstants::POST, "/foo"); |
| 443 request.AddBody(body, true); | 452 request.AddBody(body, true); |
| 444 | 453 |
| 445 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 454 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
| 446 } | 455 } |
| 447 | 456 |
| 448 /*TEST_F(EndToEndTest, PacketTooLarge) { | 457 /*TEST_P(EndToEndTest, PacketTooLarge) { |
| 449 FLAGS_quic_allow_oversized_packets_for_test = true; | 458 FLAGS_quic_allow_oversized_packets_for_test = true; |
| 450 ASSERT_TRUE(Initialize()); | 459 ASSERT_TRUE(Initialize()); |
| 451 | 460 |
| 452 string body; | 461 string body; |
| 453 GenerateBody(&body, kMaxPacketSize); | 462 GenerateBody(&body, kMaxPacketSize); |
| 454 | 463 |
| 455 HTTPMessage request(HttpConstants::HTTP_1_1, | 464 HTTPMessage request(HttpConstants::HTTP_1_1, |
| 456 HttpConstants::POST, "/foo"); | 465 HttpConstants::POST, "/foo"); |
| 457 request.AddBody(body, true); | 466 request.AddBody(body, true); |
| 458 client_->options()->max_packet_length = 20480; | 467 client_->options()->max_packet_length = 20480; |
| 459 | 468 |
| 460 EXPECT_EQ("", client_->SendCustomSynchronousRequest(request)); | 469 EXPECT_EQ("", client_->SendCustomSynchronousRequest(request)); |
| 461 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); | 470 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); |
| 462 EXPECT_EQ(QUIC_PACKET_TOO_LARGE, client_->connection_error()); | 471 EXPECT_EQ(QUIC_PACKET_TOO_LARGE, client_->connection_error()); |
| 463 }*/ | 472 }*/ |
| 464 | 473 |
| 465 TEST_F(EndToEndTest, InvalidStream) { | 474 TEST_P(EndToEndTest, InvalidStream) { |
| 466 // TODO(rtenneti): Delete this when NSS is supported. | 475 // TODO(rtenneti): Delete this when NSS is supported. |
| 467 if (!Aes128Gcm12Encrypter::IsSupported()) { | 476 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 468 LOG(INFO) << "AES GCM not supported. Test skipped."; | 477 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 469 return; | 478 return; |
| 470 } | 479 } |
| 471 | 480 |
| 472 ASSERT_TRUE(Initialize()); | 481 ASSERT_TRUE(Initialize()); |
| 473 | 482 |
| 474 string body; | 483 string body; |
| 475 GenerateBody(&body, kMaxPacketSize); | 484 GenerateBody(&body, kMaxPacketSize); |
| 476 | 485 |
| 477 HTTPMessage request(HttpConstants::HTTP_1_1, | 486 HTTPMessage request(HttpConstants::HTTP_1_1, |
| 478 HttpConstants::POST, "/foo"); | 487 HttpConstants::POST, "/foo"); |
| 479 request.AddBody(body, true); | 488 request.AddBody(body, true); |
| 480 // Force the client to write with a stream ID belonging to a nonexistant | 489 // Force the client to write with a stream ID belonging to a nonexistant |
| 481 // server-side stream. | 490 // server-side stream. |
| 482 QuicSessionPeer::SetNextStreamId(client_->client()->session(), 2); | 491 QuicSessionPeer::SetNextStreamId(client_->client()->session(), 2); |
| 483 | 492 |
| 484 client_->SendCustomSynchronousRequest(request); | 493 client_->SendCustomSynchronousRequest(request); |
| 485 // EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); | 494 // EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); |
| 486 EXPECT_EQ(QUIC_PACKET_FOR_NONEXISTENT_STREAM, client_->connection_error()); | 495 EXPECT_EQ(QUIC_PACKET_FOR_NONEXISTENT_STREAM, client_->connection_error()); |
| 487 } | 496 } |
| 488 | 497 |
| 489 // TODO(rch): this test seems to cause net_unittests timeouts :| | 498 // TODO(rch): this test seems to cause net_unittests timeouts :| |
| 490 TEST_F(EndToEndTest, DISABLED_MultipleTermination) { | 499 TEST_P(EndToEndTest, DISABLED_MultipleTermination) { |
| 491 // TODO(rtenneti): Delete this when NSS is supported. | 500 // TODO(rtenneti): Delete this when NSS is supported. |
| 492 if (!Aes128Gcm12Encrypter::IsSupported()) { | 501 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 493 LOG(INFO) << "AES GCM not supported. Test skipped."; | 502 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 494 return; | 503 return; |
| 495 } | 504 } |
| 496 | 505 |
| 497 ASSERT_TRUE(Initialize()); | 506 ASSERT_TRUE(Initialize()); |
| 498 scoped_ptr<QuicTestClient> client2(CreateQuicClient()); | 507 scoped_ptr<QuicTestClient> client2(CreateQuicClient()); |
| 499 | 508 |
| 500 HTTPMessage request(HttpConstants::HTTP_1_1, | 509 HTTPMessage request(HttpConstants::HTTP_1_1, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 528 EXPECT_DEATH({ | 537 EXPECT_DEATH({ |
| 529 client_->SendData("eep", true); | 538 client_->SendData("eep", true); |
| 530 client_->WaitForResponse(); | 539 client_->WaitForResponse(); |
| 531 EXPECT_EQ(QUIC_MULTIPLE_TERMINATION_OFFSETS, client_->stream_error()); | 540 EXPECT_EQ(QUIC_MULTIPLE_TERMINATION_OFFSETS, client_->stream_error()); |
| 532 }, | 541 }, |
| 533 "Check failed: !fin_buffered_"); | 542 "Check failed: !fin_buffered_"); |
| 534 #endif | 543 #endif |
| 535 #endif | 544 #endif |
| 536 } | 545 } |
| 537 | 546 |
| 538 TEST_F(EndToEndTest, Timeout) { | 547 TEST_P(EndToEndTest, Timeout) { |
| 539 client_config_.set_idle_connection_state_lifetime( | 548 client_config_.set_idle_connection_state_lifetime( |
| 540 QuicTime::Delta::FromMicroseconds(500), | 549 QuicTime::Delta::FromMicroseconds(500), |
| 541 QuicTime::Delta::FromMicroseconds(500)); | 550 QuicTime::Delta::FromMicroseconds(500)); |
| 542 // Note: we do NOT ASSERT_TRUE: we may time out during initial handshake: | 551 // Note: we do NOT ASSERT_TRUE: we may time out during initial handshake: |
| 543 // that's enough to validate timeout in this case. | 552 // that's enough to validate timeout in this case. |
| 544 Initialize(); | 553 Initialize(); |
| 545 while (client_->client()->connected()) { | 554 while (client_->client()->connected()) { |
| 546 client_->client()->WaitForEvents(); | 555 client_->client()->WaitForEvents(); |
| 547 } | 556 } |
| 548 } | 557 } |
| 549 | 558 |
| 550 TEST_F(EndToEndTest, LimitMaxOpenStreams) { | 559 TEST_P(EndToEndTest, LimitMaxOpenStreams) { |
| 551 // Server limits the number of max streams to 2. | 560 // Server limits the number of max streams to 2. |
| 552 server_config_.set_max_streams_per_connection(2, 2); | 561 server_config_.set_max_streams_per_connection(2, 2); |
| 553 // Client tries to negotiate for 10. | 562 // Client tries to negotiate for 10. |
| 554 client_config_.set_max_streams_per_connection(10, 5); | 563 client_config_.set_max_streams_per_connection(10, 5); |
| 555 | 564 |
| 556 ASSERT_TRUE(Initialize()); | 565 ASSERT_TRUE(Initialize()); |
| 557 client_->client()->WaitForCryptoHandshakeConfirmed(); | 566 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 558 QuicConfig* client_negotiated_config = client_->client()->session()->config(); | 567 QuicConfig* client_negotiated_config = client_->client()->session()->config(); |
| 559 EXPECT_EQ(2u, client_negotiated_config->max_streams_per_connection()); | 568 EXPECT_EQ(2u, client_negotiated_config->max_streams_per_connection()); |
| 560 } | 569 } |
| 561 | 570 |
| 562 TEST_F(EndToEndTest, ResetConnection) { | 571 TEST_P(EndToEndTest, ResetConnection) { |
| 563 // TODO(rtenneti): Delete this when NSS is supported. | 572 // TODO(rtenneti): Delete this when NSS is supported. |
| 564 if (!Aes128Gcm12Encrypter::IsSupported()) { | 573 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 565 LOG(INFO) << "AES GCM not supported. Test skipped."; | 574 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 566 return; | 575 return; |
| 567 } | 576 } |
| 568 | 577 |
| 569 ASSERT_TRUE(Initialize()); | 578 ASSERT_TRUE(Initialize()); |
| 570 | 579 |
| 571 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 580 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 572 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 581 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 590 int* error) OVERRIDE { | 599 int* error) OVERRIDE { |
| 591 return QuicSocketUtils::WritePacket(fd_, buffer, buf_len, | 600 return QuicSocketUtils::WritePacket(fd_, buffer, buf_len, |
| 592 self_address_.address(), peer_address, | 601 self_address_.address(), peer_address, |
| 593 error); | 602 error); |
| 594 } | 603 } |
| 595 | 604 |
| 596 IPEndPoint self_address_; | 605 IPEndPoint self_address_; |
| 597 int fd_; | 606 int fd_; |
| 598 }; | 607 }; |
| 599 | 608 |
| 600 TEST_F(EndToEndTest, ConnectionMigration) { | 609 TEST_P(EndToEndTest, ConnectionMigration) { |
| 601 // TODO(rtenneti): Delete this when NSS is supported. | 610 // TODO(rtenneti): Delete this when NSS is supported. |
| 602 if (!Aes128Gcm12Encrypter::IsSupported()) { | 611 if (!Aes128Gcm12Encrypter::IsSupported()) { |
| 603 LOG(INFO) << "AES GCM not supported. Test skipped."; | 612 LOG(INFO) << "AES GCM not supported. Test skipped."; |
| 604 return; | 613 return; |
| 605 } | 614 } |
| 606 | 615 |
| 607 ASSERT_TRUE(Initialize()); | 616 ASSERT_TRUE(Initialize()); |
| 608 | 617 |
| 609 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 618 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
| 610 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 619 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
| 611 | 620 |
| 612 WrongAddressWriter writer(QuicClientPeer::GetFd(client_->client())); | 621 WrongAddressWriter writer(QuicClientPeer::GetFd(client_->client())); |
| 613 QuicEpollConnectionHelper* helper = | 622 QuicEpollConnectionHelper* helper = |
| 614 reinterpret_cast<QuicEpollConnectionHelper*>( | 623 reinterpret_cast<QuicEpollConnectionHelper*>( |
| 615 QuicConnectionPeer::GetHelper( | 624 QuicConnectionPeer::GetHelper( |
| 616 client_->client()->session()->connection())); | 625 client_->client()->session()->connection())); |
| 617 QuicEpollConnectionHelperPeer::SetWriter(helper, &writer); | 626 QuicEpollConnectionHelperPeer::SetWriter(helper, &writer); |
| 618 | 627 |
| 619 client_->SendSynchronousRequest("/bar"); | 628 client_->SendSynchronousRequest("/bar"); |
| 620 QuicEpollConnectionHelperPeer::SetWriter(helper, NULL); | 629 QuicEpollConnectionHelperPeer::SetWriter(helper, NULL); |
| 621 | 630 |
| 622 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); | 631 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); |
| 623 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error()); | 632 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error()); |
| 624 } | 633 } |
| 625 | 634 |
| 626 } // namespace | 635 } // namespace |
| 627 } // namespace test | 636 } // namespace test |
| 628 } // namespace tools | 637 } // namespace tools |
| 629 } // namespace net | 638 } // namespace net |
| OLD | NEW |