mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-09 20:42:44 +03:00
s/transportInfoCb/quicStats/g
Summary: rename test local variables to be self documenting Reviewed By: mjoras Differential Revision: D32750782 fbshipit-source-id: 94ff5bbd34dbc804cd0229d8abd0ffd9891a44fc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b3784b18e5
commit
21124bf671
@@ -155,7 +155,7 @@ class QuicTransportFunctionsTest : public Test {
|
||||
void SetUp() override {
|
||||
aead = test::createNoOpAead();
|
||||
headerCipher = test::createNoOpHeaderCipher();
|
||||
transportInfoCb_ = std::make_unique<NiceMock<MockQuicStats>>();
|
||||
quicStats_ = std::make_unique<NiceMock<MockQuicStats>>();
|
||||
}
|
||||
|
||||
std::unique_ptr<QuicServerConnectionState> createConn() {
|
||||
@@ -172,7 +172,7 @@ class QuicTransportFunctionsTest : public Test {
|
||||
kDefaultStreamWindowSize * 1000;
|
||||
conn->flowControlState.peerAdvertisedMaxOffset =
|
||||
kDefaultConnectionWindowSize * 1000;
|
||||
conn->statsCallback = transportInfoCb_.get();
|
||||
conn->statsCallback = quicStats_.get();
|
||||
conn->initialWriteCipher = createNoOpAead();
|
||||
conn->initialHeaderCipher = createNoOpHeaderCipher();
|
||||
conn->streamManager->setMaxLocalBidirectionalStreams(
|
||||
@@ -188,7 +188,7 @@ class QuicTransportFunctionsTest : public Test {
|
||||
|
||||
std::unique_ptr<Aead> aead;
|
||||
std::unique_ptr<PacketNumberCipher> headerCipher;
|
||||
std::unique_ptr<MockQuicStats> transportInfoCb_;
|
||||
std::unique_ptr<MockQuicStats> quicStats_;
|
||||
};
|
||||
|
||||
TEST_F(QuicTransportFunctionsTest, PingPacketGoesToOPList) {
|
||||
@@ -227,7 +227,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnection) {
|
||||
auto stream2 = conn->streamManager->findStream(stream2Id);
|
||||
|
||||
auto buf = IOBuf::copyBuffer("hey whats up");
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketRetransmission()).Times(2);
|
||||
EXPECT_CALL(*quicStats_, onPacketRetransmission()).Times(2);
|
||||
writeDataToQuicStream(*stream1, buf->clone(), true);
|
||||
writeDataToQuicStream(*stream2, buf->clone(), true);
|
||||
|
||||
@@ -1947,7 +1947,7 @@ TEST_F(QuicTransportFunctionsTest, WriteQuicDataToSocketWithCC) {
|
||||
return iobuf->computeChainDataLength();
|
||||
}));
|
||||
EXPECT_CALL(*rawCongestionController, onPacketSent(_)).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_));
|
||||
EXPECT_CALL(*quicStats_, onWrite(_));
|
||||
writeQuicDataToSocket(
|
||||
*rawSocket,
|
||||
*conn,
|
||||
@@ -1976,7 +1976,7 @@ TEST_F(QuicTransportFunctionsTest, WriteQuicdataToSocketWithPacer) {
|
||||
writeDataToQuicStream(*stream1, buf->clone(), true);
|
||||
|
||||
EXPECT_CALL(*rawPacer, onPacketSent()).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_));
|
||||
EXPECT_CALL(*quicStats_, onWrite(_));
|
||||
writeQuicDataToSocket(
|
||||
*rawSocket,
|
||||
*conn,
|
||||
@@ -2014,7 +2014,7 @@ TEST_F(QuicTransportFunctionsTest, WriteQuicDataToSocketLimitTest) {
|
||||
conn->transportSettings.writeConnectionDataPacketsLimit = 0;
|
||||
EXPECT_CALL(*rawSocket, write(_, _)).Times(0);
|
||||
EXPECT_CALL(*rawCongestionController, onPacketSent(_)).Times(0);
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_)).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onWrite(_)).Times(0);
|
||||
auto res = writeQuicDataToSocket(
|
||||
*rawSocket,
|
||||
*conn,
|
||||
@@ -2041,7 +2041,7 @@ TEST_F(QuicTransportFunctionsTest, WriteQuicDataToSocketLimitTest) {
|
||||
return iobuf->computeChainDataLength();
|
||||
}));
|
||||
EXPECT_CALL(*rawCongestionController, onPacketSent(_)).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_)).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onWrite(_)).Times(1);
|
||||
res = writeQuicDataToSocket(
|
||||
*rawSocket,
|
||||
*conn,
|
||||
@@ -2072,7 +2072,7 @@ TEST_F(QuicTransportFunctionsTest, WriteQuicDataToSocketLimitTest) {
|
||||
}));
|
||||
EXPECT_CALL(*rawCongestionController, onPacketSent(_))
|
||||
.Times(kDefaultWriteConnectionDataPacketLimit * 2);
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_))
|
||||
EXPECT_CALL(*quicStats_, onWrite(_))
|
||||
.Times(kDefaultWriteConnectionDataPacketLimit * 2);
|
||||
res = writeQuicDataToSocket(
|
||||
*rawSocket,
|
||||
@@ -2271,7 +2271,7 @@ TEST_F(QuicTransportFunctionsTest, WriteBlockedFrameWhenBlocked) {
|
||||
// Artificially Block the stream
|
||||
stream1->flowControlState.peerAdvertisedMaxOffset = 10;
|
||||
// writes blocked frame in additionally
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_)).Times(2);
|
||||
EXPECT_CALL(*quicStats_, onWrite(_)).Times(2);
|
||||
writeQuicDataToSocket(
|
||||
*rawSocket,
|
||||
*conn,
|
||||
@@ -2293,7 +2293,7 @@ TEST_F(QuicTransportFunctionsTest, WriteBlockedFrameWhenBlocked) {
|
||||
// Since everything is blocked, we shouldn't write a blocked again, so we
|
||||
// won't have any new packets to write if we trigger a write.
|
||||
auto previousPackets = conn->outstandings.packets.size();
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_)).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onWrite(_)).Times(0);
|
||||
writeQuicDataToSocket(
|
||||
*rawSocket,
|
||||
*conn,
|
||||
@@ -2668,7 +2668,7 @@ TEST_F(QuicTransportFunctionsTest, ShouldWriteDataTest) {
|
||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
|
||||
conn->oneRttWriteCipher = test::createNoOpAead();
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onCwndBlocked()).Times(0);
|
||||
EXPECT_NE(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
|
||||
auto stream1 = conn->streamManager->createNextBidirectionalStream().value();
|
||||
@@ -2690,11 +2690,11 @@ TEST_F(QuicTransportFunctionsTest, ShouldWriteDataTest) {
|
||||
// Congestion control
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes())
|
||||
.WillRepeatedly(Return(0));
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked());
|
||||
EXPECT_CALL(*quicStats_, onCwndBlocked());
|
||||
writeDataToQuicStream(*stream1, buf->clone(), true);
|
||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked());
|
||||
EXPECT_CALL(*quicStats_, onCwndBlocked());
|
||||
writeQuicDataToSocket(
|
||||
*rawSocket,
|
||||
*conn,
|
||||
@@ -2733,28 +2733,28 @@ TEST_F(QuicTransportFunctionsTest, ShouldWriteDataTestDuringPathValidation) {
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes()).WillOnce(Return(1));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _)).WillOnce(Return(1));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onCwndBlocked()).Times(0);
|
||||
EXPECT_NE(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
|
||||
// CC has writableBytes, but PathLimiter doesn't.
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes()).WillOnce(Return(1));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _)).WillOnce(Return(0));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked());
|
||||
EXPECT_CALL(*quicStats_, onCwndBlocked());
|
||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
|
||||
// PathLimiter has writableBytes, CC doesn't
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes()).WillOnce(Return(0));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _)).WillOnce(Return(1));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked());
|
||||
EXPECT_CALL(*quicStats_, onCwndBlocked());
|
||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
|
||||
// Neither PathLimiter or CC have writablebytes
|
||||
EXPECT_CALL(*rawCongestionController, getWritableBytes()).WillOnce(Return(0));
|
||||
EXPECT_CALL(*rawLimiter, currentCredit(_, _)).WillOnce(Return(0));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onCwndBlocked());
|
||||
EXPECT_CALL(*quicStats_, onCwndBlocked());
|
||||
EXPECT_EQ(WriteDataReason::NO_WRITE, shouldWriteData(*conn));
|
||||
}
|
||||
|
||||
|
@@ -23,12 +23,12 @@ namespace test {
|
||||
class QuicFlowControlTest : public Test {
|
||||
public:
|
||||
void SetUp() override {
|
||||
transportInfoCb_ = std::make_unique<MockQuicStats>();
|
||||
quicStats_ = std::make_unique<MockQuicStats>();
|
||||
conn_.streamManager = std::make_unique<QuicStreamManager>(
|
||||
conn_, conn_.nodeType, conn_.transportSettings);
|
||||
conn_.statsCallback = transportInfoCb_.get();
|
||||
conn_.statsCallback = quicStats_.get();
|
||||
}
|
||||
std::unique_ptr<MockQuicStats> transportInfoCb_;
|
||||
std::unique_ptr<MockQuicStats> quicStats_;
|
||||
QuicConnectionStateBase conn_{QuicNodeType::Client};
|
||||
};
|
||||
|
||||
@@ -38,13 +38,13 @@ TEST_F(QuicFlowControlTest, MaybeSendConnWindowUpdate) {
|
||||
conn_.flowControlState.sumCurReadOffset = 100;
|
||||
|
||||
// Should not send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlUpdate()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlUpdate()).Times(0);
|
||||
maybeSendConnWindowUpdate(conn_, Clock::now());
|
||||
EXPECT_FALSE(conn_.pendingEvents.connWindowUpdate);
|
||||
|
||||
conn_.flowControlState.sumCurReadOffset += 200;
|
||||
// Should send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlUpdate()).Times(1);
|
||||
maybeSendConnWindowUpdate(conn_, Clock::now());
|
||||
EXPECT_TRUE(conn_.pendingEvents.connWindowUpdate);
|
||||
}
|
||||
@@ -57,14 +57,14 @@ TEST_F(QuicFlowControlTest, MaybeSendConnWindowUpdateTimeElapsed) {
|
||||
conn_.lossState.srtt = 100us;
|
||||
conn_.flowControlState.timeOfLastFlowControlUpdate = Clock::now();
|
||||
// Should not send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlUpdate()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlUpdate()).Times(0);
|
||||
// less than 2rtt passes
|
||||
maybeSendConnWindowUpdate(
|
||||
conn_, *conn_.flowControlState.timeOfLastFlowControlUpdate + 100us);
|
||||
EXPECT_FALSE(conn_.pendingEvents.connWindowUpdate);
|
||||
|
||||
// Should send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlUpdate()).Times(1);
|
||||
|
||||
maybeSendConnWindowUpdate(
|
||||
conn_, *conn_.flowControlState.timeOfLastFlowControlUpdate + 300us);
|
||||
@@ -80,7 +80,7 @@ TEST_F(QuicFlowControlTest, DontSendConnFlowControlTwice) {
|
||||
conn_.flowControlState.timeOfLastFlowControlUpdate = Clock::now();
|
||||
|
||||
// Should send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlUpdate()).Times(1);
|
||||
maybeSendConnWindowUpdate(
|
||||
conn_, *conn_.flowControlState.timeOfLastFlowControlUpdate + 300us);
|
||||
EXPECT_TRUE(conn_.pendingEvents.connWindowUpdate);
|
||||
@@ -95,7 +95,7 @@ TEST_F(QuicFlowControlTest, NoStreamFlowControlUpdateOnTimeFlowUnchanged) {
|
||||
|
||||
conn_.lossState.srtt = 100us;
|
||||
conn_.flowControlState.timeOfLastFlowControlUpdate = Clock::now();
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlUpdate()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlUpdate()).Times(0);
|
||||
|
||||
maybeSendConnWindowUpdate(
|
||||
conn_, *conn_.flowControlState.timeOfLastFlowControlUpdate + 300us);
|
||||
@@ -109,7 +109,7 @@ TEST_F(QuicFlowControlTest, NoConnFlowControlUpdateOnTimeExpiredIfNotChanged) {
|
||||
|
||||
conn_.lossState.srtt = 100us;
|
||||
conn_.flowControlState.timeOfLastFlowControlUpdate = Clock::now();
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlUpdate()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlUpdate()).Times(0);
|
||||
|
||||
maybeSendConnWindowUpdate(
|
||||
conn_, *conn_.flowControlState.timeOfLastFlowControlUpdate + 300us);
|
||||
@@ -121,12 +121,12 @@ TEST_F(QuicFlowControlTest, MaybeSendConnWindowUpdateEnqueuesPendingEvent) {
|
||||
conn_.flowControlState.advertisedMaxOffset = 400;
|
||||
conn_.flowControlState.sumCurReadOffset = 301;
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlUpdate()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlUpdate()).Times(0);
|
||||
maybeSendConnWindowUpdate(conn_, Clock::now());
|
||||
EXPECT_FALSE(conn_.pendingEvents.connWindowUpdate);
|
||||
|
||||
conn_.flowControlState.windowSize = 500;
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlUpdate()).Times(1);
|
||||
maybeSendConnWindowUpdate(conn_, Clock::now());
|
||||
EXPECT_TRUE(conn_.pendingEvents.connWindowUpdate);
|
||||
}
|
||||
@@ -178,15 +178,15 @@ TEST_F(QuicFlowControlTest, MaybeSendStreamWindowUpdate) {
|
||||
stream.flowControlState.advertisedMaxOffset = 400;
|
||||
|
||||
// Should not send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlUpdate()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlUpdate()).Times(0);
|
||||
maybeSendStreamWindowUpdate(stream, Clock::now());
|
||||
EXPECT_FALSE(conn_.streamManager->pendingWindowUpdate(stream.id));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlUpdate()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlUpdate()).Times(0);
|
||||
maybeSendStreamWindowUpdate(stream, Clock::now());
|
||||
stream.currentReadOffset += 200;
|
||||
// Should send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlUpdate()).Times(1);
|
||||
maybeSendStreamWindowUpdate(stream, Clock::now());
|
||||
EXPECT_TRUE(conn_.streamManager->pendingWindowUpdate(stream.id));
|
||||
}
|
||||
@@ -202,12 +202,12 @@ TEST_F(QuicFlowControlTest, MaybeSendStreamWindowUpdateTimeElapsed) {
|
||||
stream.flowControlState.timeOfLastFlowControlUpdate = Clock::now();
|
||||
|
||||
// Should not send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlUpdate()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlUpdate()).Times(0);
|
||||
maybeSendStreamWindowUpdate(
|
||||
stream, *stream.flowControlState.timeOfLastFlowControlUpdate + 100us);
|
||||
EXPECT_FALSE(conn_.streamManager->pendingWindowUpdate(stream.id));
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlUpdate()).Times(1);
|
||||
maybeSendStreamWindowUpdate(
|
||||
stream, *stream.flowControlState.timeOfLastFlowControlUpdate + 300us);
|
||||
EXPECT_TRUE(conn_.streamManager->pendingWindowUpdate(stream.id));
|
||||
@@ -223,7 +223,7 @@ TEST_F(QuicFlowControlTest, DontSendStreamWindowUpdateTwice) {
|
||||
conn_.lossState.srtt = 100us;
|
||||
stream.flowControlState.timeOfLastFlowControlUpdate = Clock::now();
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlUpdate()).Times(1);
|
||||
maybeSendStreamWindowUpdate(
|
||||
stream, *stream.flowControlState.timeOfLastFlowControlUpdate + 300us);
|
||||
EXPECT_TRUE(conn_.streamManager->pendingWindowUpdate(stream.id));
|
||||
@@ -249,7 +249,7 @@ TEST_F(QuicFlowControlTest, MaybeSendStreamWindowUpdateChangeWindowSmaller) {
|
||||
stream.flowControlState.advertisedMaxOffset = 400;
|
||||
|
||||
// Should not send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlUpdate()).Times(1);
|
||||
maybeSendStreamWindowUpdate(stream, Clock::now());
|
||||
ASSERT_TRUE(conn_.streamManager->pendingWindowUpdate(stream.id));
|
||||
auto sendTime = Clock::now();
|
||||
@@ -261,7 +261,7 @@ TEST_F(QuicFlowControlTest, MaybeSendStreamWindowUpdateChangeWindowSmaller) {
|
||||
// window
|
||||
stream.currentReadOffset = stream.flowControlState.advertisedMaxOffset - 15;
|
||||
// Should send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlUpdate()).Times(1);
|
||||
maybeSendStreamWindowUpdate(stream, sendTime);
|
||||
EXPECT_FALSE(conn_.streamManager->pendingWindowUpdate(stream.id));
|
||||
|
||||
@@ -279,20 +279,20 @@ TEST_F(QuicFlowControlTest, MaybeWriteBlockedAfterAPIWrite) {
|
||||
stream.currentWriteOffset = 200;
|
||||
stream.flowControlState.peerAdvertisedMaxOffset = 400;
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlBlocked()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlBlocked()).Times(0);
|
||||
maybeWriteBlockAfterAPIWrite(stream);
|
||||
EXPECT_FALSE(conn_.streamManager->hasBlocked());
|
||||
|
||||
stream.currentWriteOffset = 400;
|
||||
stream.writeBuffer.append(IOBuf::copyBuffer("1234"));
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlBlocked()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlBlocked()).Times(0);
|
||||
maybeWriteBlockAfterAPIWrite(stream);
|
||||
EXPECT_FALSE(conn_.streamManager->hasBlocked());
|
||||
|
||||
stream.writeBuffer.move();
|
||||
stream.currentWriteOffset = 600;
|
||||
stream.flowControlState.peerAdvertisedMaxOffset = 600;
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlBlocked()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlBlocked()).Times(1);
|
||||
maybeWriteBlockAfterAPIWrite(stream);
|
||||
EXPECT_TRUE(conn_.streamManager->hasBlocked());
|
||||
}
|
||||
@@ -310,12 +310,12 @@ TEST_F(QuicFlowControlTest, MaybeWriteBlockedAfterSocketWrite) {
|
||||
// flow control limited.
|
||||
stream.currentWriteOffset = 400;
|
||||
maybeWriteBlockAfterSocketWrite(stream);
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlBlocked()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlBlocked()).Times(0);
|
||||
EXPECT_FALSE(conn_.streamManager->hasBlocked());
|
||||
|
||||
// Now write something
|
||||
stream.writeBuffer.append(IOBuf::copyBuffer("1234"));
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlBlocked()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlBlocked()).Times(1);
|
||||
maybeWriteBlockAfterSocketWrite(stream);
|
||||
EXPECT_TRUE(conn_.streamManager->hasBlocked());
|
||||
|
||||
@@ -337,7 +337,7 @@ TEST_F(QuicFlowControlTest, MaybeSendStreamWindowUpdateChangeWindowLarger) {
|
||||
stream.flowControlState.advertisedMaxOffset = 400;
|
||||
|
||||
// Should not send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlUpdate()).Times(1);
|
||||
maybeSendStreamWindowUpdate(stream, Clock::now());
|
||||
EXPECT_TRUE(conn_.streamManager->pendingWindowUpdate(stream.id));
|
||||
onStreamWindowUpdateSent(
|
||||
@@ -346,7 +346,7 @@ TEST_F(QuicFlowControlTest, MaybeSendStreamWindowUpdateChangeWindowLarger) {
|
||||
|
||||
stream.flowControlState.windowSize = 1001;
|
||||
// Should send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlUpdate()).Times(1);
|
||||
maybeSendStreamWindowUpdate(stream, Clock::now());
|
||||
EXPECT_EQ(
|
||||
generateMaxStreamDataFrame(stream).maximumData,
|
||||
@@ -359,7 +359,7 @@ TEST_F(QuicFlowControlTest, SendingConnectionWindowUpdate) {
|
||||
conn_.flowControlState.sumCurReadOffset = 300;
|
||||
|
||||
// Should send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlUpdate()).Times(1);
|
||||
maybeSendConnWindowUpdate(conn_, Clock::now());
|
||||
EXPECT_TRUE(conn_.pendingEvents.connWindowUpdate);
|
||||
auto frameOffset = generateMaxDataFrame(conn_).maximumData;
|
||||
@@ -381,7 +381,7 @@ TEST_F(QuicFlowControlTest, SendingStreamWindowUpdate) {
|
||||
stream.flowControlState.advertisedMaxOffset = 400;
|
||||
|
||||
// Should send window update
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlUpdate()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlUpdate()).Times(1);
|
||||
maybeSendStreamWindowUpdate(stream, Clock::now());
|
||||
EXPECT_TRUE(conn_.streamManager->pendingWindowUpdate(stream.id));
|
||||
auto frameOffset = generateMaxStreamDataFrame(stream).maximumData;
|
||||
@@ -579,8 +579,8 @@ TEST_F(QuicFlowControlTest, UpdateFlowControlOnRead) {
|
||||
conn_.flowControlState.windowSize = 500;
|
||||
conn_.flowControlState.advertisedMaxOffset = 400;
|
||||
conn_.flowControlState.sumCurReadOffset = 100;
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlUpdate());
|
||||
EXPECT_CALL(*transportInfoCb_, onStreamFlowControlUpdate());
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlUpdate());
|
||||
EXPECT_CALL(*quicStats_, onStreamFlowControlUpdate());
|
||||
updateFlowControlOnRead(stream, 100, Clock::now());
|
||||
EXPECT_EQ(conn_.flowControlState.sumCurReadOffset, 200);
|
||||
|
||||
@@ -602,10 +602,10 @@ TEST_F(QuicFlowControlTest, UpdateFlowControlOnWrite) {
|
||||
stream.flowControlState.peerAdvertisedMaxOffset = 300;
|
||||
|
||||
conn_.flowControlState.sumCurWriteOffset = 200;
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlBlocked()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlBlocked()).Times(0);
|
||||
updateFlowControlOnWriteToStream(stream, 100);
|
||||
EXPECT_EQ(conn_.flowControlState.sumCurStreamBufferLen, 100);
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlBlocked()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlBlocked()).Times(0);
|
||||
updateFlowControlOnWriteToSocket(stream, 100);
|
||||
EXPECT_EQ(conn_.flowControlState.sumCurWriteOffset, 300);
|
||||
EXPECT_EQ(conn_.flowControlState.sumCurStreamBufferLen, 0);
|
||||
@@ -613,11 +613,11 @@ TEST_F(QuicFlowControlTest, UpdateFlowControlOnWrite) {
|
||||
EXPECT_FALSE(conn_.streamManager->flowControlUpdatedContains(id));
|
||||
|
||||
stream.currentWriteOffset = 300;
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlBlocked()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlBlocked()).Times(0);
|
||||
updateFlowControlOnWriteToStream(stream, 100);
|
||||
EXPECT_EQ(conn_.flowControlState.sumCurStreamBufferLen, 100);
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlBlocked()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlBlocked()).Times(0);
|
||||
updateFlowControlOnWriteToSocket(stream, 100);
|
||||
EXPECT_EQ(conn_.flowControlState.sumCurStreamBufferLen, 0);
|
||||
EXPECT_EQ(conn_.flowControlState.sumCurWriteOffset, 400);
|
||||
@@ -626,7 +626,7 @@ TEST_F(QuicFlowControlTest, UpdateFlowControlOnWrite) {
|
||||
conn_.flowControlState.peerAdvertisedMaxOffset = 500;
|
||||
conn_.flowControlState.sumCurStreamBufferLen = 100;
|
||||
stream.flowControlState.peerAdvertisedMaxOffset = 600;
|
||||
EXPECT_CALL(*transportInfoCb_, onConnFlowControlBlocked()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onConnFlowControlBlocked()).Times(1);
|
||||
updateFlowControlOnWriteToSocket(stream, 100);
|
||||
}
|
||||
|
||||
|
@@ -75,7 +75,7 @@ class QuicLossFunctionsTest : public TestWithParam<PacketNumberSpace> {
|
||||
void SetUp() override {
|
||||
aead = createNoOpAead();
|
||||
headerCipher = createNoOpHeaderCipher();
|
||||
transportInfoCb_ = std::make_unique<MockQuicStats>();
|
||||
quicStats_ = std::make_unique<MockQuicStats>();
|
||||
connIdAlgo_ = std::make_unique<DefaultConnectionIdAlgo>();
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ class QuicLossFunctionsTest : public TestWithParam<PacketNumberSpace> {
|
||||
kDefaultMaxStreamsBidirectional);
|
||||
conn->streamManager->setMaxLocalUnidirectionalStreams(
|
||||
kDefaultMaxStreamsUnidirectional);
|
||||
conn->statsCallback = transportInfoCb_.get();
|
||||
conn->statsCallback = quicStats_.get();
|
||||
// create a serverConnectionId that is different from the client connId
|
||||
// with bits for processId and workerId set to 0
|
||||
ServerConnectionIdParams params(0, 0, 0);
|
||||
@@ -135,7 +135,7 @@ class QuicLossFunctionsTest : public TestWithParam<PacketNumberSpace> {
|
||||
kDefaultStreamWindowSize;
|
||||
conn->flowControlState.peerAdvertisedMaxOffset =
|
||||
kDefaultConnectionWindowSize;
|
||||
conn->statsCallback = transportInfoCb_.get();
|
||||
conn->statsCallback = quicStats_.get();
|
||||
// create a serverConnectionId that is different from the client connId
|
||||
// with bits for processId and workerId set to 0
|
||||
ServerConnectionIdParams params(0, 0, 0);
|
||||
@@ -151,7 +151,7 @@ class QuicLossFunctionsTest : public TestWithParam<PacketNumberSpace> {
|
||||
std::unique_ptr<Aead> aead;
|
||||
std::unique_ptr<PacketNumberCipher> headerCipher;
|
||||
MockLossTimeout timeout;
|
||||
std::unique_ptr<MockQuicStats> transportInfoCb_;
|
||||
std::unique_ptr<MockQuicStats> quicStats_;
|
||||
std::unique_ptr<ConnectionIdAlgo> connIdAlgo_;
|
||||
|
||||
auto getLossPacketMatcher(
|
||||
@@ -298,7 +298,7 @@ PacketNum QuicLossFunctionsTest::sendPacket(
|
||||
|
||||
TEST_F(QuicLossFunctionsTest, AllPacketsProcessed) {
|
||||
auto conn = createConn();
|
||||
EXPECT_CALL(*transportInfoCb_, onPTO()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onPTO()).Times(0);
|
||||
PacketEvent packetEvent1(
|
||||
PacketNumberSpace::AppData,
|
||||
conn->ackStates.appDataAckState.nextPacketNum);
|
||||
@@ -651,7 +651,7 @@ TEST_F(QuicLossFunctionsTest, TestOnLossDetectionAlarm) {
|
||||
MockClock::mockNow = []() { return TimePoint(123ms); };
|
||||
std::vector<PacketNum> lostPacket;
|
||||
MockClock::mockNow = []() { return TimePoint(23ms); };
|
||||
EXPECT_CALL(*transportInfoCb_, onPTO());
|
||||
EXPECT_CALL(*quicStats_, onPTO());
|
||||
setLossDetectionAlarm<decltype(timeout), MockClock>(*conn, timeout);
|
||||
EXPECT_EQ(LossState::AlarmMethod::PTO, conn->lossState.currentAlarmMethod);
|
||||
onLossDetectionAlarm<decltype(testingLossMarkFunc(lostPacket)), MockClock>(
|
||||
@@ -662,7 +662,7 @@ TEST_F(QuicLossFunctionsTest, TestOnLossDetectionAlarm) {
|
||||
EXPECT_TRUE(lostPacket.empty());
|
||||
|
||||
MockClock::mockNow = []() { return TimePoint(3ms); };
|
||||
EXPECT_CALL(*transportInfoCb_, onPTO());
|
||||
EXPECT_CALL(*quicStats_, onPTO());
|
||||
sendPacket(*conn, TimePoint(), folly::none, PacketType::OneRtt);
|
||||
setLossDetectionAlarm<decltype(timeout), MockClock>(*conn, timeout);
|
||||
EXPECT_CALL(*rawCongestionController, onPacketAckOrLoss(_, _)).Times(0);
|
||||
@@ -692,7 +692,7 @@ TEST_F(QuicLossFunctionsTest, TestOnPTOSkipProcessed) {
|
||||
EXPECT_EQ(10, conn->outstandings.packets.size());
|
||||
std::vector<PacketNum> lostPackets;
|
||||
EXPECT_CALL(*rawCongestionController, onRemoveBytesFromInflight(_)).Times(0);
|
||||
EXPECT_CALL(*transportInfoCb_, onPTO());
|
||||
EXPECT_CALL(*quicStats_, onPTO());
|
||||
onPTOAlarm(*conn);
|
||||
EXPECT_EQ(10, conn->outstandings.packets.size());
|
||||
EXPECT_TRUE(lostPackets.empty());
|
||||
@@ -702,7 +702,7 @@ TEST_F(QuicLossFunctionsTest, TestMarkPacketLoss) {
|
||||
folly::EventBase evb;
|
||||
MockAsyncUDPSocket socket(&evb);
|
||||
auto conn = createConn();
|
||||
EXPECT_CALL(*transportInfoCb_, onNewQuicStream()).Times(2);
|
||||
EXPECT_CALL(*quicStats_, onNewQuicStream()).Times(2);
|
||||
auto stream1Id =
|
||||
conn->streamManager->createNextBidirectionalStream().value()->id;
|
||||
auto stream2Id =
|
||||
@@ -749,7 +749,7 @@ TEST_F(QuicLossFunctionsTest, TestMarkPacketLossMerge) {
|
||||
folly::EventBase evb;
|
||||
MockAsyncUDPSocket socket(&evb);
|
||||
auto conn = createConn();
|
||||
EXPECT_CALL(*transportInfoCb_, onNewQuicStream()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onNewQuicStream()).Times(1);
|
||||
auto stream1Id =
|
||||
conn->streamManager->createNextBidirectionalStream().value()->id;
|
||||
auto stream1 = conn->streamManager->findStream(stream1Id);
|
||||
@@ -805,7 +805,7 @@ TEST_F(QuicLossFunctionsTest, TestMarkPacketLossNoMerge) {
|
||||
folly::EventBase evb;
|
||||
MockAsyncUDPSocket socket(&evb);
|
||||
auto conn = createConn();
|
||||
EXPECT_CALL(*transportInfoCb_, onNewQuicStream()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onNewQuicStream()).Times(1);
|
||||
auto stream1Id =
|
||||
conn->streamManager->createNextBidirectionalStream().value()->id;
|
||||
auto stream1 = conn->streamManager->findStream(stream1Id);
|
||||
@@ -1308,7 +1308,7 @@ TEST_F(QuicLossFunctionsTest, PTONoLongerMarksPacketsToBeRetransmitted) {
|
||||
startTime += 1ms;
|
||||
}
|
||||
EXPECT_CALL(*rawCongestionController, onPacketAckOrLoss(_, _)).Times(0);
|
||||
EXPECT_CALL(*transportInfoCb_, onPTO());
|
||||
EXPECT_CALL(*quicStats_, onPTO());
|
||||
onLossDetectionAlarm<decltype(testingLossMarkFunc(lostPackets)), MockClock>(
|
||||
*conn, testingLossMarkFunc(lostPackets));
|
||||
EXPECT_EQ(1, conn->lossState.ptoCount);
|
||||
@@ -1341,7 +1341,7 @@ TEST_F(QuicLossFunctionsTest, PTOWithHandshakePackets) {
|
||||
expectedLargestLostNum = std::max(
|
||||
expectedLargestLostNum, i % 2 ? sentPacketNum : expectedLargestLostNum);
|
||||
}
|
||||
EXPECT_CALL(*transportInfoCb_, onPTO());
|
||||
EXPECT_CALL(*quicStats_, onPTO());
|
||||
// Verify packet count doesn't change across PTO.
|
||||
auto originalPacketCount = conn->outstandings.packetCount;
|
||||
onLossDetectionAlarm<decltype(testingLossMarkFunc(lostPackets)), Clock>(
|
||||
@@ -1605,7 +1605,7 @@ TEST_F(QuicLossFunctionsTest, TestTotalPTOCount) {
|
||||
conn->qLogger = mockQLogger;
|
||||
conn->lossState.totalPTOCount = 100;
|
||||
EXPECT_CALL(*mockQLogger, addLossAlarm(0, 1, 0, kPtoAlarm));
|
||||
EXPECT_CALL(*transportInfoCb_, onPTO());
|
||||
EXPECT_CALL(*quicStats_, onPTO());
|
||||
onPTOAlarm(*conn);
|
||||
EXPECT_EQ(101, conn->lossState.totalPTOCount);
|
||||
}
|
||||
@@ -1618,7 +1618,7 @@ TEST_F(QuicLossFunctionsTest, TestExceedsMaxPTOThrows) {
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
EXPECT_CALL(*mockQLogger, addLossAlarm(0, i, 0, kPtoAlarm));
|
||||
}
|
||||
EXPECT_CALL(*transportInfoCb_, onPTO()).Times(3);
|
||||
EXPECT_CALL(*quicStats_, onPTO()).Times(3);
|
||||
onPTOAlarm(*conn);
|
||||
onPTOAlarm(*conn);
|
||||
EXPECT_THROW(onPTOAlarm(*conn), QuicInternalException);
|
||||
|
@@ -130,12 +130,12 @@ class QuicServerWorkerTest : public Test {
|
||||
socketPtr_ = sock.get();
|
||||
workerCb_ = std::make_shared<NiceMock<MockWorkerCallback>>();
|
||||
worker_ = std::make_unique<QuicServerWorker>(workerCb_);
|
||||
auto transportInfoCb = std::make_unique<NiceMock<MockQuicStats>>();
|
||||
auto quicStats = std::make_unique<NiceMock<MockQuicStats>>();
|
||||
TransportSettings settings;
|
||||
settings.statelessResetTokenSecret = getRandSecret();
|
||||
retryTokenSecret_ = getRandSecret();
|
||||
settings.retryTokenSecret = retryTokenSecret_;
|
||||
worker_->setTransportStatsCallback(std::move(transportInfoCb));
|
||||
worker_->setTransportStatsCallback(std::move(quicStats));
|
||||
worker_->setTransportSettings(settings);
|
||||
worker_->setSocket(std::move(sock));
|
||||
worker_->setWorkerId(42);
|
||||
@@ -144,7 +144,7 @@ class QuicServerWorkerTest : public Test {
|
||||
worker_->setConnectionIdAlgo(std::make_unique<DefaultConnectionIdAlgo>());
|
||||
worker_->setCongestionControllerFactory(
|
||||
std::make_shared<ServerCongestionControllerFactory>());
|
||||
transportInfoCb_ = (MockQuicStats*)worker_->getTransportStatsCallback();
|
||||
quicStats_ = (MockQuicStats*)worker_->getTransportStatsCallback();
|
||||
|
||||
auto cb = [&](const folly::SocketAddress& addr,
|
||||
std::unique_ptr<RoutingData>& routingData,
|
||||
@@ -222,7 +222,7 @@ class QuicServerWorkerTest : public Test {
|
||||
std::unique_ptr<MockQuicServerTransportFactory> factory_;
|
||||
std::unique_ptr<MockQuicUDPSocketFactory> listenerSocketFactory_;
|
||||
std::unique_ptr<MockQuicUDPSocketFactory> socketFactory_;
|
||||
MockQuicStats* transportInfoCb_{nullptr};
|
||||
MockQuicStats* quicStats_{nullptr};
|
||||
folly::test::MockAsyncUDPSocket* socketPtr_{nullptr};
|
||||
uint16_t hostId_{49};
|
||||
bool hasShutdown_{false};
|
||||
@@ -249,7 +249,7 @@ void QuicServerWorkerTest::expectConnectionCreation(
|
||||
}));
|
||||
EXPECT_CALL(*transport, setTransportSettings(_));
|
||||
EXPECT_CALL(*transport, accept());
|
||||
EXPECT_CALL(*transport, setTransportStatsCallback(transportInfoCb_));
|
||||
EXPECT_CALL(*transport, setTransportStatsCallback(quicStats_));
|
||||
}
|
||||
|
||||
void QuicServerWorkerTest::expectConnCreateRefused() {
|
||||
@@ -262,7 +262,7 @@ void QuicServerWorkerTest::expectConnCreateRefused() {
|
||||
EXPECT_CALL(*transport, setServerConnectionIdParams(_)).Times(0);
|
||||
EXPECT_CALL(*transport, setTransportSettings(_)).Times(0);
|
||||
EXPECT_CALL(*transport, accept()).Times(0);
|
||||
EXPECT_CALL(*transport, setTransportStatsCallback(transportInfoCb_)).Times(0);
|
||||
EXPECT_CALL(*transport, setTransportStatsCallback(quicStats_)).Times(0);
|
||||
EXPECT_CALL(*transport, onNetworkData(_, _)).Times(0);
|
||||
}
|
||||
|
||||
@@ -319,11 +319,11 @@ void QuicServerWorkerTest::testSendReset(
|
||||
ConnectionId,
|
||||
ShortHeader shortHeader,
|
||||
QuicTransportStatsCallback::PacketDropReason dropReason) {
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(dropReason)).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(dropReason)).Times(1);
|
||||
// should write reset packet
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_)).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketSent()).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onStatelessReset()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onWrite(_)).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onPacketSent()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onStatelessReset()).Times(1);
|
||||
|
||||
// verify that the packet that gets written is stateless reset packet
|
||||
EXPECT_CALL(*socketPtr_, write(_, _))
|
||||
@@ -371,9 +371,9 @@ std::string QuicServerWorkerTest::testSendRetry(
|
||||
// Retry packet will only be sent if rate-limiting is configured
|
||||
worker_->setRateLimiter(
|
||||
std::make_unique<SlidingWindowRateLimiter>([]() { return 0; }, 60s));
|
||||
EXPECT_CALL(*transportInfoCb_, onConnectionRateLimited()).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_)).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketSent()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onConnectionRateLimited()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onWrite(_)).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onPacketSent()).Times(1);
|
||||
|
||||
// Send a client inital to the server - the server will respond with retry
|
||||
// packet
|
||||
@@ -486,7 +486,7 @@ TEST_F(QuicServerWorkerTest, NoConnFoundTestReset) {
|
||||
TEST_F(QuicServerWorkerTest, RateLimit) {
|
||||
worker_->setRateLimiter(
|
||||
std::make_unique<SlidingWindowRateLimiter>([]() { return 2; }, 60s));
|
||||
EXPECT_CALL(*transportInfoCb_, onConnectionRateLimited()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onConnectionRateLimited()).Times(1);
|
||||
|
||||
NiceMock<MockConnectionCallback> connCb1;
|
||||
auto mockSock1 =
|
||||
@@ -582,8 +582,7 @@ TEST_F(QuicServerWorkerTest, TestRetryValidInitial) {
|
||||
TEST_F(QuicServerWorkerTest, TestRetryInvalidInitialClientIp) {
|
||||
// The second client initial packet with the retry token is invalid
|
||||
// as the client IP is different from the one stored in the retry token
|
||||
EXPECT_CALL(
|
||||
*transportInfoCb_, onPacketDropped(PacketDropReason::INVALID_PACKET))
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(PacketDropReason::INVALID_PACKET))
|
||||
.Times(1);
|
||||
auto dstConnId = getTestConnectionId(hostId_);
|
||||
auto srcConnId = getTestConnectionId(0);
|
||||
@@ -593,8 +592,7 @@ TEST_F(QuicServerWorkerTest, TestRetryInvalidInitialClientIp) {
|
||||
|
||||
TEST_F(QuicServerWorkerTest, TestRetryInvalidInitialDstConnId) {
|
||||
// Dest conn ID is invalid as it is different from the original dst conn ID
|
||||
EXPECT_CALL(
|
||||
*transportInfoCb_, onPacketDropped(PacketDropReason::INVALID_PACKET))
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(PacketDropReason::INVALID_PACKET))
|
||||
.Times(1);
|
||||
auto dstConnId = getTestConnectionId(hostId_);
|
||||
auto srcConnId = getTestConnectionId(0);
|
||||
@@ -657,7 +655,7 @@ TEST_F(QuicServerWorkerTest, QuicServerMultipleConnIdsRouting) {
|
||||
PacketNum num = 2;
|
||||
ShortHeader shortHeaderConnId(ProtectionType::KeyPhaseZero, connId, num);
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onNewConnection());
|
||||
EXPECT_CALL(*quicStats_, onNewConnection());
|
||||
transport_->QuicServerTransport::setRoutingCallback(worker_.get());
|
||||
worker_.get()->onConnectionIdAvailable(transport_, connId);
|
||||
const auto& connIdMap = worker_->getConnectionIdMap();
|
||||
@@ -701,7 +699,7 @@ TEST_F(QuicServerWorkerTest, QuicServerMultipleConnIdsRouting) {
|
||||
folly::none);
|
||||
eventbase_.loop();
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onConnectionClose(_)).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onConnectionClose(_)).Times(1);
|
||||
EXPECT_CALL(*transport_, setRoutingCallback(nullptr));
|
||||
worker_->onConnectionUnbound(
|
||||
transport_.get(),
|
||||
@@ -728,7 +726,7 @@ TEST_F(QuicServerWorkerTest, QuicServerNewConnection) {
|
||||
ProtectionType::KeyPhaseZero, getTestConnectionId(hostId_), num);
|
||||
|
||||
// Routing by connid before conn id available on a short packet.
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_)).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_)).Times(1);
|
||||
|
||||
RoutingData routingData(
|
||||
HeaderForm::Short,
|
||||
@@ -744,7 +742,7 @@ TEST_F(QuicServerWorkerTest, QuicServerNewConnection) {
|
||||
folly::none);
|
||||
eventbase_.loop();
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onNewConnection());
|
||||
EXPECT_CALL(*quicStats_, onNewConnection());
|
||||
ConnectionId newConnId = getTestConnectionId(hostId_);
|
||||
|
||||
transport_->QuicServerTransport::setRoutingCallback(worker_.get());
|
||||
@@ -797,7 +795,7 @@ TEST_F(QuicServerWorkerTest, QuicServerNewConnection) {
|
||||
ShortHeader shortHeaderConnId2(ProtectionType::KeyPhaseZero, connId2, num);
|
||||
|
||||
// Will be dropped
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_)).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_)).Times(1);
|
||||
RoutingData routingData3(
|
||||
HeaderForm::Short,
|
||||
false,
|
||||
@@ -812,7 +810,7 @@ TEST_F(QuicServerWorkerTest, QuicServerNewConnection) {
|
||||
folly::none);
|
||||
eventbase_.loop();
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onConnectionClose(_)).Times(2);
|
||||
EXPECT_CALL(*quicStats_, onConnectionClose(_)).Times(2);
|
||||
EXPECT_CALL(*transport_, setRoutingCallback(nullptr)).Times(2);
|
||||
worker_->onConnectionUnbound(
|
||||
transport_.get(),
|
||||
@@ -845,7 +843,7 @@ TEST_F(QuicServerWorkerTest, InitialPacketTooSmall) {
|
||||
num,
|
||||
version);
|
||||
EXPECT_CALL(*factory_, _make(_, _, _, _)).Times(0);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_));
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_));
|
||||
RoutingData routingData(
|
||||
HeaderForm::Long,
|
||||
true,
|
||||
@@ -864,8 +862,7 @@ TEST_F(QuicServerWorkerTest, InitialPacketTooSmall) {
|
||||
TEST_F(QuicServerWorkerTest, QuicShedTest) {
|
||||
auto connId = getTestConnectionId(hostId_);
|
||||
EXPECT_CALL(
|
||||
*transportInfoCb_,
|
||||
onPacketDropped(PacketDropReason::CANNOT_MAKE_TRANSPORT));
|
||||
*quicStats_, onPacketDropped(PacketDropReason::CANNOT_MAKE_TRANSPORT));
|
||||
createQuicConnectionDuringShedding(kClientAddr, connId);
|
||||
}
|
||||
|
||||
@@ -877,8 +874,7 @@ TEST_F(QuicServerWorkerTest, BlockedSourcePort) {
|
||||
PacketNum num = 1;
|
||||
QuicVersion version = QuicVersion::MVFST;
|
||||
LongHeader header(LongHeader::Types::Initial, connId, connId, num, version);
|
||||
EXPECT_CALL(
|
||||
*transportInfoCb_, onPacketDropped(PacketDropReason::INVALID_SRC_PORT));
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(PacketDropReason::INVALID_SRC_PORT));
|
||||
|
||||
RegularQuicPacketBuilder builder(
|
||||
kDefaultUDPSendPacketLen, std::move(header), 0 /* largestAcked */);
|
||||
@@ -897,7 +893,7 @@ TEST_F(QuicServerWorkerTest, ZeroLengthConnectionId) {
|
||||
PacketNum num = 1;
|
||||
QuicVersion version = QuicVersion::MVFST;
|
||||
LongHeader header(LongHeader::Types::Initial, connId, connId, num, version);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_)).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_)).Times(0);
|
||||
|
||||
RegularQuicPacketBuilder builder(
|
||||
kDefaultUDPSendPacketLen, std::move(header), 0 /* largestAcked */);
|
||||
@@ -921,7 +917,7 @@ TEST_F(QuicServerWorkerTest, ClientInitialCounting) {
|
||||
kDefaultUDPSendPacketLen, std::move(initialHeader), 0);
|
||||
initialBuilder.encodePacketHeader();
|
||||
auto initialPacket = packetToBuf(std::move(initialBuilder).buildPacket());
|
||||
EXPECT_CALL(*transportInfoCb_, onClientInitialReceived(QuicVersion::MVFST))
|
||||
EXPECT_CALL(*quicStats_, onClientInitialReceived(QuicVersion::MVFST))
|
||||
.Times(1);
|
||||
worker_->handleNetworkData(
|
||||
kClientAddr, std::move(initialPacket), Clock::now());
|
||||
@@ -936,7 +932,7 @@ TEST_F(QuicServerWorkerTest, ClientInitialCounting) {
|
||||
initialBuilderBigNum.encodePacketHeader();
|
||||
auto initialPacketBigNum =
|
||||
packetToBuf(std::move(initialBuilderBigNum).buildPacket());
|
||||
EXPECT_CALL(*transportInfoCb_, onClientInitialReceived(QuicVersion::MVFST))
|
||||
EXPECT_CALL(*quicStats_, onClientInitialReceived(QuicVersion::MVFST))
|
||||
.Times(1);
|
||||
worker_->handleNetworkData(
|
||||
kClientAddr, std::move(initialPacketBigNum), Clock::now());
|
||||
@@ -948,7 +944,7 @@ TEST_F(QuicServerWorkerTest, ClientInitialCounting) {
|
||||
kDefaultUDPSendPacketLen, std::move(handshakeHeader), 0);
|
||||
handshakeBuilder.encodePacketHeader();
|
||||
auto handshakePacket = packetToBuf(std::move(handshakeBuilder).buildPacket());
|
||||
EXPECT_CALL(*transportInfoCb_, onClientInitialReceived(_)).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onClientInitialReceived(_)).Times(0);
|
||||
worker_->handleNetworkData(
|
||||
kClientAddr, std::move(handshakePacket), Clock::now());
|
||||
eventbase_.loop();
|
||||
@@ -960,10 +956,10 @@ TEST_F(QuicServerWorkerTest, ConnectionIdTooShort) {
|
||||
PacketNum num = 1;
|
||||
QuicVersion version = QuicVersion::MVFST;
|
||||
LongHeader header(LongHeader::Types::Initial, connId, connId, num, version);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_)).Times(0);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketProcessed()).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketSent()).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_)).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_)).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onPacketProcessed()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onPacketSent()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onWrite(_)).Times(1);
|
||||
|
||||
RegularQuicPacketBuilder builder(
|
||||
kDefaultUDPSendPacketLen, std::move(header), 0 /* largestAcked */);
|
||||
@@ -1009,10 +1005,10 @@ TEST_F(QuicServerWorkerTest, FailToParseConnectionId) {
|
||||
EXPECT_CALL(*rawConnIdAlgo, parseConnectionId(dstConnId))
|
||||
.WillOnce(Return(folly::makeUnexpected(QuicInternalException(
|
||||
"This CID has COVID-19", LocalErrorCode::INTERNAL_ERROR))));
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_)).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketProcessed()).Times(0);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketSent()).Times(0);
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_)).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_)).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onPacketProcessed()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onPacketSent()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onWrite(_)).Times(0);
|
||||
worker_->dispatchPacketData(
|
||||
kClientAddr, std::move(routingData), std::move(networkData), version);
|
||||
eventbase_.loop();
|
||||
@@ -1026,10 +1022,10 @@ TEST_F(QuicServerWorkerTest, ConnectionIdTooShortDispatch) {
|
||||
QuicVersion version = QuicVersion::MVFST;
|
||||
LongHeader header(
|
||||
LongHeader::Types::Initial, srcConnId, dstConnId, num, version);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_)).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketProcessed()).Times(0);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketSent()).Times(0);
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_)).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_)).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onPacketProcessed()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onPacketSent()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onWrite(_)).Times(0);
|
||||
|
||||
RegularQuicPacketBuilder builder(
|
||||
kDefaultUDPSendPacketLen, std::move(header), 0 /* largestAcked */);
|
||||
@@ -1054,10 +1050,10 @@ TEST_F(QuicServerWorkerTest, ConnectionIdTooLargeDispatch) {
|
||||
QuicVersion version = QuicVersion::MVFST;
|
||||
LongHeader header(
|
||||
LongHeader::Types::Initial, srcConnId, dstConnId, num, version);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_)).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketProcessed()).Times(0);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketSent()).Times(0);
|
||||
EXPECT_CALL(*transportInfoCb_, onWrite(_)).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_)).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onPacketProcessed()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onPacketSent()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onWrite(_)).Times(0);
|
||||
|
||||
RegularQuicPacketBuilder builder(
|
||||
kDefaultUDPSendPacketLen, std::move(header), 0 /* largestAcked */);
|
||||
@@ -1078,12 +1074,12 @@ TEST_F(QuicServerWorkerTest, ShutdownQuicServer) {
|
||||
auto connId = getTestConnectionId(hostId_);
|
||||
createQuicConnection(kClientAddr, connId);
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onNewConnection());
|
||||
EXPECT_CALL(*quicStats_, onNewConnection());
|
||||
worker_->onConnectionIdAvailable(transport_, getTestConnectionId(hostId_));
|
||||
const auto& connIdMap = worker_->getConnectionIdMap();
|
||||
EXPECT_EQ(connIdMap.count(getTestConnectionId(hostId_)), 1);
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onConnectionClose(_));
|
||||
EXPECT_CALL(*quicStats_, onConnectionClose(_));
|
||||
EXPECT_CALL(*transport_, setRoutingCallback(nullptr)).Times(2);
|
||||
EXPECT_CALL(*transport_, setTransportStatsCallback(nullptr)).Times(2);
|
||||
EXPECT_CALL(*transport_, close(_)).WillRepeatedly(Invoke([this](auto) {
|
||||
@@ -1118,12 +1114,12 @@ TEST_F(QuicServerWorkerTest, DestroyQuicServer) {
|
||||
auto connId = getTestConnectionId(hostId_);
|
||||
createQuicConnection(kClientAddr, connId);
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onNewConnection());
|
||||
EXPECT_CALL(*quicStats_, onNewConnection());
|
||||
worker_->onConnectionIdAvailable(transport_, getTestConnectionId(hostId_));
|
||||
const auto& connIdMap = worker_->getConnectionIdMap();
|
||||
EXPECT_EQ(connIdMap.count(getTestConnectionId(hostId_)), 1);
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onConnectionClose(_));
|
||||
EXPECT_CALL(*quicStats_, onConnectionClose(_));
|
||||
EXPECT_CALL(*transport_, setRoutingCallback(nullptr)).Times(2);
|
||||
EXPECT_CALL(*transport_, setTransportStatsCallback(nullptr)).Times(2);
|
||||
EXPECT_CALL(*transport_, close(_)).WillRepeatedly(Invoke([this](auto) {
|
||||
@@ -1401,12 +1397,11 @@ class QuicServerWorkerTakeoverTest : public Test {
|
||||
takeoverSocketFactory_.get());
|
||||
factory_ = std::make_unique<MockQuicServerTransportFactory>();
|
||||
takeoverWorker_->setTransportFactory(factory_.get());
|
||||
auto transportInfoCb = std::make_unique<NiceMock<MockQuicStats>>();
|
||||
auto quicStats = std::make_unique<NiceMock<MockQuicStats>>();
|
||||
takeoverWorker_->setConnectionIdAlgo(
|
||||
std::make_unique<DefaultConnectionIdAlgo>());
|
||||
takeoverWorker_->setTransportStatsCallback(std::move(transportInfoCb));
|
||||
transportInfoCb_ =
|
||||
(MockQuicStats*)takeoverWorker_->getTransportStatsCallback();
|
||||
takeoverWorker_->setTransportStatsCallback(std::move(quicStats));
|
||||
quicStats_ = (MockQuicStats*)takeoverWorker_->getTransportStatsCallback();
|
||||
|
||||
auto takeoverSock =
|
||||
std::make_unique<NiceMock<folly::test::MockAsyncUDPSocket>>(&evb_);
|
||||
@@ -1430,7 +1425,7 @@ class QuicServerWorkerTakeoverTest : public Test {
|
||||
folly::SocketAddress clientAddr{kClientAddr};
|
||||
std::unique_ptr<MockQuicUDPSocketFactory> takeoverSocketFactory_;
|
||||
std::unique_ptr<MockQuicServerTransportFactory> factory_;
|
||||
MockQuicStats* transportInfoCb_{nullptr};
|
||||
MockQuicStats* quicStats_{nullptr};
|
||||
std::vector<QuicVersion> supportedVersions{QuicVersion::MVFST, MVFST1};
|
||||
uint16_t clientHostId_{25};
|
||||
};
|
||||
@@ -1517,9 +1512,9 @@ void QuicServerWorkerTakeoverTest::testNoPacketForwarding(
|
||||
};
|
||||
EXPECT_CALL(*takeoverWorkerCb_, routeDataToWorkerLong(_, _, _, _, _))
|
||||
.WillOnce(Invoke(cb));
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketReceived());
|
||||
EXPECT_CALL(*transportInfoCb_, onRead(len));
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketForwarded()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onPacketReceived());
|
||||
EXPECT_CALL(*quicStats_, onRead(len));
|
||||
EXPECT_CALL(*quicStats_, onPacketForwarded()).Times(0);
|
||||
takeoverWorker_->onDataAvailable(
|
||||
clientAddr, len, false, OnDataAvailableParams());
|
||||
}
|
||||
@@ -1623,9 +1618,9 @@ void QuicServerWorkerTakeoverTest::testPacketForwarding(
|
||||
};
|
||||
EXPECT_CALL(*takeoverWorkerCb_, routeDataToWorkerLong(_, _, _, _, _))
|
||||
.WillOnce(Invoke(cb));
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketReceived());
|
||||
EXPECT_CALL(*transportInfoCb_, onRead(len));
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketForwarded()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onPacketReceived());
|
||||
EXPECT_CALL(*quicStats_, onRead(len));
|
||||
EXPECT_CALL(*quicStats_, onPacketForwarded()).Times(1);
|
||||
takeoverWorker_->onDataAvailable(
|
||||
clientAddr, len, false, OnDataAvailableParams());
|
||||
takeoverWorker_->stopPacketForwarding();
|
||||
@@ -1710,11 +1705,11 @@ TEST_F(QuicServerWorkerTakeoverTest, QuicServerTakeoverProcessForwardedPkt) {
|
||||
};
|
||||
EXPECT_CALL(*takeoverWorkerCb_, routeDataToWorkerLong(_, _, _, _, _))
|
||||
.WillOnce(Invoke(workerCb));
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketReceived());
|
||||
EXPECT_CALL(*transportInfoCb_, onRead(len));
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketForwarded()).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onForwardedPacketReceived()).Times(1);
|
||||
EXPECT_CALL(*transportInfoCb_, onForwardedPacketProcessed()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onPacketReceived());
|
||||
EXPECT_CALL(*quicStats_, onRead(len));
|
||||
EXPECT_CALL(*quicStats_, onPacketForwarded()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onForwardedPacketReceived()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onForwardedPacketProcessed()).Times(1);
|
||||
takeoverWorker_->onDataAvailable(
|
||||
clientAddr, len, false, OnDataAvailableParams());
|
||||
// release this resource since MockQuicUDPSocketFactory::_make() hands its
|
||||
@@ -2156,9 +2151,9 @@ class QuicServerTakeoverTest : public Test {
|
||||
auto transportStatsFactory = std::make_unique<MockQuicStatsFactory>();
|
||||
auto makeCbForOldServer = [&]() {
|
||||
oldTransInfoCb_ = new NiceMock<MockQuicStats>();
|
||||
std::unique_ptr<MockQuicStats> transportInfoCb;
|
||||
transportInfoCb.reset(oldTransInfoCb_);
|
||||
return transportInfoCb;
|
||||
std::unique_ptr<MockQuicStats> quicStats;
|
||||
quicStats.reset(oldTransInfoCb_);
|
||||
return quicStats;
|
||||
};
|
||||
EXPECT_CALL(*transportStatsFactory, make())
|
||||
.WillOnce(Invoke(makeCbForOldServer));
|
||||
@@ -2197,9 +2192,9 @@ class QuicServerTakeoverTest : public Test {
|
||||
transportStatsFactory = std::make_unique<MockQuicStatsFactory>();
|
||||
auto makeCbForNewServer = [&]() {
|
||||
newTransInfoCb_ = new NiceMock<MockQuicStats>();
|
||||
std::unique_ptr<MockQuicStats> transportInfoCb;
|
||||
transportInfoCb.reset(newTransInfoCb_);
|
||||
return transportInfoCb;
|
||||
std::unique_ptr<MockQuicStats> quicStats;
|
||||
quicStats.reset(newTransInfoCb_);
|
||||
return quicStats;
|
||||
};
|
||||
EXPECT_CALL(*transportStatsFactory, make())
|
||||
.WillOnce(Invoke(makeCbForNewServer));
|
||||
|
@@ -176,8 +176,8 @@ class QuicServerTransportTest : public Test {
|
||||
server->setServerConnectionIdParams(params);
|
||||
server->getNonConstConn().transportSettings.statelessResetTokenSecret =
|
||||
getRandSecret();
|
||||
transportInfoCb_ = std::make_unique<NiceMock<MockQuicStats>>();
|
||||
server->setTransportStatsCallback(transportInfoCb_.get());
|
||||
quicStats_ = std::make_unique<NiceMock<MockQuicStats>>();
|
||||
server->setTransportStatsCallback(quicStats_.get());
|
||||
initializeServerHandshake();
|
||||
server->getNonConstConn().handshakeLayer.reset(fakeHandshake);
|
||||
server->getNonConstConn().serverHandshakeLayer = fakeHandshake;
|
||||
@@ -339,7 +339,7 @@ class QuicServerTransportTest : public Test {
|
||||
|
||||
virtual void setupConnection() {
|
||||
EXPECT_EQ(server->getConn().readCodec, nullptr);
|
||||
EXPECT_EQ(server->getConn().statsCallback, transportInfoCb_.get());
|
||||
EXPECT_EQ(server->getConn().statsCallback, quicStats_.get());
|
||||
setupClientReadCodec();
|
||||
recvClientHello();
|
||||
|
||||
@@ -548,7 +548,7 @@ class QuicServerTransportTest : public Test {
|
||||
std::shared_ptr<fizz::server::FizzServerContext> serverCtx;
|
||||
|
||||
std::vector<QuicVersion> supportedVersions;
|
||||
std::unique_ptr<MockQuicStats> transportInfoCb_;
|
||||
std::unique_ptr<MockQuicStats> quicStats_;
|
||||
std::unique_ptr<ConnectionIdAlgo> connIdAlgo_;
|
||||
std::shared_ptr<CongestionControllerFactory> ccFactory_;
|
||||
std::shared_ptr<TestingQuicServerTransport> server;
|
||||
@@ -612,7 +612,7 @@ TEST_F(QuicServerTransportTest, TestReadMultipleStreams) {
|
||||
server->getNonConstConn().ackStates.appDataAckState.largestRecvdPacketTime =
|
||||
folly::none;
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onNewQuicStream()).Times(2); // for x08, x0C
|
||||
EXPECT_CALL(*quicStats_, onNewQuicStream()).Times(2); // for x08, x0C
|
||||
deliverData(packetToBuf(packet));
|
||||
|
||||
EXPECT_TRUE(
|
||||
@@ -639,11 +639,11 @@ TEST_F(QuicServerTransportTest, TestReadMultipleStreams) {
|
||||
auto streamData2 = readDataFromQuicStream(*stream2);
|
||||
EXPECT_TRUE(eq(buf2, streamData2.first));
|
||||
EXPECT_TRUE(streamData2.second);
|
||||
EXPECT_CALL(*transportInfoCb_, onQuicStreamClosed()).Times(2);
|
||||
EXPECT_CALL(*quicStats_, onQuicStreamClosed()).Times(2);
|
||||
}
|
||||
|
||||
TEST_F(QuicServerTransportTest, TestInvalidServerStream) {
|
||||
EXPECT_CALL(*transportInfoCb_, onNewQuicStream()).Times(0);
|
||||
EXPECT_CALL(*quicStats_, onNewQuicStream()).Times(0);
|
||||
StreamId streamId = 0x01;
|
||||
auto data = IOBuf::copyBuffer("Aloha");
|
||||
EXPECT_THROW(recvEncryptedStream(streamId, *data), std::runtime_error);
|
||||
@@ -660,7 +660,7 @@ TEST_F(QuicServerTransportTest, TestInvalidServerStream) {
|
||||
}
|
||||
|
||||
TEST_F(QuicServerTransportTest, IdleTimerResetOnRecvNewData) {
|
||||
EXPECT_CALL(*transportInfoCb_, onNewQuicStream()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onNewQuicStream()).Times(1);
|
||||
StreamId streamId = server->createBidirectionalStream().value();
|
||||
auto expected = IOBuf::copyBuffer("hello");
|
||||
auto packet = packetToBuf(createStreamPacket(
|
||||
@@ -676,11 +676,11 @@ TEST_F(QuicServerTransportTest, IdleTimerResetOnRecvNewData) {
|
||||
ASSERT_FALSE(server->idleTimeout().isScheduled());
|
||||
recvEncryptedStream(streamId, *expected);
|
||||
ASSERT_TRUE(server->idleTimeout().isScheduled());
|
||||
EXPECT_CALL(*transportInfoCb_, onQuicStreamClosed());
|
||||
EXPECT_CALL(*quicStats_, onQuicStreamClosed());
|
||||
}
|
||||
|
||||
TEST_F(QuicServerTransportTest, IdleTimerNotResetOnDuplicatePacket) {
|
||||
EXPECT_CALL(*transportInfoCb_, onNewQuicStream()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onNewQuicStream()).Times(1);
|
||||
StreamId streamId = server->createBidirectionalStream().value();
|
||||
|
||||
auto expected = IOBuf::copyBuffer("hello");
|
||||
@@ -692,7 +692,7 @@ TEST_F(QuicServerTransportTest, IdleTimerNotResetOnDuplicatePacket) {
|
||||
// Try delivering the same packet again
|
||||
deliverData(packet->clone(), false);
|
||||
ASSERT_FALSE(server->idleTimeout().isScheduled());
|
||||
EXPECT_CALL(*transportInfoCb_, onQuicStreamClosed());
|
||||
EXPECT_CALL(*quicStats_, onQuicStreamClosed());
|
||||
}
|
||||
|
||||
TEST_F(QuicServerTransportTest, IdleTimerNotResetWhenDataOutstanding) {
|
||||
@@ -981,7 +981,7 @@ TEST_F(QuicServerTransportTest, ReceiveCloseAfterLocalError) {
|
||||
currLargestReceivedPacketNum);
|
||||
|
||||
// Deliver the same bad data again
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_));
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_));
|
||||
deliverDataWithoutErrorCheck(packetToBuf(packet));
|
||||
EXPECT_LT(
|
||||
server->getConn()
|
||||
@@ -3236,7 +3236,7 @@ TEST_F(QuicServerTransportTest, ReceiveDatagramFrameAndDiscard) {
|
||||
datagramPayload.size(), IOBuf::copyBuffer(datagramPayload));
|
||||
writeFrame(datagramFrame, builder);
|
||||
auto packet = std::move(builder).buildPacket();
|
||||
EXPECT_CALL(*transportInfoCb_, onDatagramDroppedOnRead()).Times(1);
|
||||
EXPECT_CALL(*quicStats_, onDatagramDroppedOnRead()).Times(1);
|
||||
deliverData(packetToBuf(packet));
|
||||
ASSERT_EQ(server->getConn().datagramState.readBuffer.size(), 0);
|
||||
}
|
||||
@@ -3246,9 +3246,9 @@ TEST_F(QuicServerTransportTest, ReceiveDatagramFrameAndStore) {
|
||||
conn.datagramState.maxReadFrameSize = std::numeric_limits<uint16_t>::max();
|
||||
conn.datagramState.maxReadBufferSize = 10;
|
||||
|
||||
EXPECT_CALL(*transportInfoCb_, onDatagramRead(_))
|
||||
EXPECT_CALL(*quicStats_, onDatagramRead(_))
|
||||
.Times(conn.datagramState.maxReadBufferSize);
|
||||
EXPECT_CALL(*transportInfoCb_, onDatagramDroppedOnRead())
|
||||
EXPECT_CALL(*quicStats_, onDatagramDroppedOnRead())
|
||||
.Times(conn.datagramState.maxReadBufferSize);
|
||||
for (uint64_t i = 0; i < conn.datagramState.maxReadBufferSize * 2; i++) {
|
||||
ShortHeader header(
|
||||
@@ -3470,7 +3470,7 @@ TEST_F(QuicUnencryptedServerTransportTest, TestBadPacketProtectionLevel) {
|
||||
getTestConnectionId(1) /* dest */,
|
||||
{QuicVersion::MVFST})
|
||||
.buildPacket();
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_));
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_));
|
||||
deliverData(packet.second->clone());
|
||||
}
|
||||
|
||||
@@ -3491,7 +3491,7 @@ TEST_F(QuicUnencryptedServerTransportTest, TestBadCleartextEncryption) {
|
||||
*aead,
|
||||
*getInitialHeaderCipher(),
|
||||
nextPacket);
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_));
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_));
|
||||
deliverData(std::move(packetData));
|
||||
// If crypto data was processed, we would have generated some writes.
|
||||
EXPECT_NE(server->getConn().readCodec, nullptr);
|
||||
@@ -3515,7 +3515,7 @@ TEST_F(QuicUnencryptedServerTransportTest, TestPendingZeroRttData) {
|
||||
0 /* cipherOverhead */,
|
||||
0 /* largestAcked */,
|
||||
std::make_pair(LongHeader::Types::ZeroRtt, QuicVersion::MVFST)));
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_));
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_));
|
||||
deliverData(std::move(packetData));
|
||||
}
|
||||
EXPECT_EQ(server->getConn().streamManager->streamCount(), 0);
|
||||
@@ -3541,7 +3541,7 @@ TEST_F(QuicUnencryptedServerTransportTest, TestPendingOneRttData) {
|
||||
*data,
|
||||
0 /* cipherOverhead */,
|
||||
0 /* largestAcked */));
|
||||
EXPECT_CALL(*transportInfoCb_, onPacketDropped(_));
|
||||
EXPECT_CALL(*quicStats_, onPacketDropped(_));
|
||||
deliverData(std::move(packetData));
|
||||
}
|
||||
EXPECT_EQ(server->getConn().streamManager->streamCount(), 0);
|
||||
|
Reference in New Issue
Block a user