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

Unified Diff: net/quic/quic_stream_factory_test.cc

Issue 881133004: QUIC - Race two connections. One connection which loads data from disk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« net/quic/quic_stream_factory.cc ('K') | « net/quic/quic_stream_factory.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_stream_factory_test.cc
diff --git a/net/quic/quic_stream_factory_test.cc b/net/quic/quic_stream_factory_test.cc
index 2ce6ef4dcb014c7c3f70f6fabfb5ef305b5ea97d..d62ab8d73bec9b5ed760195f578dcfbadad05fc1 100644
--- a/net/quic/quic_stream_factory_test.cc
+++ b/net/quic/quic_stream_factory_test.cc
@@ -34,6 +34,7 @@
#include "testing/gtest/include/gtest/gtest.h"
using base::StringPiece;
+using std::ostream;
using std::string;
using std::vector;
@@ -43,6 +44,34 @@ namespace test {
namespace {
const char kDefaultServerHostName[] = "www.google.com";
const int kDefaultServerPort = 443;
+
+// Run all tests with all the combinations of versions and
+// enable_connection_racing.
+struct TestParams {
+ TestParams(const QuicVersion version, bool enable_connection_racing)
+ : version(version), enable_connection_racing(enable_connection_racing) {}
+
+ friend ostream& operator<<(ostream& os, const TestParams& p) {
+ os << "{ version: " << QuicVersionToString(p.version);
+ os << " enable_connection_racing: " << p.enable_connection_racing << " }";
+ return os;
+ }
+
+ QuicVersion version;
+ bool enable_connection_racing;
+};
+
+// Constructs various test permutations.
+vector<TestParams> GetTestParams() {
+ vector<TestParams> params;
+ QuicVersionVector all_supported_versions = QuicSupportedVersions();
+ for (const QuicVersion version : all_supported_versions) {
+ params.push_back(TestParams(version, false));
+ params.push_back(TestParams(version, true));
+ }
+ return params;
+}
+
} // namespace anonymous
class QuicStreamFactoryPeer {
@@ -100,6 +129,11 @@ class QuicStreamFactoryPeer {
size_t load_server_info_timeout) {
factory->load_server_info_timeout_ms_ = load_server_info_timeout;
}
+
+ static void SetEnableConnectionRacing(QuicStreamFactory* factory,
+ bool enable_connection_racing) {
+ factory->enable_connection_racing_ = enable_connection_racing;
+ }
};
class MockQuicServerInfo : public QuicServerInfo {
@@ -135,14 +169,13 @@ class MockQuicServerInfoFactory : public QuicServerInfoFactory {
}
};
-
-class QuicStreamFactoryTest : public ::testing::TestWithParam<QuicVersion> {
+class QuicStreamFactoryTest : public ::testing::TestWithParam<TestParams> {
protected:
QuicStreamFactoryTest()
: random_generator_(0),
clock_(new MockClock()),
runner_(new TestTaskRunner(clock_)),
- maker_(GetParam(), 0, clock_),
+ maker_(GetParam().version, 0, clock_),
cert_verifier_(CertVerifier::CreateDefault()),
channel_id_service_(
new ChannelIDService(new DefaultChannelIDStore(nullptr),
@@ -158,7 +191,7 @@ class QuicStreamFactoryTest : public ::testing::TestWithParam<QuicVersion> {
clock_,
kDefaultMaxPacketSize,
std::string(),
- SupportedVersions(GetParam()),
+ SupportedVersions(GetParam().version),
/*enable_port_selection=*/true,
/*always_require_handshake_confirmation=*/false,
/*disable_connection_pooling=*/false,
@@ -171,6 +204,8 @@ class QuicStreamFactoryTest : public ::testing::TestWithParam<QuicVersion> {
privacy_mode_(PRIVACY_MODE_DISABLED) {
factory_.set_require_confirmation(false);
clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
+ QuicStreamFactoryPeer::SetEnableConnectionRacing(
+ &factory_, GetParam().enable_connection_racing);
}
scoped_ptr<QuicHttpStream> CreateIfSessionExists(
@@ -244,7 +279,7 @@ class QuicStreamFactoryTest : public ::testing::TestWithParam<QuicVersion> {
QuicStreamId stream_id = kClientDataStreamId1;
return maker_.MakeRstPacket(
1, true, stream_id,
- AdjustErrorForVersion(QUIC_RST_ACKNOWLEDGEMENT, GetParam()));
+ AdjustErrorForVersion(QUIC_RST_ACKNOWLEDGEMENT, GetParam().version));
}
MockQuicServerInfoFactory quic_server_info_factory_;
@@ -266,8 +301,9 @@ class QuicStreamFactoryTest : public ::testing::TestWithParam<QuicVersion> {
TestCompletionCallback callback_;
};
-INSTANTIATE_TEST_CASE_P(Version, QuicStreamFactoryTest,
- ::testing::ValuesIn(QuicSupportedVersions()));
+INSTANTIATE_TEST_CASE_P(Version,
+ QuicStreamFactoryTest,
+ ::testing::ValuesIn(GetTestParams()));
TEST_P(QuicStreamFactoryTest, CreateIfSessionExists) {
EXPECT_EQ(nullptr, CreateIfSessionExists(host_port_pair_, net_log_).get());
@@ -1562,6 +1598,10 @@ TEST_P(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) {
}
TEST_P(QuicStreamFactoryTest, CancelWaitForDataReady) {
+ // Don't race quic connections when testing cancel reading of server config
+ // from disk cache.
+ if (GetParam().enable_connection_racing)
+ return;
factory_.set_quic_server_info_factory(&quic_server_info_factory_);
QuicStreamFactoryPeer::SetTaskRunner(&factory_, runner_.get());
const size_t kLoadServerInfoTimeoutMs = 50;
« net/quic/quic_stream_factory.cc ('K') | « net/quic/quic_stream_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698