mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-06 22:22:38 +03:00
Use Path Rate Limiter for conn migration
Summary: Use the Path rate limiter introduced in the previous diff. When we initialize path validation of an unvalidated peer address, enable pathValidationRateLimit. When we receive a proper PATH_RESPONSE frame, disable this limit. If this limit is enabled, we will check the pathValidationLimiter for the amount of bytes we are allowed to write. Change the migration tests in QuicServerTransportTest to use this new limiter instead of writableByteLimits. Update shouldWriteData to directly use the new congestionControlWritableBytes function. Reviewed By: yangchi Differential Revision: D18145774 fbshipit-source-id: 1fe4fd5be7486077c58b0d1285dfb03f6c62831c
This commit is contained in:
committed by
Facebook Github Bot
parent
b06a5e5923
commit
7504453972
@@ -1657,6 +1657,67 @@ TEST_F(QuicTransportFunctionsTest, ShouldWriteDataTest) {
|
||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
}
|
||||
|
||||
TEST_F(QuicTransportFunctionsTest, ShouldWriteDataTestDuringPathValidation) {
|
||||
auto conn = createConn();
|
||||
|
||||
// Create the CC.
|
||||
auto mockCongestionController = std::make_unique<MockCongestionController>();
|
||||
auto rawCongestionController = mockCongestionController.get();
|
||||
conn->congestionController = std::move(mockCongestionController);
|
||||
conn->oneRttWriteCipher = test::createNoOpAead();
|
||||
|
||||
// Create an outstandingPathValidation + limiter so this will be applied.
|
||||
auto pathValidationLimiter = std::make_unique<MockPendingPathRateLimiter>();
|
||||
MockPendingPathRateLimiter* rawLimiter = pathValidationLimiter.get();
|
||||
conn->pathValidationLimiter = std::move(pathValidationLimiter);
|
||||
conn->outstandingPathValidation = PathChallengeFrame(1000);
|
||||
|
||||
// Have stream data queued up during the test so there's something TO write.
|
||||
auto stream1 = conn->streamManager->createNextBidirectionalStream().value();
|
||||
auto buf = IOBuf::copyBuffer("0123456789");
|
||||
writeDataToQuicStream(*stream1, buf->clone(), false);
|
||||
|
||||
// shouldWriteData checks this first
|
||||
const size_t minimumDataSize = std::max(
|
||||
kLongHeaderHeaderSize + kCipherOverheadHeuristic, sizeof(Sample));
|
||||
|
||||
// Only case that we allow the write; both CC / PathLimiter have writablebytes
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillOnce(Return(minimumDataSize + 1));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _))
|
||||
.WillOnce(Return(minimumDataSize + 1));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked()).Times(0);
|
||||
EXPECT_NE(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
|
||||
// CC has writableBytes, but PathLimiter doesn't.
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillOnce(Return(minimumDataSize + 1));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _))
|
||||
.WillOnce(Return(minimumDataSize - 2));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked());
|
||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
|
||||
// PathLimiter has writableBytes, CC doesn't
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillOnce(Return(minimumDataSize - 1));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _))
|
||||
.WillOnce(Return(minimumDataSize + 1));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked());
|
||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
|
||||
// Neither PathLimiter or CC have writablebytes
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillOnce(Return(minimumDataSize - 1));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _))
|
||||
.WillOnce(Return(minimumDataSize - 1));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked());
|
||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
}
|
||||
|
||||
TEST_F(QuicTransportFunctionsTest, ShouldWriteStreamsNoCipher) {
|
||||
auto conn = createConn();
|
||||
auto mockCongestionController = std::make_unique<MockCongestionController>();
|
||||
|
Reference in New Issue
Block a user