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

Unified Diff: net/url_request/url_request_quic_unittest.cc

Issue 2751623002: Revert of Server push cancellation: add a finch trial parameter (patchset #14 id:280001 of https://… (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/test_tools/mock_quic_session_visitor.h ('k') | net/url_request/url_request_test_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_quic_unittest.cc
diff --git a/net/url_request/url_request_quic_unittest.cc b/net/url_request/url_request_quic_unittest.cc
index f435d61cdf19d8a52a3461fe1de2828859dc3901..7532196988f52ad3238b3bdcf438f345d128083f 100644
--- a/net/url_request/url_request_quic_unittest.cc
+++ b/net/url_request/url_request_quic_unittest.cc
@@ -15,17 +15,12 @@
#include "net/cert/mock_cert_verifier.h"
#include "net/dns/mapped_host_resolver.h"
#include "net/dns/mock_host_resolver.h"
-#include "net/log/net_log_event_type.h"
-#include "net/log/test_net_log.h"
-#include "net/log/test_net_log_entry.h"
#include "net/quic/chromium/crypto/proof_source_chromium.h"
#include "net/quic/test_tools/crypto_test_utils.h"
#include "net/test/cert_test_util.h"
#include "net/test/gtest_util.h"
#include "net/test/test_data_directory.h"
-#include "net/tools/quic/quic_dispatcher.h"
#include "net/tools/quic/quic_http_response_cache.h"
-#include "net/tools/quic/quic_simple_dispatcher.h"
#include "net/tools/quic/quic_simple_server.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_test_util.h"
@@ -69,11 +64,9 @@ class URLRequestQuicTest : public ::testing::Test {
params->origins_to_force_quic_on.insert(HostPortPair(kTestServerHost, 443));
params->cert_verifier = &cert_verifier_;
params->enable_quic = true;
- params->enable_server_push_cancellation = true;
context_->set_host_resolver(host_resolver_.get());
context_->set_http_network_session_params(std::move(params));
context_->set_cert_verifier(&cert_verifier_);
- context_->set_net_log(&net_log_);
}
void TearDown() override {
@@ -95,29 +88,11 @@ class URLRequestQuicTest : public ::testing::Test {
return context_->CreateRequest(url, priority, delegate);
}
- void ExtractNetLog(NetLogEventType type,
- TestNetLogEntry::List* entry_list) const {
- net::TestNetLogEntry::List entries;
- net_log_.GetEntries(&entries);
-
- for (const auto& entry : entries) {
- if (entry.type == type)
- entry_list->push_back(entry);
- }
- }
-
- unsigned int GetRstErrorCountReceivedByServer(
- QuicRstStreamErrorCode error_code) const {
- return (static_cast<QuicSimpleDispatcher*>(server_->dispatcher()))
- ->GetRstErrorCount(error_code);
- }
-
private:
void StartQuicServer() {
// Set up in-memory cache.
response_cache_.AddSimpleResponse(kTestServerHost, kHelloPath, kHelloStatus,
kHelloBodyValue);
- response_cache_.InitializeFromDirectory(ServerPushCacheDirectory());
net::QuicConfig config;
// Set up server certs.
std::unique_ptr<net::ProofSourceChromium> proof_source(
@@ -145,19 +120,9 @@ class URLRequestQuicTest : public ::testing::Test {
EXPECT_TRUE(host_resolver_->AddRuleFromString(map_rule));
}
- std::string ServerPushCacheDirectory() {
- base::FilePath path;
- PathService::Get(base::DIR_SOURCE_ROOT, &path);
- path = path.AppendASCII("net").AppendASCII("data").AppendASCII(
- "quic_http_response_cache_data_with_push");
- // The file path is known to be an ascii string.
- return path.MaybeAsASCII();
- }
-
std::unique_ptr<MappedHostResolver> host_resolver_;
std::unique_ptr<QuicSimpleServer> server_;
std::unique_ptr<TestURLRequestContext> context_;
- TestNetLog net_log_;
QuicHttpResponseCache response_cache_;
MockCertVerifier cert_verifier_;
};
@@ -246,201 +211,6 @@ TEST_F(URLRequestQuicTest, TestGetRequest) {
EXPECT_EQ(kHelloBodyValue, delegate.data_received());
}
-TEST_F(URLRequestQuicTest, CancelPushIfCached) {
- base::RunLoop run_loop;
- WaitForCompletionNetworkDelegate network_delegate(
- run_loop.QuitClosure(), /*num_expected_requests=*/2);
- SetNetworkDelegate(&network_delegate);
-
- Init();
- {
- // Send a request to the pushed url: /kitten-1.jpg to pull the resource into
- // cache.
- CheckLoadTimingDelegate delegate(false);
- std::string url =
- base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg");
- std::unique_ptr<URLRequest> request =
- CreateRequest(GURL(url), DEFAULT_PRIORITY, &delegate);
-
- request->Start();
- ASSERT_TRUE(request->is_pending());
- base::RunLoop().Run();
-
- EXPECT_TRUE(request->status().is_success());
- }
-
- // Send a request to /index2.html which pushes /kitten-1.jpg and /favicon.ico.
- // Should cancel push for /kitten-1.jpg.
- CheckLoadTimingDelegate delegate(true);
- std::string url =
- base::StringPrintf("https://%s%s", kTestServerHost, "/index2.html");
- std::unique_ptr<URLRequest> request =
- CreateRequest(GURL(url), DEFAULT_PRIORITY, &delegate);
-
- request->Start();
- ASSERT_TRUE(request->is_pending());
- base::RunLoop().Run();
-
- // Extract net logs on client side to verify push lookup transactions.
- net::TestNetLogEntry::List entries;
- ExtractNetLog(NetLogEventType::SERVER_PUSH_LOOKUP_TRANSACTION, &entries);
-
- EXPECT_EQ(4u, entries.size());
-
- std::string value;
- int net_error;
- std::string push_url_1 =
- base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg");
- std::string push_url_2 =
- base::StringPrintf("https://%s%s", kTestServerHost, "/favicon.ico");
-
- EXPECT_TRUE(entries[0].GetStringValue("push_url", &value));
- EXPECT_EQ(value, push_url_1);
- // No net error code for this lookup transaction, the push is found.
- EXPECT_FALSE(entries[1].GetIntegerValue("net_error", &net_error));
-
- EXPECT_TRUE(entries[2].GetStringValue("push_url", &value));
- EXPECT_EQ(value, push_url_2);
- // Net error code -400 is found for this lookup transaction, the push is not
- // found in the cache.
- EXPECT_TRUE(entries[3].GetIntegerValue("net_error", &net_error));
- EXPECT_EQ(net_error, -400);
-
- EXPECT_TRUE(request->status().is_success());
-
- // Verify the reset error count received on the server side.
- EXPECT_EQ(1u, GetRstErrorCountReceivedByServer(QUIC_STREAM_CANCELLED));
-}
-
-TEST_F(URLRequestQuicTest, CancelPushIfCached2) {
- base::RunLoop run_loop;
- WaitForCompletionNetworkDelegate network_delegate(
- run_loop.QuitClosure(), /*num_expected_requests=*/3);
- SetNetworkDelegate(&network_delegate);
-
- Init();
- {
- // Send a request to the pushed url: /kitten-1.jpg to pull the resource into
- // cache.
- CheckLoadTimingDelegate delegate(false);
- std::string url =
- base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg");
- std::unique_ptr<URLRequest> request =
- CreateRequest(GURL(url), DEFAULT_PRIORITY, &delegate);
-
- request->Start();
- ASSERT_TRUE(request->is_pending());
- base::RunLoop().Run();
-
- EXPECT_TRUE(request->status().is_success());
- EXPECT_NE(network_delegate.total_network_bytes_sent(), 0u);
- }
-
- {
- // Send a request to the pushed url: /favicon.ico to pull the resource into
- // cache.
- CheckLoadTimingDelegate delegate(true);
- std::string url =
- base::StringPrintf("https://%s%s", kTestServerHost, "/favicon.ico");
- std::unique_ptr<URLRequest> request =
- CreateRequest(GURL(url), DEFAULT_PRIORITY, &delegate);
-
- request->Start();
- ASSERT_TRUE(request->is_pending());
- base::RunLoop().Run();
-
- EXPECT_TRUE(request->status().is_success());
- }
-
- // Send a request to /index2.html which pushes /kitten-1.jpg and /favicon.ico.
- // Should cancel push for /kitten-1.jpg.
- CheckLoadTimingDelegate delegate(true);
- std::string url =
- base::StringPrintf("https://%s%s", kTestServerHost, "/index2.html");
- std::unique_ptr<URLRequest> request =
- CreateRequest(GURL(url), DEFAULT_PRIORITY, &delegate);
-
- request->Start();
- ASSERT_TRUE(request->is_pending());
- base::RunLoop().Run();
-
- // Extract net logs on client side to verify push lookup transactions.
- net::TestNetLogEntry::List entries;
- ExtractNetLog(NetLogEventType::SERVER_PUSH_LOOKUP_TRANSACTION, &entries);
-
- EXPECT_EQ(4u, entries.size());
-
- std::string value;
- int net_error;
- std::string push_url_1 =
- base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg");
- std::string push_url_2 =
- base::StringPrintf("https://%s%s", kTestServerHost, "/favicon.ico");
-
- EXPECT_TRUE(entries[0].GetStringValue("push_url", &value));
- EXPECT_EQ(value, push_url_1);
- // No net error code for this lookup transaction, the push is found.
- EXPECT_FALSE(entries[1].GetIntegerValue("net_error", &net_error));
-
- EXPECT_TRUE(entries[2].GetStringValue("push_url", &value));
- EXPECT_EQ(value, push_url_2);
- // No net error code for this lookup transaction, the push is found.
- EXPECT_FALSE(entries[3].GetIntegerValue("net_error", &net_error));
-
- EXPECT_TRUE(request->status().is_success());
-
- // Verify the reset error count received on the server side.
- EXPECT_EQ(2u, GetRstErrorCountReceivedByServer(QUIC_STREAM_CANCELLED));
-}
-
-TEST_F(URLRequestQuicTest, DoNotCancelPushIfNotFoundInCache) {
- base::RunLoop run_loop;
- WaitForCompletionNetworkDelegate network_delegate(
- run_loop.QuitClosure(), /*num_expected_requests=*/1);
- SetNetworkDelegate(&network_delegate);
-
- Init();
- // Send a request to /index2.hmtl which pushes /kitten-1.jpg and /favicon.ico
- // and shouldn't cancel any since neither is in cache.
- CheckLoadTimingDelegate delegate(false);
- std::string url =
- base::StringPrintf("https://%s%s", kTestServerHost, "/index2.html");
- std::unique_ptr<URLRequest> request =
- CreateRequest(GURL(url), DEFAULT_PRIORITY, &delegate);
-
- request->Start();
- ASSERT_TRUE(request->is_pending());
- base::RunLoop().Run();
-
- // Extract net logs on client side to verify push lookup transactions.
- net::TestNetLogEntry::List entries;
- ExtractNetLog(NetLogEventType::SERVER_PUSH_LOOKUP_TRANSACTION, &entries);
-
- EXPECT_EQ(4u, entries.size());
-
- std::string value;
- int net_error;
- std::string push_url_1 =
- base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg");
- std::string push_url_2 =
- base::StringPrintf("https://%s%s", kTestServerHost, "/favicon.ico");
-
- EXPECT_TRUE(entries[0].GetStringValue("push_url", &value));
- EXPECT_EQ(value, push_url_1);
- EXPECT_TRUE(entries[1].GetIntegerValue("net_error", &net_error));
- EXPECT_EQ(net_error, -400);
-
- EXPECT_TRUE(entries[2].GetStringValue("push_url", &value));
- EXPECT_EQ(value, push_url_2);
- EXPECT_TRUE(entries[3].GetIntegerValue("net_error", &net_error));
- EXPECT_EQ(net_error, -400);
-
- EXPECT_TRUE(request->status().is_success());
-
- // Verify the reset error count received on the server side.
- EXPECT_EQ(0u, GetRstErrorCountReceivedByServer(QUIC_STREAM_CANCELLED));
-}
-
// Tests that if two requests use the same QUIC session, the second request
// should not have |LoadTimingInfo::connect_timing|.
TEST_F(URLRequestQuicTest, TestTwoRequests) {
« no previous file with comments | « net/tools/quic/test_tools/mock_quic_session_visitor.h ('k') | net/url_request/url_request_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698