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

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

Issue 1360253002: Log GOAWAY frame debug data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re: #12. Created 5 years, 2 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') | net/spdy/spdy_test_util_common.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 "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 NetLog::Source socket_source; 1544 NetLog::Source socket_source;
1545 EXPECT_TRUE(NetLog::Source::FromEventParameters(entry.params.get(), 1545 EXPECT_TRUE(NetLog::Source::FromEventParameters(entry.params.get(),
1546 &socket_source)); 1546 &socket_source));
1547 EXPECT_TRUE(socket_source.IsValid()); 1547 EXPECT_TRUE(socket_source.IsValid());
1548 EXPECT_NE(log_.bound().source().id, socket_source.id); 1548 EXPECT_NE(log_.bound().source().id, socket_source.id);
1549 } 1549 }
1550 1550
1551 TEST_P(SpdySessionTest, NetLogOnSessionGoaway) { 1551 TEST_P(SpdySessionTest, NetLogOnSessionGoaway) {
1552 session_deps_.host_resolver->set_synchronous_mode(true); 1552 session_deps_.host_resolver->set_synchronous_mode(true);
1553 1553
1554 scoped_ptr<SpdyFrame> goaway(spdy_util_.ConstructSpdyGoAway()); 1554 scoped_ptr<SpdyFrame> goaway(
1555 spdy_util_.ConstructSpdyGoAway(42, GOAWAY_ENHANCE_YOUR_CALM, "foo"));
1555 MockRead reads[] = { 1556 MockRead reads[] = {
1556 CreateMockRead(*goaway), 1557 CreateMockRead(*goaway),
1557 MockRead(SYNCHRONOUS, 0, 0) // EOF 1558 MockRead(SYNCHRONOUS, 0, 0) // EOF
1558 }; 1559 };
1559 1560
1560 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 1561 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0);
1561 session_deps_.socket_factory->AddSocketDataProvider(&data); 1562 session_deps_.socket_factory->AddSocketDataProvider(&data);
1562 1563
1563 CreateNetworkSession(); 1564 CreateNetworkSession();
1564 CreateInsecureSpdySession(); 1565 CreateInsecureSpdySession();
1565 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_)); 1566 EXPECT_TRUE(HasSpdySession(spdy_session_pool_, key_));
1566 1567
1567 // Flush the read completion task. 1568 // Flush the read completion task.
1568 base::RunLoop().RunUntilIdle(); 1569 base::RunLoop().RunUntilIdle();
1569 1570
1570 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); 1571 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
1571 EXPECT_FALSE(session_); 1572 EXPECT_FALSE(session_);
1572 1573
1573 // Check that the NetLog was filled reasonably. 1574 // Check that the NetLog was filled reasonably.
1574 TestNetLogEntry::List entries; 1575 TestNetLogEntry::List entries;
1575 log_.GetEntries(&entries); 1576 log_.GetEntries(&entries);
1576 EXPECT_LT(0u, entries.size()); 1577 EXPECT_LT(0u, entries.size());
1577 1578
1579 if (GetParam() == kProtoHTTP2) {
1580 int pos = ExpectLogContainsSomewhere(
1581 entries, 0, NetLog::TYPE_HTTP2_SESSION_GOAWAY, NetLog::PHASE_NONE);
1582 TestNetLogEntry entry = entries[pos];
1583 int last_accepted_stream_id;
1584 ASSERT_TRUE(entry.GetIntegerValue("last_accepted_stream_id",
1585 &last_accepted_stream_id));
1586 EXPECT_EQ(42, last_accepted_stream_id);
1587 int active_streams;
1588 ASSERT_TRUE(entry.GetIntegerValue("active_streams", &active_streams));
1589 EXPECT_EQ(0, active_streams);
1590 int unclaimed_streams;
1591 ASSERT_TRUE(entry.GetIntegerValue("unclaimed_streams", &unclaimed_streams));
1592 EXPECT_EQ(0, unclaimed_streams);
1593 int status;
1594 ASSERT_TRUE(entry.GetIntegerValue("status", &status));
1595 EXPECT_EQ(GOAWAY_ENHANCE_YOUR_CALM, status);
1596 std::string debug_data;
1597 ASSERT_TRUE(entry.GetStringValue("debug_data", &debug_data));
1598 EXPECT_EQ("foo", debug_data);
1599 }
1600
1578 // Check that we logged SPDY_SESSION_CLOSE correctly. 1601 // Check that we logged SPDY_SESSION_CLOSE correctly.
1579 int pos = ExpectLogContainsSomewhere( 1602 int pos = ExpectLogContainsSomewhere(
1580 entries, 0, NetLog::TYPE_HTTP2_SESSION_CLOSE, NetLog::PHASE_NONE); 1603 entries, 0, NetLog::TYPE_HTTP2_SESSION_CLOSE, NetLog::PHASE_NONE);
1581 1604 TestNetLogEntry entry = entries[pos];
1582 if (pos < static_cast<int>(entries.size())) { 1605 int error_code = 0;
1583 TestNetLogEntry entry = entries[pos]; 1606 ASSERT_TRUE(entry.GetNetErrorCode(&error_code));
1584 int error_code = 0; 1607 EXPECT_EQ(OK, error_code);
1585 ASSERT_TRUE(entry.GetNetErrorCode(&error_code));
1586 EXPECT_EQ(OK, error_code);
1587 } else {
1588 ADD_FAILURE();
1589 }
1590 } 1608 }
1591 1609
1592 TEST_P(SpdySessionTest, NetLogOnSessionEOF) { 1610 TEST_P(SpdySessionTest, NetLogOnSessionEOF) {
1593 session_deps_.host_resolver->set_synchronous_mode(true); 1611 session_deps_.host_resolver->set_synchronous_mode(true);
1594 1612
1595 MockRead reads[] = { 1613 MockRead reads[] = {
1596 MockRead(SYNCHRONOUS, 0, 0) // EOF 1614 MockRead(SYNCHRONOUS, 0, 0) // EOF
1597 }; 1615 };
1598 1616
1599 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 1617 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0);
(...skipping 3513 matching lines...) Expand 10 before | Expand all | Expand 10 after
5113 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), 5131 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(),
5114 "spdy_pooling.pem"); 5132 "spdy_pooling.pem");
5115 ssl_info.is_issued_by_known_root = true; 5133 ssl_info.is_issued_by_known_root = true;
5116 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); 5134 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin));
5117 5135
5118 EXPECT_TRUE(SpdySession::CanPool( 5136 EXPECT_TRUE(SpdySession::CanPool(
5119 &tss, ssl_info, "www.example.org", "mail.example.org")); 5137 &tss, ssl_info, "www.example.org", "mail.example.org"));
5120 } 5138 }
5121 5139
5122 } // namespace net 5140 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.cc ('k') | net/spdy/spdy_test_util_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698