You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sc...@apache.org on 2019/01/28 10:11:13 UTC
[trafficserver] branch quic-latest updated: QUIC: Add retransmit
fin stream frame test and fixed test_QUICFrameRetransmitter
This is an automated email from the ASF dual-hosted git repository.
scw00 pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/quic-latest by this push:
new 46da77d QUIC: Add retransmit fin stream frame test and fixed test_QUICFrameRetransmitter
46da77d is described below
commit 46da77d330379bab623a373dc65851d855eb06fc
Author: scw00 <sc...@apache.org>
AuthorDate: Mon Jan 28 18:07:18 2019 +0800
QUIC: Add retransmit fin stream frame test and fixed test_QUICFrameRetransmitter
---
.../net/quic/test/test_QUICFrameRetransmitter.cc | 68 ++++++++++++++++++++--
1 file changed, 63 insertions(+), 5 deletions(-)
diff --git a/iocore/net/quic/test/test_QUICFrameRetransmitter.cc b/iocore/net/quic/test/test_QUICFrameRetransmitter.cc
index 6ea6b11..9dad813 100644
--- a/iocore/net/quic/test/test_QUICFrameRetransmitter.cc
+++ b/iocore/net/quic/test/test_QUICFrameRetransmitter.cc
@@ -25,7 +25,8 @@
#include "QUICFrameRetransmitter.h"
-constexpr static uint8_t data[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10};
+constexpr static uint8_t data[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x01, 0x02, 0x03, 0x04, 0x05,
+ 0x06, 0x07, 0x08, 0x09, 0x10, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10};
TEST_CASE("QUICFrameRetransmitter ignore frame which can not be retranmistted", "[quic]")
{
@@ -138,13 +139,13 @@ TEST_CASE("QUICFrameRetransmitter successfully split stream frame", "[quic]")
retransmitter.save_frame_info(std::move(info));
- auto frame = retransmitter.create_retransmitted_frame(QUICEncryptionLevel::INITIAL, 15);
+ auto frame = retransmitter.create_retransmitted_frame(QUICEncryptionLevel::INITIAL, 25);
CHECK(frame != nullptr);
CHECK(frame->type() == QUICFrameType::STREAM);
auto stream_frame = static_cast<QUICStreamFrame *>(frame.get());
CHECK(stream_frame->stream_id() == 0x12345);
CHECK(stream_frame->offset() == 0x67890);
- CHECK(stream_frame->size() <= 15);
+ CHECK(stream_frame->size() <= 25);
auto size = stream_frame->data_length();
CHECK(memcmp(stream_frame->data()->start(), data, stream_frame->data_length()) == 0);
@@ -191,12 +192,12 @@ TEST_CASE("QUICFrameRetransmitter successfully split crypto frame", "[quic]")
retransmitter.save_frame_info(std::move(info));
- auto frame = retransmitter.create_retransmitted_frame(QUICEncryptionLevel::INITIAL, 15);
+ auto frame = retransmitter.create_retransmitted_frame(QUICEncryptionLevel::INITIAL, 25);
CHECK(frame != nullptr);
CHECK(frame->type() == QUICFrameType::CRYPTO);
auto crypto_frame = static_cast<QUICCryptoFrame *>(frame.get());
CHECK(crypto_frame->offset() == 0x67890);
- CHECK(crypto_frame->size() <= 15);
+ CHECK(crypto_frame->size() <= 25);
auto size = crypto_frame->data_length();
CHECK(memcmp(crypto_frame->data()->start(), data, crypto_frame->data_length()) == 0);
@@ -222,3 +223,60 @@ TEST_CASE("QUICFrameRetransmitter successfully split crypto frame", "[quic]")
CHECK(block->refcount() == 1);
CHECK(block->data->refcount() == 1);
}
+
+TEST_CASE("QUICFrameRetransmitter successfully split stream frame with fin flag", "[quic]")
+{
+ QUICFrameRetransmitter retransmitter;
+ QUICFrameInformationUPtr info = QUICFrameInformationUPtr(quicFrameInformationAllocator.alloc());
+ info->type = QUICFrameType::STREAM;
+ info->level = QUICEncryptionLevel::INITIAL;
+
+ Ptr<IOBufferBlock> block = make_ptr<IOBufferBlock>(new_IOBufferBlock());
+ block->alloc();
+ memcpy(block->start(), data, sizeof(data));
+ block->fill(sizeof(data));
+
+ StreamFrameInfo *frame_info = reinterpret_cast<StreamFrameInfo *>(info->data);
+ frame_info->stream_id = 0x12345;
+ frame_info->offset = 0x67890;
+ frame_info->block = block;
+ frame_info->has_fin = true;
+ CHECK(block->refcount() == 2);
+
+ retransmitter.save_frame_info(std::move(info));
+
+ auto frame = retransmitter.create_retransmitted_frame(QUICEncryptionLevel::INITIAL, 25);
+ CHECK(frame != nullptr);
+ CHECK(frame->type() == QUICFrameType::STREAM);
+ auto stream_frame = static_cast<QUICStreamFrame *>(frame.get());
+ CHECK(stream_frame->stream_id() == 0x12345);
+ CHECK(stream_frame->offset() == 0x67890);
+ CHECK(stream_frame->size() <= 25);
+ CHECK(stream_frame->has_fin_flag() == false);
+
+ auto size = stream_frame->data_length();
+ CHECK(memcmp(stream_frame->data()->start(), data, stream_frame->data_length()) == 0);
+ // one for var block, one for the left data which saved in retransmitter
+ CHECK(block->data->refcount() == 2);
+ // one for var block, one for the left data which saved in retransmitter, one for var frame
+ CHECK(block->refcount() == 2);
+ frame = QUICFrameFactory::create_null_frame();
+ // one for var block, one for var info
+ CHECK(block->refcount() == 2);
+ CHECK(block->data->refcount() == 1);
+
+ frame = retransmitter.create_retransmitted_frame(QUICEncryptionLevel::INITIAL, UINT16_MAX);
+ CHECK(frame != nullptr);
+ CHECK(frame->type() == QUICFrameType::STREAM);
+ stream_frame = static_cast<QUICStreamFrame *>(frame.get());
+ CHECK(stream_frame->stream_id() == 0x12345);
+ CHECK(stream_frame->offset() == 0x67890 + size);
+ CHECK(stream_frame->data_length() == sizeof(data) - size);
+ CHECK(memcmp(stream_frame->data()->start(), data + size, stream_frame->data_length()) == 0);
+ CHECK(block->refcount() == 1); // one for var block
+ CHECK(stream_frame->has_fin_flag() == true);
+
+ frame = QUICFrameFactory::create_null_frame();
+ CHECK(block->refcount() == 1);
+ CHECK(block->data->refcount() == 1);
+}