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

Side by Side Diff: net/tools/quic/end_to_end_test.cc

Issue 2850573002: Landing Recent QUIC changes until 3:35 PM, Apr 26, 2017 UTC-4 (Closed)
Patch Set: Remove Disconnect from ~QuicTestClient Created 3 years, 7 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <sys/epoll.h> 6 #include <sys/epoll.h>
7 7
8 #include <cstdint> 8 #include <cstdint>
9 #include <list> 9 #include <list>
10 #include <memory> 10 #include <memory>
(...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 ASSERT_TRUE(Initialize()); 1996 ASSERT_TRUE(Initialize());
1997 1997
1998 // Send the public reset. 1998 // Send the public reset.
1999 QuicConnectionId connection_id = 1999 QuicConnectionId connection_id =
2000 client_->client()->session()->connection()->connection_id(); 2000 client_->client()->session()->connection()->connection_id();
2001 QuicPublicResetPacket header; 2001 QuicPublicResetPacket header;
2002 header.public_header.connection_id = 2002 header.public_header.connection_id =
2003 GetPeerInMemoryConnectionId(connection_id); 2003 GetPeerInMemoryConnectionId(connection_id);
2004 header.public_header.reset_flag = true; 2004 header.public_header.reset_flag = true;
2005 header.public_header.version_flag = false; 2005 header.public_header.version_flag = false;
2006 header.rejected_packet_number = 10101;
2007 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), 2006 QuicFramer framer(server_supported_versions_, QuicTime::Zero(),
2008 Perspective::IS_SERVER); 2007 Perspective::IS_SERVER);
2009 std::unique_ptr<QuicEncryptedPacket> packet( 2008 std::unique_ptr<QuicEncryptedPacket> packet(
2010 framer.BuildPublicResetPacket(header)); 2009 framer.BuildPublicResetPacket(header));
2011 // We must pause the server's thread in order to call WritePacket without 2010 // We must pause the server's thread in order to call WritePacket without
2012 // race conditions. 2011 // race conditions.
2013 server_thread_->Pause(); 2012 server_thread_->Pause();
2014 server_writer_->WritePacket( 2013 server_writer_->WritePacket(
2015 packet->data(), packet->length(), server_address_.host(), 2014 packet->data(), packet->length(), server_address_.host(),
2016 client_->client()->GetLatestClientAddress(), nullptr); 2015 client_->client()->GetLatestClientAddress(), nullptr);
(...skipping 13 matching lines...) Expand all
2030 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); 2029 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2031 2030
2032 // Send the public reset. 2031 // Send the public reset.
2033 QuicConnectionId incorrect_connection_id = 2032 QuicConnectionId incorrect_connection_id =
2034 client_->client()->session()->connection()->connection_id() + 1; 2033 client_->client()->session()->connection()->connection_id() + 1;
2035 QuicPublicResetPacket header; 2034 QuicPublicResetPacket header;
2036 header.public_header.connection_id = 2035 header.public_header.connection_id =
2037 GetPeerInMemoryConnectionId(incorrect_connection_id); 2036 GetPeerInMemoryConnectionId(incorrect_connection_id);
2038 header.public_header.reset_flag = true; 2037 header.public_header.reset_flag = true;
2039 header.public_header.version_flag = false; 2038 header.public_header.version_flag = false;
2040 header.rejected_packet_number = 10101;
2041 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), 2039 QuicFramer framer(server_supported_versions_, QuicTime::Zero(),
2042 Perspective::IS_SERVER); 2040 Perspective::IS_SERVER);
2043 std::unique_ptr<QuicEncryptedPacket> packet( 2041 std::unique_ptr<QuicEncryptedPacket> packet(
2044 framer.BuildPublicResetPacket(header)); 2042 framer.BuildPublicResetPacket(header));
2045 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; 2043 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor;
2046 client_->client()->session()->connection()->set_debug_visitor(&visitor); 2044 client_->client()->session()->connection()->set_debug_visitor(&visitor);
2047 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) 2045 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id))
2048 .Times(1); 2046 .Times(1);
2049 // We must pause the server's thread in order to call WritePacket without 2047 // We must pause the server's thread in order to call WritePacket without
2050 // race conditions. 2048 // race conditions.
(...skipping 15 matching lines...) Expand all
2066 TEST_P(EndToEndTest, ClientSendPublicResetWithDifferentConnectionId) { 2064 TEST_P(EndToEndTest, ClientSendPublicResetWithDifferentConnectionId) {
2067 ASSERT_TRUE(Initialize()); 2065 ASSERT_TRUE(Initialize());
2068 2066
2069 // Send the public reset. 2067 // Send the public reset.
2070 QuicConnectionId incorrect_connection_id = 2068 QuicConnectionId incorrect_connection_id =
2071 client_->client()->session()->connection()->connection_id() + 1; 2069 client_->client()->session()->connection()->connection_id() + 1;
2072 QuicPublicResetPacket header; 2070 QuicPublicResetPacket header;
2073 header.public_header.connection_id = incorrect_connection_id; 2071 header.public_header.connection_id = incorrect_connection_id;
2074 header.public_header.reset_flag = true; 2072 header.public_header.reset_flag = true;
2075 header.public_header.version_flag = false; 2073 header.public_header.version_flag = false;
2076 header.rejected_packet_number = 10101;
2077 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), 2074 QuicFramer framer(server_supported_versions_, QuicTime::Zero(),
2078 Perspective::IS_CLIENT); 2075 Perspective::IS_CLIENT);
2079 std::unique_ptr<QuicEncryptedPacket> packet( 2076 std::unique_ptr<QuicEncryptedPacket> packet(
2080 framer.BuildPublicResetPacket(header)); 2077 framer.BuildPublicResetPacket(header));
2081 client_writer_->WritePacket( 2078 client_writer_->WritePacket(
2082 packet->data(), packet->length(), 2079 packet->data(), packet->length(),
2083 client_->client()->GetLatestClientAddress().host(), server_address_, 2080 client_->client()->GetLatestClientAddress().host(), server_address_,
2084 nullptr); 2081 nullptr);
2085 2082
2086 // The connection should be unaffected. 2083 // The connection should be unaffected.
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
3016 headers[":scheme"] = "https"; 3013 headers[":scheme"] = "https";
3017 headers[":authority"] = server_hostname_; 3014 headers[":authority"] = server_hostname_;
3018 headers["key"] = string(64 * 1024, 'a'); 3015 headers["key"] = string(64 * 1024, 'a');
3019 3016
3020 client_->SendMessage(headers, ""); 3017 client_->SendMessage(headers, "");
3021 client_->WaitForResponse(); 3018 client_->WaitForResponse();
3022 EXPECT_EQ(QUIC_HEADERS_STREAM_DATA_DECOMPRESS_FAILURE, 3019 EXPECT_EQ(QUIC_HEADERS_STREAM_DATA_DECOMPRESS_FAILURE,
3023 client_->connection_error()); 3020 client_->connection_error());
3024 } 3021 }
3025 3022
3023 class WindowUpdateObserver : public QuicConnectionDebugVisitor {
3024 public:
3025 WindowUpdateObserver() : num_window_update_frames_(0) {}
3026
3027 size_t num_window_update_frames() const { return num_window_update_frames_; }
3028
3029 void OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override {
3030 ++num_window_update_frames_;
3031 }
3032
3033 private:
3034 size_t num_window_update_frames_;
3035 };
3036
3037 TEST_P(EndToEndTest, WindowUpdateInAck) {
3038 FLAGS_quic_reloadable_flag_quic_enable_version_38 = true;
3039 FLAGS_quic_reloadable_flag_quic_enable_version_39 = true;
3040 ASSERT_TRUE(Initialize());
3041 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
3042 WindowUpdateObserver observer;
3043 QuicConnection* client_connection =
3044 client_->client()->session()->connection();
3045 client_connection->set_debug_visitor(&observer);
3046 QuicVersion version = client_connection->version();
3047 // 100KB body.
3048 string body(100 * 1024, 'a');
3049 SpdyHeaderBlock headers;
3050 headers[":method"] = "POST";
3051 headers[":path"] = "/foo";
3052 headers[":scheme"] = "https";
3053 headers[":authority"] = server_hostname_;
3054
3055 EXPECT_EQ(kFooResponseBody,
3056 client_->SendCustomSynchronousRequest(headers, body));
3057 client_->Disconnect();
3058 if (version > QUIC_VERSION_38) {
3059 EXPECT_LT(0u, observer.num_window_update_frames());
3060 } else {
3061 EXPECT_EQ(0u, observer.num_window_update_frames());
3062 }
3063 }
3064
3026 class EndToEndBufferedPacketsTest : public EndToEndTest { 3065 class EndToEndBufferedPacketsTest : public EndToEndTest {
3027 public: 3066 public:
3028 void CreateClientWithWriter() override { 3067 void CreateClientWithWriter() override {
3029 QUIC_LOG(ERROR) << "create client with reorder_writer_ "; 3068 QUIC_LOG(ERROR) << "create client with reorder_writer_ ";
3030 reorder_writer_ = new PacketReorderingWriter(); 3069 reorder_writer_ = new PacketReorderingWriter();
3031 client_.reset(EndToEndTest::CreateQuicClient(reorder_writer_)); 3070 client_.reset(EndToEndTest::CreateQuicClient(reorder_writer_));
3032 } 3071 }
3033 3072
3034 void SetUp() override { 3073 void SetUp() override {
3035 // Don't initialize client writer in base class. 3074 // Don't initialize client writer in base class.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3070 client_->WaitForResponse(); 3109 client_->WaitForResponse();
3071 EXPECT_EQ(kBarResponseBody, client_->response_body()); 3110 EXPECT_EQ(kBarResponseBody, client_->response_body());
3072 QuicConnectionStats client_stats = 3111 QuicConnectionStats client_stats =
3073 client_->client()->session()->connection()->GetStats(); 3112 client_->client()->session()->connection()->GetStats();
3074 EXPECT_EQ(0u, client_stats.packets_lost); 3113 EXPECT_EQ(0u, client_stats.packets_lost);
3075 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); 3114 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos());
3076 } 3115 }
3077 } // namespace 3116 } // namespace
3078 } // namespace test 3117 } // namespace test
3079 } // namespace net 3118 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/simulator/quic_endpoint.h ('k') | net/tools/quic/quic_client_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698