Commit e1d19cbf authored by rch's avatar rch Committed by Commit bot

Move the chromium specific QUIC end-to-end tests from net/quic/core

to net/quic/chromium and make them cross-platform.

BUG=641709

Review-Url: https://codereview.chromium.org/2295473002
Cr-Commit-Position: refs/heads/master@{#415449}
parent a17c267c
......@@ -53,8 +53,10 @@ void StartOnServerThread(const base::FilePath& test_files_root,
directory.Append("quic_test.example.com.crt"),
directory.Append("quic_test.example.com.key.pkcs8"),
directory.Append("quic_test.example.com.key.sct")));
g_quic_server = new net::QuicSimpleServer(std::move(proof_source), config,
net::AllSupportedVersions());
g_quic_server =
new net::QuicSimpleServer(std::move(proof_source), config,
net::QuicCryptoServerConfig::ConfigOptions(),
net::AllSupportedVersions());
// Start listening.
int rv = g_quic_server->Listen(
......
......@@ -76,8 +76,10 @@ void StartQuicServerOnServerThread(const base::FilePath& test_files_root,
directory.Append("quic_test.example.com.crt"),
directory.Append("quic_test.example.com.key.pkcs8"),
directory.Append("quic_test.example.com.key.sct")));
g_quic_server = new net::QuicSimpleServer(std::move(proof_source), config,
net::AllSupportedVersions());
g_quic_server =
new net::QuicSimpleServer(std::move(proof_source), config,
net::QuicCryptoServerConfig::ConfigOptions(),
net::AllSupportedVersions());
// Start listening.
int rv = g_quic_server->Listen(
......
......@@ -1608,6 +1608,7 @@
'quic/chromium/quic_chromium_client_session_test.cc',
'quic/chromium/quic_chromium_client_stream_test.cc',
'quic/chromium/quic_chromium_connection_helper_test.cc',
'quic/chromium/quic_end_to_end_unittest.cc',
'quic/chromium/quic_http_stream_test.cc',
'quic/chromium/quic_network_transaction_unittest.cc',
'quic/chromium/quic_stream_factory_test.cc',
......@@ -1862,6 +1863,8 @@
'tools/quic/quic_simple_client_test.cc',
'tools/quic/test_tools/mock_quic_server_session_visitor.cc',
'tools/quic/test_tools/mock_quic_server_session_visitor.h',
'tools/quic/test_tools/quic_in_memory_cache_peer.cc',
'tools/quic/test_tools/quic_in_memory_cache_peer.h',
'tools/tld_cleanup/tld_cleanup_util_unittest.cc',
'udp/udp_socket_unittest.cc',
'url_request/report_sender_unittest.cc',
......@@ -1886,7 +1889,6 @@
'url_request/view_cache_helper_unittest.cc',
],
'net_linux_test_sources': [
'quic/core/quic_end_to_end_unittest.cc',
'tools/quic/chlo_extractor_test.cc',
'tools/quic/end_to_end_test.cc',
'tools/quic/quic_client_session_test.cc',
......@@ -1921,8 +1923,6 @@
'tools/quic/test_tools/quic_client_peer.h',
'tools/quic/test_tools/quic_dispatcher_peer.cc',
'tools/quic/test_tools/quic_dispatcher_peer.h',
'tools/quic/test_tools/quic_in_memory_cache_peer.cc',
'tools/quic/test_tools/quic_in_memory_cache_peer.h',
'tools/quic/test_tools/quic_server_peer.cc',
'tools/quic/test_tools/quic_server_peer.h',
'tools/quic/test_tools/quic_test_client.cc',
......
......@@ -37,9 +37,8 @@
#include "net/test/gtest_util.h"
#include "net/test/test_data_directory.h"
#include "net/tools/quic/quic_in_memory_cache.h"
#include "net/tools/quic/quic_server.h"
#include "net/tools/quic/quic_simple_server.h"
#include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h"
#include "net/tools/quic/test_tools/server_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
......@@ -50,7 +49,6 @@ namespace net {
using test::IsOk;
using test::QuicInMemoryCachePeer;
using test::ServerThread;
namespace test {
......@@ -161,7 +159,7 @@ class QuicEndToEndTest : public ::testing::TestWithParam<TestParams> {
// Use a mapped host resolver so that request for test.example.com (port 80)
// reach the server running on localhost.
std::string map_rule = "MAP test.example.com test.example.com:" +
base::IntToString(server_thread_->GetPort());
base::IntToString(server_->server_address().port());
EXPECT_TRUE(host_resolver_.AddRuleFromString(map_rule));
// To simplify the test, and avoid the race with the HTTP request, we force
......@@ -172,10 +170,7 @@ class QuicEndToEndTest : public ::testing::TestWithParam<TestParams> {
transaction_factory_.reset(new TestTransactionFactory(params_));
}
void TearDown() override {
StopServer();
QuicInMemoryCachePeer::ResetForTests();
}
void TearDown() override { QuicInMemoryCachePeer::ResetForTests(); }
// Starts the QUIC server listening on a random port.
void StartServer() {
......@@ -185,29 +180,15 @@ class QuicEndToEndTest : public ::testing::TestWithParam<TestParams> {
server_config_.SetInitialSessionFlowControlWindowToSend(
kInitialSessionFlowControlWindowForTest);
server_config_options_.token_binding_enabled = true;
QuicServer* server =
new QuicServer(CryptoTestUtils::ProofSourceForTesting(), server_config_,
server_config_options_, AllSupportedVersions());
server_thread_.reset(new ServerThread(server, server_address_,
strike_register_no_startup_period_));
server_thread_->Initialize();
server_address_ =
IPEndPoint(server_address_.address(), server_thread_->GetPort());
server_thread_->Start();
server_.reset(new QuicSimpleServer(CryptoTestUtils::ProofSourceForTesting(),
server_config_, server_config_options_,
AllSupportedVersions()));
server_->Listen(server_address_);
server_address_ = server_->server_address();
server_->StartReading();
server_started_ = true;
}
// Stops the QUIC server.
void StopServer() {
if (!server_started_) {
return;
}
if (server_thread_.get()) {
server_thread_->Quit();
server_thread_->Join();
}
}
// Adds an entry to the cache used by the QUIC server to serve
// responses.
void AddToCache(StringPiece path,
......@@ -269,7 +250,7 @@ class QuicEndToEndTest : public ::testing::TestWithParam<TestParams> {
HttpRequestInfo request_;
std::string request_body_;
std::unique_ptr<UploadDataStream> upload_data_stream_;
std::unique_ptr<ServerThread> server_thread_;
std::unique_ptr<QuicSimpleServer> server_;
IPEndPoint server_address_;
std::string server_hostname_;
QuicConfig server_config_;
......
......@@ -34,9 +34,11 @@ const int kReadBufferSize = 2 * kMaxPacketSize;
} // namespace
QuicSimpleServer::QuicSimpleServer(std::unique_ptr<ProofSource> proof_source,
const QuicConfig& config,
const QuicVersionVector& supported_versions)
QuicSimpleServer::QuicSimpleServer(
std::unique_ptr<ProofSource> proof_source,
const QuicConfig& config,
const QuicCryptoServerConfig::ConfigOptions& crypto_config_options,
const QuicVersionVector& supported_versions)
: version_manager_(supported_versions),
helper_(
new QuicChromiumConnectionHelper(&clock_, QuicRandom::GetInstance())),
......@@ -44,6 +46,7 @@ QuicSimpleServer::QuicSimpleServer(std::unique_ptr<ProofSource> proof_source,
base::ThreadTaskRunnerHandle::Get().get(),
&clock_)),
config_(config),
crypto_config_options_(crypto_config_options),
crypto_config_(kSourceAddressTokenSecret,
QuicRandom::GetInstance(),
std::move(proof_source)),
......@@ -76,7 +79,7 @@ void QuicSimpleServer::Initialize() {
std::unique_ptr<CryptoHandshakeMessage> scfg(crypto_config_.AddDefaultConfig(
helper_->GetRandomGenerator(), helper_->GetClock(),
QuicCryptoServerConfig::ConfigOptions()));
crypto_config_options_));
}
QuicSimpleServer::~QuicSimpleServer() {}
......
......@@ -33,9 +33,11 @@ class QuicSimpleServerPeer;
class QuicSimpleServer {
public:
QuicSimpleServer(std::unique_ptr<ProofSource> proof_source,
const QuicConfig& config,
const QuicVersionVector& supported_versions);
QuicSimpleServer(
std::unique_ptr<ProofSource> proof_source,
const QuicConfig& config,
const QuicCryptoServerConfig::ConfigOptions& crypto_config_options,
const QuicVersionVector& supported_versions);
virtual ~QuicSimpleServer();
......@@ -59,6 +61,8 @@ class QuicSimpleServer {
QuicDispatcher* dispatcher() { return dispatcher_.get(); }
IPEndPoint server_address() const { return server_address_; }
private:
friend class test::QuicSimpleServerPeer;
......@@ -85,6 +89,9 @@ class QuicSimpleServer {
// config_ contains non-crypto parameters that are negotiated in the crypto
// handshake.
QuicConfig config_;
// crypto_config_ contains crypto parameters that are negotiated in the crypto
// handshake.
QuicCryptoServerConfig::ConfigOptions crypto_config_options_;
// crypto_config_ contains crypto parameters for the handshake.
QuicCryptoServerConfig crypto_config_;
......
......@@ -85,7 +85,8 @@ int main(int argc, char* argv[]) {
net::QuicSimpleServer server(
CreateProofSource(line->GetSwitchValuePath("certificate_file"),
line->GetSwitchValuePath("key_file")),
config, net::AllSupportedVersions());
config, net::QuicCryptoServerConfig::ConfigOptions(),
net::AllSupportedVersions());
server.SetStrikeRegisterNoStartupPeriod();
int rc = server.Listen(net::IPEndPoint(ip, FLAGS_port));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment