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

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

Issue 1245013003: QUIC - clean up changes to keep internal source and chromium code in sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Protect_against_QUIC_crash_bug_98506577
Patch Set: Merge with TOT Created 5 years, 5 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
« no previous file with comments | « net/quic/quic_protocol.h ('k') | net/tools/quic/quic_client_bin.cc » ('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 <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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 server_address_ = IPEndPoint(ip, server_address_.port()); 450 server_address_ = IPEndPoint(ip, server_address_.port());
451 ASSERT_TRUE(Initialize()); 451 ASSERT_TRUE(Initialize());
452 452
453 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 453 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
454 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 454 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
455 } 455 }
456 456
457 TEST_P(EndToEndTest, SeparateFinPacket) { 457 TEST_P(EndToEndTest, SeparateFinPacket) {
458 ASSERT_TRUE(Initialize()); 458 ASSERT_TRUE(Initialize());
459 459
460 HTTPMessage request(HttpConstants::HTTP_1_1, 460 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
461 HttpConstants::POST, "/foo");
462 request.set_has_complete_message(false); 461 request.set_has_complete_message(false);
463 462
464 // Send a request in two parts: the request and then an empty packet with FIN. 463 // Send a request in two parts: the request and then an empty packet with FIN.
465 client_->SendMessage(request); 464 client_->SendMessage(request);
466 client_->SendData("", true); 465 client_->SendData("", true);
467 client_->WaitForResponse(); 466 client_->WaitForResponse();
468 EXPECT_EQ(kFooResponseBody, client_->response_body()); 467 EXPECT_EQ(kFooResponseBody, client_->response_body());
469 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 468 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
470 469
471 // Now do the same thing but with a content length. 470 // Now do the same thing but with a content length.
(...skipping 11 matching lines...) Expand all
483 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 482 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
484 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 483 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
485 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); 484 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar"));
486 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 485 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
487 } 486 }
488 487
489 TEST_P(EndToEndTest, MultipleClients) { 488 TEST_P(EndToEndTest, MultipleClients) {
490 ASSERT_TRUE(Initialize()); 489 ASSERT_TRUE(Initialize());
491 scoped_ptr<QuicTestClient> client2(CreateQuicClient(nullptr)); 490 scoped_ptr<QuicTestClient> client2(CreateQuicClient(nullptr));
492 491
493 HTTPMessage request(HttpConstants::HTTP_1_1, 492 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
494 HttpConstants::POST, "/foo");
495 request.AddHeader("content-length", "3"); 493 request.AddHeader("content-length", "3");
496 request.set_has_complete_message(false); 494 request.set_has_complete_message(false);
497 495
498 client_->SendMessage(request); 496 client_->SendMessage(request);
499 client2->SendMessage(request); 497 client2->SendMessage(request);
500 498
501 client_->SendData("bar", true); 499 client_->SendData("bar", true);
502 client_->WaitForResponse(); 500 client_->WaitForResponse();
503 EXPECT_EQ(kFooResponseBody, client_->response_body()); 501 EXPECT_EQ(kFooResponseBody, client_->response_body());
504 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 502 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
(...skipping 25 matching lines...) Expand all
530 SetReorderPercentage(50); 528 SetReorderPercentage(50);
531 529
532 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest(huge_request)); 530 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest(huge_request));
533 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 531 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
534 } 532 }
535 533
536 TEST_P(EndToEndTest, PostMissingBytes) { 534 TEST_P(EndToEndTest, PostMissingBytes) {
537 ASSERT_TRUE(Initialize()); 535 ASSERT_TRUE(Initialize());
538 536
539 // Add a content length header with no body. 537 // Add a content length header with no body.
540 HTTPMessage request(HttpConstants::HTTP_1_1, 538 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
541 HttpConstants::POST, "/foo");
542 request.AddHeader("content-length", "3"); 539 request.AddHeader("content-length", "3");
543 request.set_skip_message_validation(true); 540 request.set_skip_message_validation(true);
544 541
545 // This should be detected as stream fin without complete request, 542 // This should be detected as stream fin without complete request,
546 // triggering an error response. 543 // triggering an error response.
547 client_->SendCustomSynchronousRequest(request); 544 client_->SendCustomSynchronousRequest(request);
548 EXPECT_EQ("bad", client_->response_body()); 545 EXPECT_EQ("bad", client_->response_body());
549 EXPECT_EQ(500u, client_->response_headers()->parsed_response_code()); 546 EXPECT_EQ(500u, client_->response_headers()->parsed_response_code());
550 } 547 }
551 548
552 // TODO(rtenneti): DISABLED_LargePostNoPacketLoss seems to be flaky. 549 // TODO(rtenneti): DISABLED_LargePostNoPacketLoss seems to be flaky.
553 // http://crbug.com/297040. 550 // http://crbug.com/297040.
554 TEST_P(EndToEndTest, DISABLED_LargePostNoPacketLoss) { 551 TEST_P(EndToEndTest, DISABLED_LargePostNoPacketLoss) {
555 ASSERT_TRUE(Initialize()); 552 ASSERT_TRUE(Initialize());
556 553
557 client_->client()->WaitForCryptoHandshakeConfirmed(); 554 client_->client()->WaitForCryptoHandshakeConfirmed();
558 555
559 // 1 MB body. 556 // 1 MB body.
560 string body; 557 string body;
561 GenerateBody(&body, 1024 * 1024); 558 GenerateBody(&body, 1024 * 1024);
562 559
563 HTTPMessage request(HttpConstants::HTTP_1_1, 560 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
564 HttpConstants::POST, "/foo");
565 request.AddBody(body, true); 561 request.AddBody(body, true);
566 562
567 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); 563 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request));
568 VerifyCleanConnection(false); 564 VerifyCleanConnection(false);
569 } 565 }
570 566
571 TEST_P(EndToEndTest, LargePostNoPacketLoss1sRTT) { 567 TEST_P(EndToEndTest, LargePostNoPacketLoss1sRTT) {
572 ASSERT_TRUE(Initialize()); 568 ASSERT_TRUE(Initialize());
573 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(1000)); 569 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(1000));
574 570
575 client_->client()->WaitForCryptoHandshakeConfirmed(); 571 client_->client()->WaitForCryptoHandshakeConfirmed();
576 572
577 // 100 KB body. 573 // 100 KB body.
578 string body; 574 string body;
579 GenerateBody(&body, 100 * 1024); 575 GenerateBody(&body, 100 * 1024);
580 576
581 HTTPMessage request(HttpConstants::HTTP_1_1, 577 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
582 HttpConstants::POST, "/foo");
583 request.AddBody(body, true); 578 request.AddBody(body, true);
584 579
585 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); 580 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request));
586 VerifyCleanConnection(false); 581 VerifyCleanConnection(false);
587 } 582 }
588 583
589 TEST_P(EndToEndTest, LargePostWithPacketLoss) { 584 TEST_P(EndToEndTest, LargePostWithPacketLoss) {
590 // Connect with lower fake packet loss than we'd like to test. Until 585 // Connect with lower fake packet loss than we'd like to test. Until
591 // b/10126687 is fixed, losing handshake packets is pretty brutal. 586 // b/10126687 is fixed, losing handshake packets is pretty brutal.
592 SetPacketLossPercentage(5); 587 SetPacketLossPercentage(5);
593 ASSERT_TRUE(Initialize()); 588 ASSERT_TRUE(Initialize());
594 589
595 // Wait for the server SHLO before upping the packet loss. 590 // Wait for the server SHLO before upping the packet loss.
596 client_->client()->WaitForCryptoHandshakeConfirmed(); 591 client_->client()->WaitForCryptoHandshakeConfirmed();
597 SetPacketLossPercentage(30); 592 SetPacketLossPercentage(30);
598 593
599 // 10 KB body. 594 // 10 KB body.
600 string body; 595 string body;
601 GenerateBody(&body, 1024 * 10); 596 GenerateBody(&body, 1024 * 10);
602 597
603 HTTPMessage request(HttpConstants::HTTP_1_1, 598 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
604 HttpConstants::POST, "/foo");
605 request.AddBody(body, true); 599 request.AddBody(body, true);
606 600
607 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); 601 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request));
608 VerifyCleanConnection(true); 602 VerifyCleanConnection(true);
609 } 603 }
610 604
611 TEST_P(EndToEndTest, LargePostWithPacketLossAndBlockedSocket) { 605 TEST_P(EndToEndTest, LargePostWithPacketLossAndBlockedSocket) {
612 // Connect with lower fake packet loss than we'd like to test. Until 606 // Connect with lower fake packet loss than we'd like to test. Until
613 // b/10126687 is fixed, losing handshake packets is pretty brutal. 607 // b/10126687 is fixed, losing handshake packets is pretty brutal.
614 SetPacketLossPercentage(5); 608 SetPacketLossPercentage(5);
615 ASSERT_TRUE(Initialize()); 609 ASSERT_TRUE(Initialize());
616 610
617 // Wait for the server SHLO before upping the packet loss. 611 // Wait for the server SHLO before upping the packet loss.
618 client_->client()->WaitForCryptoHandshakeConfirmed(); 612 client_->client()->WaitForCryptoHandshakeConfirmed();
619 SetPacketLossPercentage(10); 613 SetPacketLossPercentage(10);
620 client_writer_->set_fake_blocked_socket_percentage(10); 614 client_writer_->set_fake_blocked_socket_percentage(10);
621 615
622 // 10 KB body. 616 // 10 KB body.
623 string body; 617 string body;
624 GenerateBody(&body, 1024 * 10); 618 GenerateBody(&body, 1024 * 10);
625 619
626 HTTPMessage request(HttpConstants::HTTP_1_1, 620 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
627 HttpConstants::POST, "/foo");
628 request.AddBody(body, true); 621 request.AddBody(body, true);
629 622
630 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); 623 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request));
631 } 624 }
632 625
633 TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) { 626 TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) {
634 ASSERT_TRUE(Initialize()); 627 ASSERT_TRUE(Initialize());
635 628
636 client_->client()->WaitForCryptoHandshakeConfirmed(); 629 client_->client()->WaitForCryptoHandshakeConfirmed();
637 // Both of these must be called when the writer is not actively used. 630 // Both of these must be called when the writer is not actively used.
638 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); 631 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2));
639 SetReorderPercentage(30); 632 SetReorderPercentage(30);
640 633
641 // 1 MB body. 634 // 1 MB body.
642 string body; 635 string body;
643 GenerateBody(&body, 1024 * 1024); 636 GenerateBody(&body, 1024 * 1024);
644 637
645 HTTPMessage request(HttpConstants::HTTP_1_1, 638 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
646 HttpConstants::POST, "/foo");
647 request.AddBody(body, true); 639 request.AddBody(body, true);
648 640
649 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); 641 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request));
650 } 642 }
651 643
652 TEST_P(EndToEndTest, LargePostZeroRTTFailure) { 644 TEST_P(EndToEndTest, LargePostZeroRTTFailure) {
653 // Have the server accept 0-RTT without waiting a startup period. 645 // Have the server accept 0-RTT without waiting a startup period.
654 strike_register_no_startup_period_ = true; 646 strike_register_no_startup_period_ = true;
655 647
656 // Send a request and then disconnect. This prepares the client to attempt 648 // Send a request and then disconnect. This prepares the client to attempt
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 784
793 client_->SendCustomSynchronousRequest(request); 785 client_->SendCustomSynchronousRequest(request);
794 // EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); 786 // EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error());
795 EXPECT_EQ(QUIC_PACKET_FOR_NONEXISTENT_STREAM, client_->connection_error()); 787 EXPECT_EQ(QUIC_PACKET_FOR_NONEXISTENT_STREAM, client_->connection_error());
796 } 788 }
797 789
798 // TODO(rch): this test seems to cause net_unittests timeouts :| 790 // TODO(rch): this test seems to cause net_unittests timeouts :|
799 TEST_P(EndToEndTest, DISABLED_MultipleTermination) { 791 TEST_P(EndToEndTest, DISABLED_MultipleTermination) {
800 ASSERT_TRUE(Initialize()); 792 ASSERT_TRUE(Initialize());
801 793
802 HTTPMessage request(HttpConstants::HTTP_1_1, 794 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
803 HttpConstants::POST, "/foo");
804 request.AddHeader("content-length", "3"); 795 request.AddHeader("content-length", "3");
805 request.set_has_complete_message(false); 796 request.set_has_complete_message(false);
806 797
807 // Set the offset so we won't frame. Otherwise when we pick up termination 798 // Set the offset so we won't frame. Otherwise when we pick up termination
808 // before HTTP framing is complete, we send an error and close the stream, 799 // before HTTP framing is complete, we send an error and close the stream,
809 // and the second write is picked up as writing on a closed stream. 800 // and the second write is picked up as writing on a closed stream.
810 QuicSpdyClientStream* stream = client_->GetOrCreateStream(); 801 QuicSpdyClientStream* stream = client_->GetOrCreateStream();
811 ASSERT_TRUE(stream != nullptr); 802 ASSERT_TRUE(stream != nullptr);
812 ReliableQuicStreamPeer::SetStreamBytesWritten(3, stream); 803 ReliableQuicStreamPeer::SetStreamBytesWritten(3, stream);
813 804
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 1627
1637 // The connection should not be terminated. 1628 // The connection should not be terminated.
1638 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 1629 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
1639 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 1630 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1640 } 1631 }
1641 1632
1642 } // namespace 1633 } // namespace
1643 } // namespace test 1634 } // namespace test
1644 } // namespace tools 1635 } // namespace tools
1645 } // namespace net 1636 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_protocol.h ('k') | net/tools/quic/quic_client_bin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698