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

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

Issue 2862563003: Landing Recent QUIC changes until Sat Apr 29 00:22:04 2017 +0000 (Closed)
Patch Set: rebase and fix test bugs detected by swarm bot. 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
« no previous file with comments | « net/quic/test_tools/quic_test_utils.cc ('k') | net/tools/quic/quic_client_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 QuicFlowControllerPeer::ReceiveWindowSize(server)); 596 QuicFlowControllerPeer::ReceiveWindowSize(server));
597 EXPECT_EQ(QuicFlowControllerPeer::ReceiveWindowSize(client), 597 EXPECT_EQ(QuicFlowControllerPeer::ReceiveWindowSize(client),
598 QuicFlowControllerPeer::SendWindowSize(server)); 598 QuicFlowControllerPeer::SendWindowSize(server));
599 } 599 }
600 600
601 // Must be called before Initialize to have effect. 601 // Must be called before Initialize to have effect.
602 void SetSpdyStreamFactory(QuicTestServer::StreamFactory* factory) { 602 void SetSpdyStreamFactory(QuicTestServer::StreamFactory* factory) {
603 stream_factory_ = factory; 603 stream_factory_ = factory;
604 } 604 }
605 605
606 QuicStreamId GetNthClientInitiatedId(int n) {
607 return QuicSpdySessionPeer::GetNthClientInitiatedStreamId(
608 *client_->client()->session(), n);
609 }
610
611 QuicStreamId GetNthServerInitiatedId(int n) {
612 return QuicSpdySessionPeer::GetNthServerInitiatedStreamId(
613 *client_->client()->session(), n);
614 }
615
606 bool initialized_; 616 bool initialized_;
607 QuicSocketAddress server_address_; 617 QuicSocketAddress server_address_;
608 string server_hostname_; 618 string server_hostname_;
609 QuicHttpResponseCache response_cache_; 619 QuicHttpResponseCache response_cache_;
610 std::unique_ptr<ServerThread> server_thread_; 620 std::unique_ptr<ServerThread> server_thread_;
611 std::unique_ptr<QuicTestClient> client_; 621 std::unique_ptr<QuicTestClient> client_;
612 PacketDroppingTestWriter* client_writer_; 622 PacketDroppingTestWriter* client_writer_;
613 PacketDroppingTestWriter* server_writer_; 623 PacketDroppingTestWriter* server_writer_;
614 bool server_started_; 624 bool server_started_;
615 QuicConfig client_config_; 625 QuicConfig client_config_;
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 1200
1191 string body(kMaxPacketSize, 'a'); 1201 string body(kMaxPacketSize, 'a');
1192 SpdyHeaderBlock headers; 1202 SpdyHeaderBlock headers;
1193 headers[":method"] = "POST"; 1203 headers[":method"] = "POST";
1194 headers[":path"] = "/foo"; 1204 headers[":path"] = "/foo";
1195 headers[":scheme"] = "https"; 1205 headers[":scheme"] = "https";
1196 headers[":authority"] = server_hostname_; 1206 headers[":authority"] = server_hostname_;
1197 1207
1198 // Force the client to write with a stream ID belonging to a nonexistent 1208 // Force the client to write with a stream ID belonging to a nonexistent
1199 // server-side stream. 1209 // server-side stream.
1200 QuicSessionPeer::SetNextOutgoingStreamId(client_->client()->session(), 2); 1210 QuicSpdySession* session = client_->client()->session();
1211 QuicSessionPeer::SetNextOutgoingStreamId(session, GetNthServerInitiatedId(0));
1201 1212
1202 client_->SendCustomSynchronousRequest(headers, body); 1213 client_->SendCustomSynchronousRequest(headers, body);
1203 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); 1214 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error());
1204 EXPECT_EQ(QUIC_INVALID_STREAM_ID, client_->connection_error()); 1215 EXPECT_EQ(QUIC_INVALID_STREAM_ID, client_->connection_error());
1205 } 1216 }
1206 1217
1207 // Test that if the the server will close the connection if the client attempts 1218 // Test that if the the server will close the connection if the client attempts
1208 // to send a request with overly large headers. 1219 // to send a request with overly large headers.
1209 TEST_P(EndToEndTest, LargeHeaders) { 1220 TEST_P(EndToEndTest, LargeHeaders) {
1210 ASSERT_TRUE(Initialize()); 1221 ASSERT_TRUE(Initialize());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 TEST_P(EndToEndTest, MaxIncomingDynamicStreamsLimitRespected) { 1292 TEST_P(EndToEndTest, MaxIncomingDynamicStreamsLimitRespected) {
1282 // Set a limit on maximum number of incoming dynamic streams. 1293 // Set a limit on maximum number of incoming dynamic streams.
1283 // Make sure the limit is respected. 1294 // Make sure the limit is respected.
1284 const uint32_t kServerMaxIncomingDynamicStreams = 1; 1295 const uint32_t kServerMaxIncomingDynamicStreams = 1;
1285 server_config_.SetMaxIncomingDynamicStreamsToSend( 1296 server_config_.SetMaxIncomingDynamicStreamsToSend(
1286 kServerMaxIncomingDynamicStreams); 1297 kServerMaxIncomingDynamicStreams);
1287 ASSERT_TRUE(Initialize()); 1298 ASSERT_TRUE(Initialize());
1288 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); 1299 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1289 1300
1290 // Make the client misbehave after negotiation. 1301 // Make the client misbehave after negotiation.
1291 const int kServerMaxStreams = 1302 const int kServerMaxStreams = kMaxStreamsMinimumIncrement + 1;
1292 kMaxStreamsMinimumIncrement + kServerMaxIncomingDynamicStreams;
1293 QuicSessionPeer::SetMaxOpenOutgoingStreams(client_->client()->session(), 1303 QuicSessionPeer::SetMaxOpenOutgoingStreams(client_->client()->session(),
1294 kServerMaxStreams + 1); 1304 kServerMaxStreams + 1);
1295 1305
1296 SpdyHeaderBlock headers; 1306 SpdyHeaderBlock headers;
1297 headers[":method"] = "POST"; 1307 headers[":method"] = "POST";
1298 headers[":path"] = "/foo"; 1308 headers[":path"] = "/foo";
1299 headers[":scheme"] = "https"; 1309 headers[":scheme"] = "https";
1300 headers[":authority"] = server_hostname_; 1310 headers[":authority"] = server_hostname_;
1301 headers["content-length"] = "3"; 1311 headers["content-length"] = "3";
1302 1312
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 1546
1537 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); 1547 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1538 1548
1539 QuicSession* session = client_->client()->session(); 1549 QuicSession* session = client_->client()->session();
1540 // Lose the request. 1550 // Lose the request.
1541 SetPacketLossPercentage(100); 1551 SetPacketLossPercentage(100);
1542 EXPECT_LT(0, client_->SendRequest("/small_response")); 1552 EXPECT_LT(0, client_->SendRequest("/small_response"));
1543 client_->client()->WaitForEvents(); 1553 client_->client()->WaitForEvents();
1544 // Transmit the cancel, and ensure the connection is torn down properly. 1554 // Transmit the cancel, and ensure the connection is torn down properly.
1545 SetPacketLossPercentage(0); 1555 SetPacketLossPercentage(0);
1546 QuicStreamId stream_id = kClientDataStreamId1; 1556 QuicStreamId stream_id = GetNthClientInitiatedId(0);
1547 session->SendRstStream(stream_id, QUIC_STREAM_CANCELLED, 0); 1557 session->SendRstStream(stream_id, QUIC_STREAM_CANCELLED, 0);
1548 1558
1549 // WaitForEvents waits 50ms and returns true if there are outstanding 1559 // WaitForEvents waits 50ms and returns true if there are outstanding
1550 // requests. 1560 // requests.
1551 while (client_->client()->WaitForEvents() == true) { 1561 while (client_->client()->WaitForEvents() == true) {
1552 } 1562 }
1553 // It should be completely fine to RST a stream before any data has been 1563 // It should be completely fine to RST a stream before any data has been
1554 // received for that stream. 1564 // received for that stream.
1555 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error()); 1565 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error());
1556 } 1566 }
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 server_id, 2420 server_id,
2411 crypto_config, 2421 crypto_config,
2412 push_promise_index) {} 2422 push_promise_index) {}
2413 2423
2414 ~ClientSessionThatDropsBody() override {} 2424 ~ClientSessionThatDropsBody() override {}
2415 2425
2416 std::unique_ptr<QuicSpdyClientStream> CreateClientStream() override { 2426 std::unique_ptr<QuicSpdyClientStream> CreateClientStream() override {
2417 return QuicMakeUnique<ClientStreamThatDropsBody>(GetNextOutgoingStreamId(), 2427 return QuicMakeUnique<ClientStreamThatDropsBody>(GetNextOutgoingStreamId(),
2418 this); 2428 this);
2419 } 2429 }
2430 std::unique_ptr<QuicStream> CreateStream(QuicStreamId id) override {
2431 return QuicMakeUnique<ClientStreamThatDropsBody>(id, this);
2432 }
2420 }; 2433 };
2421 2434
2422 class MockableQuicClientThatDropsBody : public MockableQuicClient { 2435 class MockableQuicClientThatDropsBody : public MockableQuicClient {
2423 public: 2436 public:
2424 MockableQuicClientThatDropsBody(QuicSocketAddress server_address, 2437 MockableQuicClientThatDropsBody(QuicSocketAddress server_address,
2425 const QuicServerId& server_id, 2438 const QuicServerId& server_id,
2426 const QuicConfig& config, 2439 const QuicConfig& config,
2427 const QuicVersionVector& supported_versions, 2440 const QuicVersionVector& supported_versions,
2428 EpollServer* epoll_server) 2441 EpollServer* epoll_server)
2429 : MockableQuicClient(server_address, 2442 : MockableQuicClient(server_address,
(...skipping 17 matching lines...) Expand all
2447 public: 2460 public:
2448 QuicTestClientThatDropsBody(QuicSocketAddress server_address, 2461 QuicTestClientThatDropsBody(QuicSocketAddress server_address,
2449 const string& server_hostname, 2462 const string& server_hostname,
2450 const QuicConfig& config, 2463 const QuicConfig& config,
2451 const QuicVersionVector& supported_versions) 2464 const QuicVersionVector& supported_versions)
2452 : QuicTestClient(server_address, 2465 : QuicTestClient(server_address,
2453 server_hostname, 2466 server_hostname,
2454 config, 2467 config,
2455 supported_versions) { 2468 supported_versions) {
2456 set_client(new MockableQuicClientThatDropsBody( 2469 set_client(new MockableQuicClientThatDropsBody(
2457 server_address, QuicServerId(server_hostname, server_address.port(), 2470 server_address,
2458 PRIVACY_MODE_DISABLED), 2471 QuicServerId(server_hostname, server_address.port(),
2472 PRIVACY_MODE_DISABLED),
2459 config, supported_versions, epoll_server())); 2473 config, supported_versions, epoll_server()));
2460 } 2474 }
2461 ~QuicTestClientThatDropsBody() override {} 2475 ~QuicTestClientThatDropsBody() override {}
2462 }; 2476 };
2463 2477
2464 TEST_P(EndToEndTest, EarlyResponseFinRecording) { 2478 TEST_P(EndToEndTest, EarlyResponseFinRecording) {
2465 set_smaller_flow_control_receive_window(); 2479 set_smaller_flow_control_receive_window();
2466 2480
2467 // Verify that an incoming FIN is recorded in a stream object even if the read 2481 // Verify that an incoming FIN is recorded in a stream object even if the read
2468 // side has been closed. This prevents an entry from being made in 2482 // side has been closed. This prevents an entry from being made in
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 // Tell the client to not close the stream if it receives an early response. 2573 // Tell the client to not close the stream if it receives an early response.
2560 client_->set_allow_bidirectional_data(true); 2574 client_->set_allow_bidirectional_data(true);
2561 // Send the headers. 2575 // Send the headers.
2562 client_->SendMessage(headers, "", /*fin=*/false); 2576 client_->SendMessage(headers, "", /*fin=*/false);
2563 2577
2564 // Receive the response and let the server close writing. 2578 // Receive the response and let the server close writing.
2565 client_->WaitForInitialResponse(); 2579 client_->WaitForInitialResponse();
2566 EXPECT_EQ("500", client_->response_headers()->find(":status")->second); 2580 EXPECT_EQ("500", client_->response_headers()->find(":status")->second);
2567 2581
2568 // Receive the reset stream from server on early response. 2582 // Receive the reset stream from server on early response.
2569 QuicStream* stream = 2583 QuicStream* stream = client_->client()->session()->GetOrCreateStream(
2570 client_->client()->session()->GetOrCreateStream(kClientDataStreamId1); 2584 GetNthClientInitiatedId(0));
2571 // The stream is reset by server's reset stream. 2585 // The stream is reset by server's reset stream.
2572 EXPECT_EQ(stream, nullptr); 2586 EXPECT_EQ(stream, nullptr);
2573 } 2587 }
2574 2588
2575 TEST_P(EndToEndTest, Trailers) { 2589 TEST_P(EndToEndTest, Trailers) {
2576 // Test sending and receiving HTTP/2 Trailers (trailing HEADERS frames). 2590 // Test sending and receiving HTTP/2 Trailers (trailing HEADERS frames).
2577 ASSERT_TRUE(Initialize()); 2591 ASSERT_TRUE(Initialize());
2578 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); 2592 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2579 2593
2580 // Set reordering to ensure that Trailers arriving before body is ok. 2594 // Set reordering to ensure that Trailers arriving before body is ok.
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
3109 client_->WaitForResponse(); 3123 client_->WaitForResponse();
3110 EXPECT_EQ(kBarResponseBody, client_->response_body()); 3124 EXPECT_EQ(kBarResponseBody, client_->response_body());
3111 QuicConnectionStats client_stats = 3125 QuicConnectionStats client_stats =
3112 client_->client()->session()->connection()->GetStats(); 3126 client_->client()->session()->connection()->GetStats();
3113 EXPECT_EQ(0u, client_stats.packets_lost); 3127 EXPECT_EQ(0u, client_stats.packets_lost);
3114 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); 3128 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos());
3115 } 3129 }
3116 } // namespace 3130 } // namespace
3117 } // namespace test 3131 } // namespace test
3118 } // namespace net 3132 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.cc ('k') | net/tools/quic/quic_client_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698