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

Side by Side Diff: net/quic/chromium/quic_network_transaction_unittest.cc

Issue 2901093004: Add and persist a new field in AlternativeServiceInfo to list QUIC verisons advertised (Closed)
Patch Set: self review Created 3 years, 7 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
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 <memory> 5 #include <memory>
6 #include <ostream> 6 #include <ostream>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 uint16_t port) { 600 uint16_t port) {
601 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, true, port); 601 SendRequestAndExpectQuicResponseMaybeFromProxy(expected, true, port);
602 } 602 }
603 603
604 void AddQuicAlternateProtocolMapping( 604 void AddQuicAlternateProtocolMapping(
605 MockCryptoClientStream::HandshakeMode handshake_mode) { 605 MockCryptoClientStream::HandshakeMode handshake_mode) {
606 crypto_client_stream_factory_.set_handshake_mode(handshake_mode); 606 crypto_client_stream_factory_.set_handshake_mode(handshake_mode);
607 url::SchemeHostPort server(request_.url); 607 url::SchemeHostPort server(request_.url);
608 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 608 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
609 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 609 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
610 http_server_properties_.SetAlternativeService(server, alternative_service, 610 http_server_properties_.SetAlternativeService(
611 expiration); 611 server, alternative_service, expiration,
612 HttpNetworkSession::Params().quic_supported_versions);
612 } 613 }
613 614
614 void AddQuicRemoteAlternativeServiceMapping( 615 void AddQuicRemoteAlternativeServiceMapping(
615 MockCryptoClientStream::HandshakeMode handshake_mode, 616 MockCryptoClientStream::HandshakeMode handshake_mode,
616 const HostPortPair& alternative) { 617 const HostPortPair& alternative) {
617 crypto_client_stream_factory_.set_handshake_mode(handshake_mode); 618 crypto_client_stream_factory_.set_handshake_mode(handshake_mode);
618 url::SchemeHostPort server(request_.url); 619 url::SchemeHostPort server(request_.url);
619 AlternativeService alternative_service(kProtoQUIC, alternative.host(), 620 AlternativeService alternative_service(kProtoQUIC, alternative.host(),
620 alternative.port()); 621 alternative.port());
621 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 622 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
622 http_server_properties_.SetAlternativeService(server, alternative_service, 623 http_server_properties_.SetAlternativeService(
623 expiration); 624 server, alternative_service, expiration,
625 HttpNetworkSession::Params().quic_supported_versions);
624 } 626 }
625 627
626 void ExpectBrokenAlternateProtocolMapping() { 628 void ExpectBrokenAlternateProtocolMapping() {
627 const url::SchemeHostPort server(request_.url); 629 const url::SchemeHostPort server(request_.url);
628 const AlternativeServiceInfoVector alternative_service_info_vector = 630 const AlternativeServiceInfoVector alternative_service_info_vector =
629 http_server_properties_.GetAlternativeServiceInfos(server); 631 http_server_properties_.GetAlternativeServiceInfos(server);
630 EXPECT_EQ(1u, alternative_service_info_vector.size()); 632 EXPECT_EQ(1u, alternative_service_info_vector.size());
631 EXPECT_TRUE(http_server_properties_.IsAlternativeServiceBroken( 633 EXPECT_TRUE(http_server_properties_.IsAlternativeServiceBroken(
632 alternative_service_info_vector[0].alternative_service)); 634 alternative_service_info_vector[0].alternative_service));
633 } 635 }
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 // HttpNetworkTransaction should reset the request and retry without using 1070 // HttpNetworkTransaction should reset the request and retry without using
1069 // alternative services. 1071 // alternative services.
1070 TEST_P(QuicNetworkTransactionTest, RetryMisdirectedRequest) { 1072 TEST_P(QuicNetworkTransactionTest, RetryMisdirectedRequest) {
1071 // Set up alternative service to use QUIC. 1073 // Set up alternative service to use QUIC.
1072 // Note that |origins_to_force_quic_on| cannot be used in this test, because 1074 // Note that |origins_to_force_quic_on| cannot be used in this test, because
1073 // that overrides |enable_alternative_services|. 1075 // that overrides |enable_alternative_services|.
1074 url::SchemeHostPort server(request_.url); 1076 url::SchemeHostPort server(request_.url);
1075 AlternativeService alternative_service(kProtoQUIC, kDefaultServerHostName, 1077 AlternativeService alternative_service(kProtoQUIC, kDefaultServerHostName,
1076 443); 1078 443);
1077 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 1079 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
1078 http_server_properties_.SetAlternativeService(server, alternative_service, 1080 http_server_properties_.SetAlternativeService(
1079 expiration); 1081 server, alternative_service, expiration,
1082 HttpNetworkSession::Params().quic_supported_versions);
1080 1083
1081 // First try: The alternative job uses QUIC and reports an HTTP 421 1084 // First try: The alternative job uses QUIC and reports an HTTP 421
1082 // Misdirected Request error. The main job uses TCP, but |http_data| below is 1085 // Misdirected Request error. The main job uses TCP, but |http_data| below is
1083 // paused at Connect(), so it will never exit the socket pool. This ensures 1086 // paused at Connect(), so it will never exit the socket pool. This ensures
1084 // that the alternate job always wins the race and keeps whether the 1087 // that the alternate job always wins the race and keeps whether the
1085 // |http_data| exits the socket pool before the main job is aborted 1088 // |http_data| exits the socket pool before the main job is aborted
1086 // deterministic. The first main job gets aborted without the socket pool ever 1089 // deterministic. The first main job gets aborted without the socket pool ever
1087 // dispensing the socket, making it available for the second try. 1090 // dispensing the socket, making it available for the second try.
1088 MockQuicData mock_quic_data; 1091 MockQuicData mock_quic_data;
1089 QuicStreamOffset request_header_offset = 0; 1092 QuicStreamOffset request_header_offset = 0;
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
2667 2670
2668 CreateSession(); 2671 CreateSession();
2669 2672
2670 const char destination1[] = "first.example.com"; 2673 const char destination1[] = "first.example.com";
2671 const char destination2[] = "second.example.com"; 2674 const char destination2[] = "second.example.com";
2672 2675
2673 // Set up alternative service entry to destination1. 2676 // Set up alternative service entry to destination1.
2674 url::SchemeHostPort server(request_.url); 2677 url::SchemeHostPort server(request_.url);
2675 AlternativeService alternative_service(kProtoQUIC, destination1, 443); 2678 AlternativeService alternative_service(kProtoQUIC, destination1, 443);
2676 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 2679 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
2677 http_server_properties_.SetAlternativeService(server, alternative_service, 2680 http_server_properties_.SetAlternativeService(
2678 expiration); 2681 server, alternative_service, expiration,
2682 HttpNetworkSession::Params().quic_supported_versions);
2679 // First request opens connection to |destination1| 2683 // First request opens connection to |destination1|
2680 // with QuicServerId.host() == kDefaultServerHostName. 2684 // with QuicServerId.host() == kDefaultServerHostName.
2681 SendRequestAndExpectQuicResponse("hello!"); 2685 SendRequestAndExpectQuicResponse("hello!");
2682 2686
2683 // Set up alternative service entry to a different destination. 2687 // Set up alternative service entry to a different destination.
2684 alternative_service = AlternativeService(kProtoQUIC, destination2, 443); 2688 alternative_service = AlternativeService(kProtoQUIC, destination2, 443);
2685 http_server_properties_.SetAlternativeService(server, alternative_service, 2689 http_server_properties_.SetAlternativeService(
2686 expiration); 2690 server, alternative_service, expiration,
2691 HttpNetworkSession::Params().quic_supported_versions);
2687 // Second request pools to existing connection with same QuicServerId, 2692 // Second request pools to existing connection with same QuicServerId,
2688 // even though alternative service destination is different. 2693 // even though alternative service destination is different.
2689 SendRequestAndExpectQuicResponse("hello!"); 2694 SendRequestAndExpectQuicResponse("hello!");
2690 } 2695 }
2691 2696
2692 // Pool to existing session with matching destination and matching certificate 2697 // Pool to existing session with matching destination and matching certificate
2693 // even if origin is different, and even if the alternative service with 2698 // even if origin is different, and even if the alternative service with
2694 // matching destination is not the first one on the list. 2699 // matching destination is not the first one on the list.
2695 TEST_P(QuicNetworkTransactionTest, PoolByDestination) { 2700 TEST_P(QuicNetworkTransactionTest, PoolByDestination) {
2696 GURL origin1 = request_.url; 2701 GURL origin1 = request_.url;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2740 2745
2741 CreateSession(); 2746 CreateSession();
2742 2747
2743 const char destination1[] = "first.example.com"; 2748 const char destination1[] = "first.example.com";
2744 const char destination2[] = "second.example.com"; 2749 const char destination2[] = "second.example.com";
2745 2750
2746 // Set up alternative service for |origin1|. 2751 // Set up alternative service for |origin1|.
2747 AlternativeService alternative_service1(kProtoQUIC, destination1, 443); 2752 AlternativeService alternative_service1(kProtoQUIC, destination1, 443);
2748 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 2753 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
2749 http_server_properties_.SetAlternativeService( 2754 http_server_properties_.SetAlternativeService(
2750 url::SchemeHostPort(origin1), alternative_service1, expiration); 2755 url::SchemeHostPort(origin1), alternative_service1, expiration,
2756 HttpNetworkSession::Params().quic_supported_versions);
2751 2757
2752 // Set up multiple alternative service entries for |origin2|, 2758 // Set up multiple alternative service entries for |origin2|,
2753 // the first one with a different destination as for |origin1|, 2759 // the first one with a different destination as for |origin1|,
2754 // the second one with the same. The second one should be used, 2760 // the second one with the same. The second one should be used,
2755 // because the request can be pooled to that one. 2761 // because the request can be pooled to that one.
2756 AlternativeService alternative_service2(kProtoQUIC, destination2, 443); 2762 AlternativeService alternative_service2(kProtoQUIC, destination2, 443);
2757 AlternativeServiceInfoVector alternative_services; 2763 AlternativeServiceInfoVector alternative_services;
2758 alternative_services.push_back( 2764 alternative_services.push_back(AlternativeServiceInfo(
2759 AlternativeServiceInfo(alternative_service2, expiration)); 2765 alternative_service2, expiration,
2760 alternative_services.push_back( 2766 HttpNetworkSession::Params().quic_supported_versions));
2761 AlternativeServiceInfo(alternative_service1, expiration)); 2767 alternative_services.push_back(AlternativeServiceInfo(
2768 alternative_service1, expiration,
2769 HttpNetworkSession::Params().quic_supported_versions));
2762 http_server_properties_.SetAlternativeServices(url::SchemeHostPort(origin2), 2770 http_server_properties_.SetAlternativeServices(url::SchemeHostPort(origin2),
2763 alternative_services); 2771 alternative_services);
2764 // First request opens connection to |destination1| 2772 // First request opens connection to |destination1|
2765 // with QuicServerId.host() == origin1.host(). 2773 // with QuicServerId.host() == origin1.host().
2766 SendRequestAndExpectQuicResponse("hello!"); 2774 SendRequestAndExpectQuicResponse("hello!");
2767 2775
2768 // Second request pools to existing connection with same destination, 2776 // Second request pools to existing connection with same destination,
2769 // because certificate matches, even though QuicServerId is different. 2777 // because certificate matches, even though QuicServerId is different.
2770 request_.url = origin2; 2778 request_.url = origin2;
2771 2779
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
4254 destination = HostPortPair(origin2_, 443); 4262 destination = HostPortPair(origin2_, 443);
4255 break; 4263 break;
4256 case DIFFERENT: 4264 case DIFFERENT:
4257 destination = HostPortPair(kDifferentHostname, 443); 4265 destination = HostPortPair(kDifferentHostname, 443);
4258 break; 4266 break;
4259 } 4267 }
4260 AlternativeService alternative_service(kProtoQUIC, destination); 4268 AlternativeService alternative_service(kProtoQUIC, destination);
4261 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 4269 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
4262 http_server_properties_.SetAlternativeService( 4270 http_server_properties_.SetAlternativeService(
4263 url::SchemeHostPort("https", origin, 443), alternative_service, 4271 url::SchemeHostPort("https", origin, 443), alternative_service,
4264 expiration); 4272 expiration, HttpNetworkSession::Params().quic_supported_versions);
4265 } 4273 }
4266 4274
4267 std::unique_ptr<QuicEncryptedPacket> ConstructClientRequestHeadersPacket( 4275 std::unique_ptr<QuicEncryptedPacket> ConstructClientRequestHeadersPacket(
4268 QuicPacketNumber packet_number, 4276 QuicPacketNumber packet_number,
4269 QuicStreamId stream_id, 4277 QuicStreamId stream_id,
4270 bool should_include_version, 4278 bool should_include_version,
4271 QuicStreamOffset* offset, 4279 QuicStreamOffset* offset,
4272 QuicTestPacketMaker* maker) { 4280 QuicTestPacketMaker* maker) {
4273 SpdyPriority priority = 4281 SpdyPriority priority =
4274 ConvertRequestPriorityToQuicPriority(DEFAULT_PRIORITY); 4282 ConvertRequestPriorityToQuicPriority(DEFAULT_PRIORITY);
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
4689 4697
4690 request_.url = GURL("https://mail.example.org/pushed.jpg"); 4698 request_.url = GURL("https://mail.example.org/pushed.jpg");
4691 ChunkedUploadDataStream upload_data(0); 4699 ChunkedUploadDataStream upload_data(0);
4692 upload_data.AppendData("1", 1, true); 4700 upload_data.AppendData("1", 1, true);
4693 request_.upload_data_stream = &upload_data; 4701 request_.upload_data_stream = &upload_data;
4694 SendRequestAndExpectQuicResponse("and hello!"); 4702 SendRequestAndExpectQuicResponse("and hello!");
4695 } 4703 }
4696 4704
4697 } // namespace test 4705 } // namespace test
4698 } // namespace net 4706 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698