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

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

Issue 2854833005: QUIC - stream id refactor for tests. (Closed)
Patch Set: fix test failures detected by swarming test bots 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_session_test.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 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 public: 2457 public:
2448 QuicTestClientThatDropsBody(QuicSocketAddress server_address, 2458 QuicTestClientThatDropsBody(QuicSocketAddress server_address,
2449 const string& server_hostname, 2459 const string& server_hostname,
2450 const QuicConfig& config, 2460 const QuicConfig& config,
2451 const QuicVersionVector& supported_versions) 2461 const QuicVersionVector& supported_versions)
2452 : QuicTestClient(server_address, 2462 : QuicTestClient(server_address,
2453 server_hostname, 2463 server_hostname,
2454 config, 2464 config,
2455 supported_versions) { 2465 supported_versions) {
2456 set_client(new MockableQuicClientThatDropsBody( 2466 set_client(new MockableQuicClientThatDropsBody(
2457 server_address, QuicServerId(server_hostname, server_address.port(), 2467 server_address,
2458 PRIVACY_MODE_DISABLED), 2468 QuicServerId(server_hostname, server_address.port(),
2469 PRIVACY_MODE_DISABLED),
2459 config, supported_versions, epoll_server())); 2470 config, supported_versions, epoll_server()));
2460 } 2471 }
2461 ~QuicTestClientThatDropsBody() override {} 2472 ~QuicTestClientThatDropsBody() override {}
2462 }; 2473 };
2463 2474
2464 TEST_P(EndToEndTest, EarlyResponseFinRecording) { 2475 TEST_P(EndToEndTest, EarlyResponseFinRecording) {
2465 set_smaller_flow_control_receive_window(); 2476 set_smaller_flow_control_receive_window();
2466 2477
2467 // Verify that an incoming FIN is recorded in a stream object even if the read 2478 // 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 2479 // 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. 2570 // Tell the client to not close the stream if it receives an early response.
2560 client_->set_allow_bidirectional_data(true); 2571 client_->set_allow_bidirectional_data(true);
2561 // Send the headers. 2572 // Send the headers.
2562 client_->SendMessage(headers, "", /*fin=*/false); 2573 client_->SendMessage(headers, "", /*fin=*/false);
2563 2574
2564 // Receive the response and let the server close writing. 2575 // Receive the response and let the server close writing.
2565 client_->WaitForInitialResponse(); 2576 client_->WaitForInitialResponse();
2566 EXPECT_EQ("500", client_->response_headers()->find(":status")->second); 2577 EXPECT_EQ("500", client_->response_headers()->find(":status")->second);
2567 2578
2568 // Receive the reset stream from server on early response. 2579 // Receive the reset stream from server on early response.
2569 QuicStream* stream = 2580 QuicStream* stream = client_->client()->session()->GetOrCreateStream(
2570 client_->client()->session()->GetOrCreateStream(kClientDataStreamId1); 2581 GetNthClientInitiatedId(0));
2571 // The stream is reset by server's reset stream. 2582 // The stream is reset by server's reset stream.
2572 EXPECT_EQ(stream, nullptr); 2583 EXPECT_EQ(stream, nullptr);
2573 } 2584 }
2574 2585
2575 TEST_P(EndToEndTest, Trailers) { 2586 TEST_P(EndToEndTest, Trailers) {
2576 // Test sending and receiving HTTP/2 Trailers (trailing HEADERS frames). 2587 // Test sending and receiving HTTP/2 Trailers (trailing HEADERS frames).
2577 ASSERT_TRUE(Initialize()); 2588 ASSERT_TRUE(Initialize());
2578 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); 2589 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2579 2590
2580 // Set reordering to ensure that Trailers arriving before body is ok. 2591 // 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(); 3120 client_->WaitForResponse();
3110 EXPECT_EQ(kBarResponseBody, client_->response_body()); 3121 EXPECT_EQ(kBarResponseBody, client_->response_body());
3111 QuicConnectionStats client_stats = 3122 QuicConnectionStats client_stats =
3112 client_->client()->session()->connection()->GetStats(); 3123 client_->client()->session()->connection()->GetStats();
3113 EXPECT_EQ(0u, client_stats.packets_lost); 3124 EXPECT_EQ(0u, client_stats.packets_lost);
3114 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); 3125 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos());
3115 } 3126 }
3116 } // namespace 3127 } // namespace
3117 } // namespace test 3128 } // namespace test
3118 } // namespace net 3129 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.cc ('k') | net/tools/quic/quic_client_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698