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

Unified Diff: net/tools/quic/end_to_end_test.cc

Issue 47283002: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compilation error Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/test_tools/simple_quic_framer.cc ('k') | net/tools/quic/quic_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/end_to_end_test.cc
diff --git a/net/tools/quic/end_to_end_test.cc b/net/tools/quic/end_to_end_test.cc
index adedabb85770f3dfb96a70860bc1ae42445d07a6..b0a963f0814283031dad011381ab00fdcf24d68d 100644
--- a/net/tools/quic/end_to_end_test.cc
+++ b/net/tools/quic/end_to_end_test.cc
@@ -70,22 +70,65 @@ void GenerateBody(string* body, int length) {
// Run all tests with the cross products of all versions
// and all values of FLAGS_pad_quic_handshake_packets.
struct TestParams {
- TestParams(QuicVersion version,
+ TestParams(const QuicVersionVector& client_supported_versions,
+ const QuicVersionVector& server_supported_versions,
+ QuicVersion negotiated_version,
bool use_padding)
- : version(version),
+ : client_supported_versions(client_supported_versions),
+ server_supported_versions(server_supported_versions),
+ negotiated_version(negotiated_version),
use_padding(use_padding) {
}
- QuicVersion version;
+ QuicVersionVector client_supported_versions;
+ QuicVersionVector server_supported_versions;
+ QuicVersion negotiated_version;
bool use_padding;
};
-// Constructs all the various test permutations.
+// Constructs various test permutations.
vector<TestParams> GetTestParams() {
vector<TestParams> params;
- for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) {
- params.push_back(TestParams(kSupportedQuicVersions[i], true));
- params.push_back(TestParams(kSupportedQuicVersions[i], false));
+ QuicVersionVector all_supported_versions = QuicSupportedVersions();
+
+ // Add an entry for server and client supporting all versions.
+ params.push_back(TestParams(all_supported_versions, all_supported_versions,
+ all_supported_versions[0], true));
+ params.push_back(TestParams(all_supported_versions, all_supported_versions,
+ all_supported_versions[0], false));
+
+ // Test client supporting 1 version and server supporting all versions.
+ // Simulate an old client and exercise version downgrade in the server.
+ // No protocol negotiation should occur. Skip the i = 0 case because it
+ // is essentially the same as the default case.
+ for (size_t i = 1; i < all_supported_versions.size(); ++i) {
+ QuicVersionVector client_supported_versions;
+ client_supported_versions.push_back(all_supported_versions[i]);
+ params.push_back(TestParams(client_supported_versions,
+ all_supported_versions,
+ client_supported_versions[0],
+ true));
+ params.push_back(TestParams(client_supported_versions,
+ all_supported_versions,
+ client_supported_versions[0],
+ false));
+ }
+
+ // Test client supporting all versions and server supporting 1 version.
+ // Simulate an old server and exercise version downgrade in the client.
+ // Protocol negotiation should occur. Skip the i = 0 case because it is
+ // essentially the same as the default case.
+ for (size_t i = 1; i < all_supported_versions.size(); ++i) {
+ QuicVersionVector server_supported_versions;
+ server_supported_versions.push_back(all_supported_versions[i]);
+ params.push_back(TestParams(all_supported_versions,
+ server_supported_versions,
+ server_supported_versions[0],
+ true));
+ params.push_back(TestParams(all_supported_versions,
+ server_supported_versions,
+ server_supported_versions[0],
+ false));
}
return params;
}
@@ -109,12 +152,23 @@ class EndToEndTest : public ::testing::TestWithParam<TestParams> {
"HTTP/1.1", "200", "OK", kFooResponseBody);
AddToCache("GET", "https://www.google.com/bar",
"HTTP/1.1", "200", "OK", kBarResponseBody);
- version_ = GetParam().version;
- FLAGS_pad_quic_handshake_packets =
- GetParam().use_padding;
+
+ client_supported_versions_ = GetParam().client_supported_versions;
+ server_supported_versions_ = GetParam().server_supported_versions;
+ negotiated_version_ = GetParam().negotiated_version;
+ FLAGS_pad_quic_handshake_packets = GetParam().use_padding;
+ LOG(INFO) << "server running " << QuicVersionVectorToString(
+ server_supported_versions_);
+ LOG(INFO) << "client running " << QuicVersionVectorToString(
+ client_supported_versions_);
+ LOG(INFO) << "negotiated_version_ " << QuicVersionToString(
+ negotiated_version_);
+ LOG(INFO) << "use_padding " << GetParam().use_padding;
}
virtual ~EndToEndTest() {
+ // TODO(rtenneti): port RecycleUnusedPort if needed.
+ // RecycleUnusedPort(server_address_.port());
QuicInMemoryCachePeer::ResetForTests();
}
@@ -123,7 +177,7 @@ class EndToEndTest : public ::testing::TestWithParam<TestParams> {
server_hostname_,
false, // not secure
client_config_,
- version_);
+ client_supported_versions_);
client->UseWriter(writer);
client->Connect();
return client;
@@ -155,6 +209,7 @@ class EndToEndTest : public ::testing::TestWithParam<TestParams> {
void StartServer() {
server_thread_.reset(new ServerThread(server_address_, server_config_,
+ server_supported_versions_,
strike_register_no_startup_period_));
server_thread_->Start();
server_thread_->listening()->Wait();
@@ -217,7 +272,9 @@ class EndToEndTest : public ::testing::TestWithParam<TestParams> {
bool server_started_;
QuicConfig client_config_;
QuicConfig server_config_;
- QuicVersion version_;
+ QuicVersionVector client_supported_versions_;
+ QuicVersionVector server_supported_versions_;
+ QuicVersion negotiated_version_;
bool strike_register_no_startup_period_;
};
@@ -312,14 +369,12 @@ TEST_P(EndToEndTest, RequestOverMultiplePackets) {
const size_t kStreamDataLength = 3;
const QuicStreamId kStreamId = 1u;
const QuicStreamOffset kStreamOffset = 0u;
- size_t stream_payload_size =
- QuicFramer::GetMinStreamFrameSize(
- version_, kStreamId, kStreamOffset, true) + kStreamDataLength;
+ size_t stream_payload_size = QuicFramer::GetMinStreamFrameSize(
+ negotiated_version_, kStreamId, kStreamOffset, true) + kStreamDataLength;
size_t min_payload_size =
std::max(kCongestionFeedbackFrameSize, stream_payload_size);
- bool use_short_hash = version_ >= QUIC_VERSION_11;
size_t ciphertext_size =
- NullEncrypter(use_short_hash).GetCiphertextSize(min_payload_size);
+ NullEncrypter(false).GetCiphertextSize(min_payload_size);
// TODO(satyashekhar): Fix this when versioning is implemented.
client_->options()->max_packet_length =
GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
@@ -345,14 +400,12 @@ TEST_P(EndToEndTest, MultipleFramesRandomOrder) {
const size_t kStreamDataLength = 3;
const QuicStreamId kStreamId = 1u;
const QuicStreamOffset kStreamOffset = 0u;
- size_t stream_payload_size =
- QuicFramer::GetMinStreamFrameSize(
- version_, kStreamId, kStreamOffset, true) + kStreamDataLength;
+ size_t stream_payload_size = QuicFramer::GetMinStreamFrameSize(
+ negotiated_version_, kStreamId, kStreamOffset, true) + kStreamDataLength;
size_t min_payload_size =
std::max(kCongestionFeedbackFrameSize, stream_payload_size);
- bool use_short_hash = version_ >= QUIC_VERSION_11;
size_t ciphertext_size =
- NullEncrypter(use_short_hash).GetCiphertextSize(min_payload_size);
+ NullEncrypter(false).GetCiphertextSize(min_payload_size);
// TODO(satyashekhar): Fix this when versioning is implemented.
client_->options()->max_packet_length =
GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
« no previous file with comments | « net/quic/test_tools/simple_quic_framer.cc ('k') | net/tools/quic/quic_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698