diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-11 21:30:35 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-11 21:30:35 +0000 |
commit | a3d677d8ff537f07aba274a61e0621a3db9af074 (patch) | |
tree | 8d53d838688c11edfafd8e100742b2d87fe8a746 /net/spdy | |
parent | fb245a0e547638deabc5cb094a38ba863ff22ec7 (diff) | |
download | chromium_src-a3d677d8ff537f07aba274a61e0621a3db9af074.zip chromium_src-a3d677d8ff537f07aba274a61e0621a3db9af074.tar.gz chromium_src-a3d677d8ff537f07aba274a61e0621a3db9af074.tar.bz2 |
Revert r77399 in preparation for merging a small portion of it to 696.
Reland r77075,r77077.
They were reverted due to flaky tests, especially on valgrind. Basically, we kept hitting the backup socket timer (500ms) which would create another socket, which the tests don't expect, so they crash. I disabled the backup socket timer completely for the SPDY tests, because they make it too hard to handle the parallel alternate protocol jobs.
I also deleted the HTTP fallback test from SpdyNetworkTransactionTest, because it had a similar problem. Also, it was already being tested in HttpNetworkTransactionTest.
BUG=69688,75000
TEST=Try connecting to belshe.com with various proxy configurations. Should work still.
Review URL: http://codereview.chromium.org/6635047
TBR=willchan@chromium.org
Review URL: http://codereview.chromium.org/6681012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77864 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy')
-rw-r--r-- | net/spdy/spdy_http_stream.cc | 4 | ||||
-rw-r--r-- | net/spdy/spdy_http_stream.h | 1 | ||||
-rw-r--r-- | net/spdy/spdy_network_transaction_unittest.cc | 192 |
3 files changed, 112 insertions, 85 deletions
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc index 130a818..51a2efd 100644 --- a/net/spdy/spdy_http_stream.cc +++ b/net/spdy/spdy_http_stream.cc @@ -463,8 +463,4 @@ void SpdyHttpStream::GetSSLCertRequestInfo( stream_->GetSSLCertRequestInfo(cert_request_info); } -bool SpdyHttpStream::IsSpdyHttpStream() const { - return true; -} - } // namespace net diff --git a/net/spdy/spdy_http_stream.h b/net/spdy/spdy_http_stream.h index 4c00e0f..bdae342 100644 --- a/net/spdy/spdy_http_stream.h +++ b/net/spdy/spdy_http_stream.h @@ -65,7 +65,6 @@ class SpdyHttpStream : public SpdyStream::Delegate, public HttpStream { virtual void SetConnectionReused(); virtual void GetSSLInfo(SSLInfo* ssl_info); virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info); - virtual bool IsSpdyHttpStream() const; // SpdyStream::Delegate methods: virtual bool OnSendHeadersComplete(int status); diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index 9f4e1fe..94ef61d 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -11,7 +11,6 @@ #include "net/base/net_log_unittest.h" #include "net/http/http_network_session_peer.h" #include "net/http/http_transaction_unittest.h" -#include "net/socket/client_socket_pool_base.h" #include "net/spdy/spdy_http_stream.h" #include "net/spdy/spdy_http_utils.h" #include "net/spdy/spdy_session.h" @@ -36,25 +35,17 @@ enum SpdyNetworkTransactionTestTypes { class SpdyNetworkTransactionTest : public ::testing::TestWithParam<SpdyNetworkTransactionTestTypes> { protected: - virtual void SetUp() { // By default, all tests turn off compression. EnableCompression(false); google_get_request_initialized_ = false; google_post_request_initialized_ = false; google_chunked_post_request_initialized_ = false; - - backup_jobs_prev_value_ = - internal::ClientSocketPoolBaseHelper::connect_backup_jobs_enabled(); - internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( - false); } virtual void TearDown() { // Empty the current queue. MessageLoop::current()->RunAllPending(); - internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( - backup_jobs_prev_value_); } struct TransactionHelperResult { @@ -176,8 +167,10 @@ class SpdyNetworkTransactionTest EXPECT_EQ(spdy_enabled_, response->was_fetched_via_spdy); if (test_type_ == SPDYNPN && spdy_enabled_) { EXPECT_TRUE(response->was_npn_negotiated); + EXPECT_TRUE(response->was_alternate_protocol_available); } else { EXPECT_TRUE(!response->was_npn_negotiated); + EXPECT_TRUE(!response->was_alternate_protocol_available); } // If SPDY is not enabled, a HTTP request should not be diverted // over a SSL session. @@ -244,20 +237,9 @@ class SpdyNetworkTransactionTest ssl_->was_npn_negotiated = true; } ssl_vector_.push_back(ssl_); - if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) + if(test_type_ == SPDYNPN || test_type_ == SPDYSSL) session_deps_->socket_factory->AddSSLSocketDataProvider(ssl_.get()); session_deps_->socket_factory->AddSocketDataProvider(data); - if (test_type_ == SPDYNPN) { - MockConnect never_finishing_connect(false, ERR_IO_PENDING); - linked_ptr<StaticSocketDataProvider> - hanging_non_alternate_protocol_socket( - new StaticSocketDataProvider(NULL, 0, NULL, 0)); - hanging_non_alternate_protocol_socket->set_connect_data( - never_finishing_connect); - session_deps_->socket_factory->AddSocketDataProvider( - hanging_non_alternate_protocol_socket.get()); - alternate_vector_.push_back(hanging_non_alternate_protocol_socket); - } } void AddDeterministicData(DeterministicSocketData* data) { @@ -271,23 +253,10 @@ class SpdyNetworkTransactionTest ssl_->was_npn_negotiated = true; } ssl_vector_.push_back(ssl_); - if (test_type_ == SPDYNPN || test_type_ == SPDYSSL) { + if(test_type_ == SPDYNPN || test_type_ == SPDYSSL) session_deps_->deterministic_socket_factory-> AddSSLSocketDataProvider(ssl_.get()); - } session_deps_->deterministic_socket_factory->AddSocketDataProvider(data); - if (test_type_ == SPDYNPN) { - MockConnect never_finishing_connect(false, ERR_IO_PENDING); - scoped_refptr<DeterministicSocketData> - hanging_non_alternate_protocol_socket( - new DeterministicSocketData(NULL, 0, NULL, 0)); - hanging_non_alternate_protocol_socket->set_connect_data( - never_finishing_connect); - session_deps_->deterministic_socket_factory->AddSocketDataProvider( - hanging_non_alternate_protocol_socket); - alternate_deterministic_vector_.push_back( - hanging_non_alternate_protocol_socket); - } } // This can only be called after RunPreTestSetup. It adds a Data Provider, @@ -320,9 +289,6 @@ class SpdyNetworkTransactionTest private: typedef std::vector<StaticSocketDataProvider*> DataVector; typedef std::vector<linked_ptr<SSLSocketDataProvider> > SSLVector; - typedef std::vector<linked_ptr<StaticSocketDataProvider> > AlternateVector; - typedef std::vector<scoped_refptr<DeterministicSocketData> > - AlternateDeterministicVector; HttpRequestInfo request_; scoped_ptr<SpdySessionDependencies> session_deps_; scoped_refptr<HttpNetworkSession> session_; @@ -333,8 +299,6 @@ class SpdyNetworkTransactionTest scoped_ptr<HttpNetworkTransaction> trans_; scoped_ptr<HttpNetworkTransaction> trans_http_; DataVector data_vector_; - AlternateVector alternate_vector_; - AlternateDeterministicVector alternate_deterministic_vector_; const BoundNetLog& log_; SpdyNetworkTransactionTestTypes test_type_; int port_; @@ -511,8 +475,6 @@ class SpdyNetworkTransactionTest HttpRequestInfo google_post_request_; HttpRequestInfo google_chunked_post_request_; HttpRequestInfo google_get_push_request_; - - bool backup_jobs_prev_value_; }; //----------------------------------------------------------------------------- @@ -742,7 +704,7 @@ TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBinding) { new OrderedSocketData(reads, arraysize(reads), writes, arraysize(writes))); - MockConnect never_finishing_connect(false, ERR_IO_PENDING); + MockConnect never_finishing_connect(true, ERR_IO_PENDING); scoped_refptr<OrderedSocketData> data_placeholder( new OrderedSocketData(NULL, 0, NULL, 0)); @@ -931,12 +893,10 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrent) { settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); scoped_ptr<spdy::SpdyFrame> settings_frame(ConstructSpdySettings(settings)); - MockWrite writes[] = { - CreateMockWrite(*req), - CreateMockWrite(*req2), - CreateMockWrite(*req3), + MockWrite writes[] = { CreateMockWrite(*req), + CreateMockWrite(*req2), + CreateMockWrite(*req3), }; - MockRead reads[] = { CreateMockRead(*settings_frame, 1), CreateMockRead(*resp), @@ -961,14 +921,14 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrent) { BoundNetLog log; TransactionHelperResult out; { - NormalSpdyTransactionHelper helper(CreateGetRequest(), - BoundNetLog(), GetParam()); - helper.RunPreTestSetup(); - helper.AddData(data.get()); - // We require placeholder data because three get requests are sent out, so - // there needs to be three sets of SSL connection data. - helper.AddData(data_placeholder.get()); - helper.AddData(data_placeholder.get()); + NormalSpdyTransactionHelper helper(CreateGetRequest(), + BoundNetLog(), GetParam()); + helper.RunPreTestSetup(); + helper.AddData(data.get()); + // We require placeholder data because three get requests are sent out, so + // there needs to be three sets of SSL connection data. + helper.AddData(data_placeholder.get()); + helper.AddData(data_placeholder.get()); scoped_ptr<HttpNetworkTransaction> trans1( new HttpNetworkTransaction(helper.session())); scoped_ptr<HttpNetworkTransaction> trans2( @@ -1756,7 +1716,7 @@ TEST_P(SpdyNetworkTransactionTest, SocketWriteReturnsZero) { scoped_refptr<DeterministicSocketData> data( new DeterministicSocketData(reads, arraysize(reads), - writes, arraysize(writes))); + writes, arraysize(writes))); NormalSpdyTransactionHelper helper(CreateGetRequest(), BoundNetLog(), GetParam()); helper.SetDeterministic(); @@ -2570,6 +2530,20 @@ TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) { "version", "HTTP/1.1" }; + const char* const kStandardGetHeaders2[] = { + "host", + "www.foo.com", + "method", + "GET", + "scheme", + "http", + "url", + "/index.php", + "user-agent", + "", + "version", + "HTTP/1.1" + }; // Setup writes/reads to www.google.com scoped_ptr<spdy::SpdyFrame> req( @@ -2578,6 +2552,12 @@ TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) { arraysize(kExtraHeaders) / 2, kStandardGetHeaders, arraysize(kStandardGetHeaders) / 2)); + scoped_ptr<spdy::SpdyFrame> req2( + ConstructSpdyPacket(kSynStartHeader, + kExtraHeaders, + arraysize(kExtraHeaders) / 2, + kStandardGetHeaders2, + arraysize(kStandardGetHeaders2) / 2)); scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); scoped_ptr<spdy::SpdyFrame> rep( ConstructSpdyPush(NULL, @@ -2588,40 +2568,18 @@ TEST_P(SpdyNetworkTransactionTest, RedirectServerPush) { "301 Moved Permanently", "http://www.foo.com/index.php")); scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); - scoped_ptr<spdy::SpdyFrame> rst(ConstructSpdyRstStream(2, spdy::CANCEL)); MockWrite writes[] = { CreateMockWrite(*req, 1), - CreateMockWrite(*rst, 6), }; MockRead reads[] = { CreateMockRead(*resp, 2), CreateMockRead(*rep, 3), CreateMockRead(*body, 4), MockRead(true, ERR_IO_PENDING, 5), // Force a pause - MockRead(true, 0, 0, 7) // EOF + MockRead(true, 0, 0, 6) // EOF }; // Setup writes/reads to www.foo.com - const char* const kStandardGetHeaders2[] = { - "host", - "www.foo.com", - "method", - "GET", - "scheme", - "http", - "url", - "/index.php", - "user-agent", - "", - "version", - "HTTP/1.1" - }; - scoped_ptr<spdy::SpdyFrame> req2( - ConstructSpdyPacket(kSynStartHeader, - kExtraHeaders, - arraysize(kExtraHeaders) / 2, - kStandardGetHeaders2, - arraysize(kStandardGetHeaders2) / 2)); scoped_ptr<spdy::SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 1)); scoped_ptr<spdy::SpdyFrame> body2(ConstructSpdyBodyFrame(1, true)); MockWrite writes2[] = { @@ -3847,6 +3805,80 @@ TEST_P(SpdyNetworkTransactionTest, BufferFull) { EXPECT_EQ("goodbye world", out.response_data); } +TEST_P(SpdyNetworkTransactionTest, ConnectFailureFallbackToHttp) { + MockConnect connects[] = { + MockConnect(true, ERR_NAME_NOT_RESOLVED), + MockConnect(false, ERR_NAME_NOT_RESOLVED), + MockConnect(true, ERR_INTERNET_DISCONNECTED), + MockConnect(false, ERR_INTERNET_DISCONNECTED) + }; + + for (size_t index = 0; index < arraysize(connects); ++index) { + scoped_ptr<spdy::SpdyFrame> req( + ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); + MockWrite writes[] = { + CreateMockWrite(*req), + MockWrite(true, 0, 0) // EOF + }; + + scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); + scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); + MockRead reads[] = { + CreateMockRead(*resp), + CreateMockRead(*body), + MockRead(true, 0, 0) // EOF + }; + + scoped_refptr<DelayedSocketData> data( + new DelayedSocketData(connects[index], 1, reads, arraysize(reads), + writes, arraysize(writes))); + NormalSpdyTransactionHelper helper(CreateGetRequest(), + BoundNetLog(), GetParam()); + helper.RunPreTestSetup(); + helper.AddData(data.get()); + + // Set up http fallback data. + MockRead http_fallback_data[] = { + MockRead("HTTP/1.1 200 OK\r\n\r\n"), + MockRead("hello world!!!"), + MockRead(true, OK), + }; + + scoped_ptr<StaticSocketDataProvider> http_fallback( + new StaticSocketDataProvider(http_fallback_data, + arraysize(http_fallback_data), + NULL, 0)); + helper.AddDataNoSSL(http_fallback.get()); + HttpNetworkTransaction* trans = helper.trans(); + TestCompletionCallback callback; + + int rv = trans->Start(&helper.request(), &callback, BoundNetLog()); + EXPECT_EQ(rv, ERR_IO_PENDING); + rv = callback.WaitForResult(); + const HttpResponseInfo* response = trans->GetResponseInfo(); + if (GetParam() == SPDYNOSSL || GetParam() == SPDYSSL) { + ASSERT_TRUE(response == NULL); + return; + } + if (GetParam() != SPDYNPN) + NOTREACHED(); + ASSERT_TRUE(response != NULL); + ASSERT_TRUE(response->headers != NULL); + EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); + std::string response_data; + rv = ReadTransaction(trans, &response_data); + EXPECT_EQ(OK, rv); + + EXPECT_TRUE(!response->was_fetched_via_spdy); + EXPECT_TRUE(!response->was_npn_negotiated); + EXPECT_TRUE(response->was_alternate_protocol_available); + EXPECT_TRUE(http_fallback->at_read_eof()); + EXPECT_EQ(0u, data->read_index()); + EXPECT_EQ(0u, data->write_index()); + EXPECT_EQ("hello world!!!", response_data); + } +} + // Verify that basic buffering works; when multiple data frames arrive // at the same time, ensure that we don't notify a read completion for // each data frame individually. |