src/net/third_party/quiche/src/quic/core/quic_connection_test.cc
// Includes regression test for b/69979024.
Includes regression test for b/69979024.
Includes regression test for b / 69979024 .
TEST_P(QuicConnectionTest, PathDegradingAlarmForNonCryptoPackets) {
  EXPECT_TRUE(connection_.connected());
  EXPECT_FALSE(connection_.PathDegradingDetectionInProgress());
  EXPECT_FALSE(connection_.IsPathDegrading());
  const char data[] = "data";
  size_t data_size = strlen(data);
  QuicStreamOffset offset = 0;
  for (int i = 0; i < 2; ++i) {
    connection_.SendStreamDataWithString(
        GetNthClientInitiatedStreamId(1, connection_.transport_version()), data,
        offset, NO_FIN);
    offset += data_size;
    EXPECT_TRUE(connection_.PathDegradingDetectionInProgress());
    QuicTime::Delta delay =
        QuicConnectionPeer::GetSentPacketManager(&connection_)
            ->GetPathDegradingDelay();
    if (GetQuicReloadableFlag(quic_use_blackhole_detector)) {
      EXPECT_EQ(delay, connection_.GetBlackholeDetectorAlarm()->deadline() -
                           clock_.ApproximateNow());
    } else {
      EXPECT_EQ(delay, connection_.GetPathDegradingAlarm()->deadline() -
                           clock_.ApproximateNow());
    }
    clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
    QuicTime prev_deadline = connection_.GetPathDegradingAlarm()->deadline();
    if (GetQuicReloadableFlag(quic_use_blackhole_detector)) {
      prev_deadline = connection_.GetBlackholeDetectorAlarm()->deadline();
    }
    connection_.SendStreamDataWithString(
        GetNthClientInitiatedStreamId(1, connection_.transport_version()), data,
        offset, NO_FIN);
    offset += data_size;
    EXPECT_TRUE(connection_.PathDegradingDetectionInProgress());
    if (GetQuicReloadableFlag(quic_use_blackhole_detector)) {
      EXPECT_EQ(prev_deadline,
                connection_.GetBlackholeDetectorAlarm()->deadline());
    } else {
      EXPECT_EQ(prev_deadline, connection_.GetPathDegradingAlarm()->deadline());
    }
    clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
    if (i == 0) {
      EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
    }
    EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _, _));
    QuicAckFrame frame = InitAckFrame(
        {{QuicPacketNumber(1u + 2u * i), QuicPacketNumber(2u + 2u * i)}});
    ProcessAckPacket(&frame);
    EXPECT_TRUE(connection_.PathDegradingDetectionInProgress());
    delay = QuicConnectionPeer::GetSentPacketManager(&connection_)
                ->GetPathDegradingDelay();
    if (GetQuicReloadableFlag(quic_use_blackhole_detector)) {
      EXPECT_EQ(delay, connection_.GetBlackholeDetectorAlarm()->deadline() -
                           clock_.ApproximateNow());
    } else {
      EXPECT_EQ(delay, connection_.GetPathDegradingAlarm()->deadline() -
                           clock_.ApproximateNow());
    }
    if (i == 0) {
      clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
      EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _, _));
      frame = InitAckFrame({{QuicPacketNumber(2), QuicPacketNumber(3)}});
      ProcessAckPacket(&frame);
      EXPECT_FALSE(connection_.PathDegradingDetectionInProgress());
    } else {
      clock_.AdvanceTime(delay);
      EXPECT_CALL(visitor_, OnPathDegrading());
      connection_.PathDegradingTimeout();
      EXPECT_FALSE(connection_.PathDegradingDetectionInProgress());
    }
  }
  EXPECT_TRUE(connection_.IsPathDegrading());
}
TEST_P ( QuicConnectionTest , PathDegradingAlarmForNonCryptoPackets ) { EXPECT_TRUE ( connection_ . connected ( ) ) ; EXPECT_FALSE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; EXPECT_FALSE ( connection_ . IsPathDegrading ( ) ) ; const char data [ ] = " " ; size_t data_size = strlen ( data ) ; QuicStreamOffset offset = 0 ; for ( int i = 0 ; i < 2 ; ++ i ) { connection_ . SendStreamDataWithString ( GetNthClientInitiatedStreamId ( 1 , connection_ . transport_version ( ) ) , data , offset , NO_FIN ) ; offset += data_size ; EXPECT_TRUE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; QuicTime :: Delta delay = QuicConnectionPeer :: GetSentPacketManager ( & connection_ ) -> GetPathDegradingDelay ( ) ; if ( GetQuicReloadableFlag ( quic_use_blackhole_detector ) ) { EXPECT_EQ ( delay , connection_ . GetBlackholeDetectorAlarm ( ) -> deadline ( ) - clock_ . ApproximateNow ( ) ) ; } else { EXPECT_EQ ( delay , connection_ . GetPathDegradingAlarm ( ) -> deadline ( ) - clock_ . ApproximateNow ( ) ) ; } clock_ . AdvanceTime ( QuicTime :: Delta :: FromMilliseconds ( 5 ) ) ; QuicTime prev_deadline = connection_ . GetPathDegradingAlarm ( ) -> deadline ( ) ; if ( GetQuicReloadableFlag ( quic_use_blackhole_detector ) ) { prev_deadline = connection_ . GetBlackholeDetectorAlarm ( ) -> deadline ( ) ; } connection_ . SendStreamDataWithString ( GetNthClientInitiatedStreamId ( 1 , connection_ . transport_version ( ) ) , data , offset , NO_FIN ) ; offset += data_size ; EXPECT_TRUE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; if ( GetQuicReloadableFlag ( quic_use_blackhole_detector ) ) { EXPECT_EQ ( prev_deadline , connection_ . GetBlackholeDetectorAlarm ( ) -> deadline ( ) ) ; } else { EXPECT_EQ ( prev_deadline , connection_ . GetPathDegradingAlarm ( ) -> deadline ( ) ) ; } clock_ . AdvanceTime ( QuicTime :: Delta :: FromMilliseconds ( 5 ) ) ; if ( i == 0 ) { EXPECT_CALL ( visitor_ , OnSuccessfulVersionNegotiation ( _ ) ) ; } EXPECT_CALL ( * send_algorithm_ , OnCongestionEvent ( true , _ , _ , _ , _ ) ) ; QuicAckFrame frame = InitAckFrame ( { { QuicPacketNumber ( 1u + 2u * i ) , QuicPacketNumber ( 2u + 2u * i ) } } ) ; ProcessAckPacket ( & frame ) ; EXPECT_TRUE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; delay = QuicConnectionPeer :: GetSentPacketManager ( & connection_ ) -> GetPathDegradingDelay ( ) ; if ( GetQuicReloadableFlag ( quic_use_blackhole_detector ) ) { EXPECT_EQ ( delay , connection_ . GetBlackholeDetectorAlarm ( ) -> deadline ( ) - clock_ . ApproximateNow ( ) ) ; } else { EXPECT_EQ ( delay , connection_ . GetPathDegradingAlarm ( ) -> deadline ( ) - clock_ . ApproximateNow ( ) ) ; } if ( i == 0 ) { clock_ . AdvanceTime ( QuicTime :: Delta :: FromMilliseconds ( 5 ) ) ; EXPECT_CALL ( * send_algorithm_ , OnCongestionEvent ( true , _ , _ , _ , _ ) ) ; frame = InitAckFrame ( { { QuicPacketNumber ( 2 ) , QuicPacketNumber ( 3 ) } } ) ; ProcessAckPacket ( & frame ) ; EXPECT_FALSE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; } else { clock_ . AdvanceTime ( delay ) ; EXPECT_CALL ( visitor_ , OnPathDegrading ( ) ) ; connection_ . PathDegradingTimeout ( ) ; EXPECT_FALSE ( connection_ . PathDegradingDetectionInProgress ( ) ) ; } } EXPECT_TRUE ( connection_ . IsPathDegrading ( ) ) ; }
Includes regression test for b/69979024.
Includes regression test for b / 69979024 .
// Send a packet. Now there's a retransmittable packet on the wire, so the // path degrading alarm should be set. // Check the deadline of the path degrading alarm. // Send a second packet. The path degrading alarm's deadline should remain // the same. // Regression test for b/69979024. // Now receive an ACK of the first packet. This should advance the path // degrading alarm's deadline since forward progress has been made. // Check the deadline of the path degrading alarm. // Now receive an ACK of the second packet. Since there are no more // retransmittable packets on the wire, this should cancel the path // degrading alarm. // Advance time to the path degrading alarm's deadline and simulate // firing the alarm.