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

Side by Side Diff: net/spdy/spdy_session_unittest.cc

Issue 1866983006: SHP 2: Change SpdySettingsMap to use SchemeHostPort as the key. No change to Pref data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SHP_1
Patch Set: git sync Created 4 years, 8 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/spdy/spdy_session.cc ('k') | no next file » | 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 "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 SpdySessionTest() 129 SpdySessionTest()
130 : old_max_group_sockets_(ClientSocketPoolManager::max_sockets_per_group( 130 : old_max_group_sockets_(ClientSocketPoolManager::max_sockets_per_group(
131 HttpNetworkSession::NORMAL_SOCKET_POOL)), 131 HttpNetworkSession::NORMAL_SOCKET_POOL)),
132 old_max_pool_sockets_(ClientSocketPoolManager::max_sockets_per_pool( 132 old_max_pool_sockets_(ClientSocketPoolManager::max_sockets_per_pool(
133 HttpNetworkSession::NORMAL_SOCKET_POOL)), 133 HttpNetworkSession::NORMAL_SOCKET_POOL)),
134 spdy_util_(GetProtocol(), GetDependenciesFromPriority()), 134 spdy_util_(GetProtocol(), GetDependenciesFromPriority()),
135 session_deps_(GetProtocol()), 135 session_deps_(GetProtocol()),
136 spdy_session_pool_(nullptr), 136 spdy_session_pool_(nullptr),
137 test_url_(kDefaultURL), 137 test_url_(kDefaultURL),
138 test_host_port_pair_(HostPortPair::FromURL(test_url_)), 138 test_server_(test_url_),
139 key_(test_host_port_pair_, 139 key_(HostPortPair::FromURL(test_url_),
140 ProxyServer::Direct(), 140 ProxyServer::Direct(),
141 PRIVACY_MODE_DISABLED) { 141 PRIVACY_MODE_DISABLED) {
142 session_deps_.enable_priority_dependencies = GetDependenciesFromPriority(); 142 session_deps_.enable_priority_dependencies = GetDependenciesFromPriority();
143 } 143 }
144 144
145 virtual ~SpdySessionTest() { 145 virtual ~SpdySessionTest() {
146 // Important to restore the per-pool limit first, since the pool limit must 146 // Important to restore the per-pool limit first, since the pool limit must
147 // always be greater than group limit, and the tests reduce both limits. 147 // always be greater than group limit, and the tests reduce both limits.
148 ClientSocketPoolManager::set_max_sockets_per_pool( 148 ClientSocketPoolManager::set_max_sockets_per_pool(
149 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_pool_sockets_); 149 HttpNetworkSession::NORMAL_SOCKET_POOL, old_max_pool_sockets_);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // them once each test has been run. 203 // them once each test has been run.
204 int old_max_group_sockets_; 204 int old_max_group_sockets_;
205 int old_max_pool_sockets_; 205 int old_max_pool_sockets_;
206 206
207 SpdyTestUtil spdy_util_; 207 SpdyTestUtil spdy_util_;
208 SpdySessionDependencies session_deps_; 208 SpdySessionDependencies session_deps_;
209 std::unique_ptr<HttpNetworkSession> http_session_; 209 std::unique_ptr<HttpNetworkSession> http_session_;
210 base::WeakPtr<SpdySession> session_; 210 base::WeakPtr<SpdySession> session_;
211 SpdySessionPool* spdy_session_pool_; 211 SpdySessionPool* spdy_session_pool_;
212 GURL test_url_; 212 GURL test_url_;
213 HostPortPair test_host_port_pair_; 213 url::SchemeHostPort test_server_;
214 SpdySessionKey key_; 214 SpdySessionKey key_;
215 BoundTestNetLog log_; 215 BoundTestNetLog log_;
216 }; 216 };
217 217
218 INSTANTIATE_TEST_CASE_P(ProtoPlusDepend, 218 INSTANTIATE_TEST_CASE_P(ProtoPlusDepend,
219 SpdySessionTest, 219 SpdySessionTest,
220 testing::Values(kTestCaseSPDY31, 220 testing::Values(kTestCaseSPDY31,
221 kTestCaseHTTP2NoPriorityDependencies, 221 kTestCaseHTTP2NoPriorityDependencies,
222 kTestCaseHTTP2PriorityDependencies)); 222 kTestCaseHTTP2PriorityDependencies));
223 223
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 MockRead(ASYNC, 0, 2), 1539 MockRead(ASYNC, 0, 2),
1540 }; 1540 };
1541 1541
1542 SequencedSocketData data(reads, arraysize(reads), nullptr, 0); 1542 SequencedSocketData data(reads, arraysize(reads), nullptr, 0);
1543 session_deps_.socket_factory->AddSocketDataProvider(&data); 1543 session_deps_.socket_factory->AddSocketDataProvider(&data);
1544 1544
1545 CreateNetworkSession(); 1545 CreateNetworkSession();
1546 1546
1547 // Initialize the SpdySetting with the default. 1547 // Initialize the SpdySetting with the default.
1548 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1548 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1549 test_host_port_pair_, 1549 test_server_,
1550 SETTINGS_MAX_CONCURRENT_STREAMS, 1550 SETTINGS_MAX_CONCURRENT_STREAMS,
1551 SETTINGS_FLAG_PLEASE_PERSIST, 1551 SETTINGS_FLAG_PLEASE_PERSIST,
1552 kInitialMaxConcurrentStreams); 1552 kInitialMaxConcurrentStreams);
1553 1553
1554 EXPECT_FALSE( 1554 EXPECT_FALSE(
1555 spdy_session_pool_->http_server_properties()->GetSpdySettings( 1555 spdy_session_pool_->http_server_properties()->GetSpdySettings(
1556 test_host_port_pair_).empty()); 1556 test_server_).empty());
1557 1557
1558 CreateInsecureSpdySession(); 1558 CreateInsecureSpdySession();
1559 1559
1560 // Create the maximum number of concurrent streams. 1560 // Create the maximum number of concurrent streams.
1561 for (size_t i = 0; i < kInitialMaxConcurrentStreams; ++i) { 1561 for (size_t i = 0; i < kInitialMaxConcurrentStreams; ++i) {
1562 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously( 1562 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously(
1563 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog()); 1563 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog());
1564 ASSERT_TRUE(spdy_stream != nullptr); 1564 ASSERT_TRUE(spdy_stream != nullptr);
1565 } 1565 }
1566 1566
1567 StreamReleaserCallback stream_releaser; 1567 StreamReleaserCallback stream_releaser;
1568 1568
1569 SpdyStreamRequest request; 1569 SpdyStreamRequest request;
1570 ASSERT_EQ(ERR_IO_PENDING, 1570 ASSERT_EQ(ERR_IO_PENDING,
1571 request.StartRequest(SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, 1571 request.StartRequest(SPDY_BIDIRECTIONAL_STREAM, session_, test_url_,
1572 MEDIUM, BoundNetLog(), 1572 MEDIUM, BoundNetLog(),
1573 stream_releaser.MakeCallback(&request))); 1573 stream_releaser.MakeCallback(&request)));
1574 1574
1575 base::RunLoop().RunUntilIdle(); 1575 base::RunLoop().RunUntilIdle();
1576 1576
1577 EXPECT_EQ(OK, stream_releaser.WaitForResult()); 1577 EXPECT_EQ(OK, stream_releaser.WaitForResult());
1578 1578
1579 // Make sure that persisted data is cleared. 1579 // Make sure that persisted data is cleared.
1580 EXPECT_TRUE( 1580 EXPECT_TRUE(
1581 spdy_session_pool_->http_server_properties()->GetSpdySettings( 1581 spdy_session_pool_->http_server_properties()->GetSpdySettings(
1582 test_host_port_pair_).empty()); 1582 test_server_).empty());
1583 1583
1584 // Make sure session's max_concurrent_streams is correct. 1584 // Make sure session's max_concurrent_streams is correct.
1585 EXPECT_EQ(kInitialMaxConcurrentStreams + 1, 1585 EXPECT_EQ(kInitialMaxConcurrentStreams + 1,
1586 session_->max_concurrent_streams_); 1586 session_->max_concurrent_streams_);
1587 1587
1588 data.Resume(); 1588 data.Resume();
1589 base::RunLoop().RunUntilIdle(); 1589 base::RunLoop().RunUntilIdle();
1590 EXPECT_FALSE(session_); 1590 EXPECT_FALSE(session_);
1591 } 1591 }
1592 1592
1593 // Start with max concurrent streams set to 1. Request two streams. 1593 // Start with max concurrent streams set to 1. Request two streams.
1594 // When the first completes, have the callback close its stream, which 1594 // When the first completes, have the callback close its stream, which
1595 // should trigger the second stream creation. Then cancel that one 1595 // should trigger the second stream creation. Then cancel that one
1596 // immediately. Don't crash. This is a regression test for 1596 // immediately. Don't crash. This is a regression test for
1597 // http://crbug.com/63532 . 1597 // http://crbug.com/63532 .
1598 TEST_P(SpdySessionTest, CancelPendingCreateStream) { 1598 TEST_P(SpdySessionTest, CancelPendingCreateStream) {
1599 session_deps_.host_resolver->set_synchronous_mode(true); 1599 session_deps_.host_resolver->set_synchronous_mode(true);
1600 1600
1601 MockRead reads[] = { 1601 MockRead reads[] = {
1602 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. 1602 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever.
1603 }; 1603 };
1604 1604
1605 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 1605 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0);
1606 session_deps_.socket_factory->AddSocketDataProvider(&data); 1606 session_deps_.socket_factory->AddSocketDataProvider(&data);
1607 1607
1608 CreateNetworkSession(); 1608 CreateNetworkSession();
1609 1609
1610 // Initialize the SpdySetting with 1 max concurrent streams. 1610 // Initialize the SpdySetting with 1 max concurrent streams.
1611 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1611 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1612 test_host_port_pair_, 1612 test_server_,
1613 SETTINGS_MAX_CONCURRENT_STREAMS, 1613 SETTINGS_MAX_CONCURRENT_STREAMS,
1614 SETTINGS_FLAG_PLEASE_PERSIST, 1614 SETTINGS_FLAG_PLEASE_PERSIST,
1615 1); 1615 1);
1616 1616
1617 CreateInsecureSpdySession(); 1617 CreateInsecureSpdySession();
1618 1618
1619 // Leave room for only one more stream to be created. 1619 // Leave room for only one more stream to be created.
1620 for (size_t i = 0; i < kInitialMaxConcurrentStreams - 1; ++i) { 1620 for (size_t i = 0; i < kInitialMaxConcurrentStreams - 1; ++i) {
1621 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously( 1621 base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously(
1622 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog()); 1622 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, MEDIUM, BoundNetLog());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 writes.push_back(CreateMockWrite(*server_settings_frame)); 1680 writes.push_back(CreateMockWrite(*server_settings_frame));
1681 } 1681 }
1682 1682
1683 StaticSocketDataProvider data(reads, arraysize(reads), writes.data(), 1683 StaticSocketDataProvider data(reads, arraysize(reads), writes.data(),
1684 writes.size()); 1684 writes.size());
1685 session_deps_.socket_factory->AddSocketDataProvider(&data); 1685 session_deps_.socket_factory->AddSocketDataProvider(&data);
1686 1686
1687 CreateNetworkSession(); 1687 CreateNetworkSession();
1688 1688
1689 spdy_session_pool_->http_server_properties()->SetSpdySetting( 1689 spdy_session_pool_->http_server_properties()->SetSpdySetting(
1690 test_host_port_pair_, 1690 test_server_,
1691 SETTINGS_MAX_CONCURRENT_STREAMS, 1691 SETTINGS_MAX_CONCURRENT_STREAMS,
1692 SETTINGS_FLAG_PLEASE_PERSIST, 1692 SETTINGS_FLAG_PLEASE_PERSIST,
1693 initial_max_concurrent_streams); 1693 initial_max_concurrent_streams);
1694 1694
1695 SpdySessionPoolPeer pool_peer(spdy_session_pool_); 1695 SpdySessionPoolPeer pool_peer(spdy_session_pool_);
1696 pool_peer.SetEnableSendingInitialData(true); 1696 pool_peer.SetEnableSendingInitialData(true);
1697 1697
1698 CreateInsecureSpdySession(); 1698 CreateInsecureSpdySession();
1699 1699
1700 base::RunLoop().RunUntilIdle(); 1700 base::RunLoop().RunUntilIdle();
1701 EXPECT_TRUE(data.AllWriteDataConsumed()); 1701 EXPECT_TRUE(data.AllWriteDataConsumed());
1702 } 1702 }
1703 1703
1704 TEST_P(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) { 1704 TEST_P(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) {
1705 CreateNetworkSession(); 1705 CreateNetworkSession();
1706 1706
1707 base::WeakPtr<HttpServerProperties> test_http_server_properties = 1707 base::WeakPtr<HttpServerProperties> test_http_server_properties =
1708 spdy_session_pool_->http_server_properties(); 1708 spdy_session_pool_->http_server_properties();
1709 SettingsFlagsAndValue flags_and_value1(SETTINGS_FLAG_PLEASE_PERSIST, 2); 1709 SettingsFlagsAndValue flags_and_value1(SETTINGS_FLAG_PLEASE_PERSIST, 2);
1710 test_http_server_properties->SetSpdySetting( 1710 test_http_server_properties->SetSpdySetting(
1711 test_host_port_pair_, 1711 test_server_,
1712 SETTINGS_MAX_CONCURRENT_STREAMS, 1712 SETTINGS_MAX_CONCURRENT_STREAMS,
1713 SETTINGS_FLAG_PLEASE_PERSIST, 1713 SETTINGS_FLAG_PLEASE_PERSIST,
1714 2); 1714 2);
1715 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings( 1715 EXPECT_NE(0u, test_http_server_properties->GetSpdySettings(
1716 test_host_port_pair_).size()); 1716 test_server_).size());
1717 spdy_session_pool_->OnIPAddressChanged(); 1717 spdy_session_pool_->OnIPAddressChanged();
1718 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( 1718 EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings(
1719 test_host_port_pair_).size()); 1719 test_server_).size());
1720 } 1720 }
1721 1721
1722 TEST_P(SpdySessionTest, Initialize) { 1722 TEST_P(SpdySessionTest, Initialize) {
1723 session_deps_.host_resolver->set_synchronous_mode(true); 1723 session_deps_.host_resolver->set_synchronous_mode(true);
1724 1724
1725 MockRead reads[] = { 1725 MockRead reads[] = {
1726 MockRead(ASYNC, 0, 0) // EOF 1726 MockRead(ASYNC, 0, 0) // EOF
1727 }; 1727 };
1728 1728
1729 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 1729 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0);
(...skipping 3748 matching lines...) Expand 10 before | Expand all | Expand 10 after
5478 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), 5478 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(),
5479 "spdy_pooling.pem"); 5479 "spdy_pooling.pem");
5480 ssl_info.is_issued_by_known_root = true; 5480 ssl_info.is_issued_by_known_root = true;
5481 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); 5481 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin));
5482 5482
5483 EXPECT_TRUE(SpdySession::CanPool( 5483 EXPECT_TRUE(SpdySession::CanPool(
5484 &tss, ssl_info, "www.example.org", "mail.example.org")); 5484 &tss, ssl_info, "www.example.org", "mail.example.org"));
5485 } 5485 }
5486 5486
5487 } // namespace net 5487 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698