This is an automated email from the ASF dual-hosted git repository.
maskit 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 22dfdfb Add tests for QUICStreamManager (total_offset_sent/received)
22dfdfb is described below
commit 22dfdfb3cf243377bf0ed864eee88ccb16b19a5e
Author: Masakazu Kitajo <[email protected]>
AuthorDate: Mon Sep 4 17:40:32 2017 +0900
Add tests for QUICStreamManager (total_offset_sent/received)
---
iocore/net/quic/Mock.h | 22 ++++++++-
iocore/net/quic/QUICApplication.cc | 2 +-
iocore/net/quic/QUICApplication.h | 2 +-
iocore/net/quic/QUICStreamManager.h | 3 --
iocore/net/quic/test/test_QUICStreamManager.cc | 66 ++++++++++++++++++++++++++
5 files changed, 89 insertions(+), 6 deletions(-)
diff --git a/iocore/net/quic/Mock.h b/iocore/net/quic/Mock.h
index 270b83b..46bb03d 100644
--- a/iocore/net/quic/Mock.h
+++ b/iocore/net/quic/Mock.h
@@ -348,7 +348,27 @@ private:
class MockQUICApplication : public QUICApplication
{
public:
- MockQUICApplication() : QUICApplication(new MockQUICConnection) {}
+ MockQUICApplication() : QUICApplication(new MockQUICConnection) {
+ SET_HANDLER(&MockQUICApplication::main_event_handler);
+ }
+
+ int
+ main_event_handler(int event, Event *data)
+ {
+ if (event == 12345) {
+ QUICStreamIO *stream_io = static_cast<QUICStreamIO *>(data->cookie);
+ stream_io->write_reenable();
+ }
+ return EVENT_CONT;
+ }
+
+ void
+ send(const uint8_t *data, size_t size, QUICStreamId stream_id)
+ {
+ QUICStreamIO *stream_io = this->_find_stream_io(stream_id);
+ stream_io->write(data, size);
+ eventProcessor.schedule_imm(this, ET_CALL, 12345, stream_io);
+ }
};
void NetVConnection::cancel_OOB(){};
diff --git a/iocore/net/quic/QUICApplication.cc
b/iocore/net/quic/QUICApplication.cc
index 3bd0d20..455459a 100644
--- a/iocore/net/quic/QUICApplication.cc
+++ b/iocore/net/quic/QUICApplication.cc
@@ -56,7 +56,7 @@ QUICStreamIO::read(uint8_t *buf, int64_t len)
}
int64_t
-QUICStreamIO::write(uint8_t *buf, int64_t len)
+QUICStreamIO::write(const uint8_t *buf, int64_t len)
{
SCOPED_MUTEX_LOCK(lock, this->_write_vio->mutex, this_ethread());
diff --git a/iocore/net/quic/QUICApplication.h
b/iocore/net/quic/QUICApplication.h
index 39c1974..25df608 100644
--- a/iocore/net/quic/QUICApplication.h
+++ b/iocore/net/quic/QUICApplication.h
@@ -41,7 +41,7 @@ public:
int64_t read_avail();
int64_t read(uint8_t *buf, int64_t len);
- int64_t write(uint8_t *buf, int64_t len);
+ int64_t write(const uint8_t *buf, int64_t len);
void read_reenable();
void write_reenable();
diff --git a/iocore/net/quic/QUICStreamManager.h
b/iocore/net/quic/QUICStreamManager.h
index 70af464..fd6412a 100644
--- a/iocore/net/quic/QUICStreamManager.h
+++ b/iocore/net/quic/QUICStreamManager.h
@@ -64,7 +64,4 @@ private:
QUICApplicationMap *_app_map = nullptr;
std::shared_ptr<const QUICTransportParameters> _local_tp = nullptr;
std::shared_ptr<const QUICTransportParameters> _remote_tp = nullptr;
-
- QUICMaximumData _recv_max_data = {0};
- QUICMaximumData _send_max_data = {0};
};
diff --git a/iocore/net/quic/test/test_QUICStreamManager.cc
b/iocore/net/quic/test/test_QUICStreamManager.cc
index 752859b..55f3a29 100644
--- a/iocore/net/quic/test/test_QUICStreamManager.cc
+++ b/iocore/net/quic/test/test_QUICStreamManager.cc
@@ -64,3 +64,69 @@ TEST_CASE("QUICStreamManager_NewStream", "[quic]")
sm.handle_frame(stream_blocked_frame);
CHECK(sm.stream_count() == 5);
}
+
+TEST_CASE("QUICStreamManager_total_offset_received", "[quic]")
+{
+ MockQUICFrameTransmitter tx;
+ QUICApplicationMap app_map;
+ MockQUICApplication mock_app;
+ app_map.set_default(&mock_app);
+ QUICStreamManager sm(&tx, &app_map);
+ std::shared_ptr<QUICTransportParameters> local_tp =
std::make_shared<QUICTransportParametersInEncryptedExtensions>();
+ local_tp->add(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA,
std::unique_ptr<QUICTransportParameterValue>(new
QUICTransportParameterValue(4096, 4)));
+ std::shared_ptr<QUICTransportParameters> remote_tp =
std::make_shared<QUICTransportParametersInClientHello>(static_cast<QUICVersion>(0),
static_cast<QUICVersion>(0));
+ sm.init_flow_control_params(local_tp, remote_tp);
+ uint8_t data[1024] = {0};
+
+ // Create a stream with STREAM_BLOCKED (== noop)
+ std::shared_ptr<QUICFrame> stream_blocked_frame_0 =
QUICFrameFactory::create_stream_blocked_frame(0);
+ std::shared_ptr<QUICFrame> stream_blocked_frame_1 =
QUICFrameFactory::create_stream_blocked_frame(1);
+ sm.handle_frame(stream_blocked_frame_0);
+ sm.handle_frame(stream_blocked_frame_1);
+ CHECK(sm.stream_count() == 2);
+ CHECK(sm.total_offset_received() == 0);
+
+ // Stream 0 shoud be out of flow control
+ std::shared_ptr<QUICFrame> stream_frame_0 =
QUICFrameFactory::create_stream_frame(data, 1024, 0, 0);
+ sm.handle_frame(stream_frame_0);
+ CHECK(sm.total_offset_received() == 0);
+
+ // total_offset should be a integer in unit of 1024 octets
+ std::shared_ptr<QUICFrame> stream_frame_1 =
QUICFrameFactory::create_stream_frame(data, 1024, 1, 0);
+ sm.handle_frame(stream_frame_1);
+ CHECK(sm.total_offset_received() == 1);
+}
+
+TEST_CASE("QUICStreamManager_total_offset_sent", "[quic]")
+{
+ MockQUICFrameTransmitter tx;
+ QUICApplicationMap app_map;
+ MockQUICApplication mock_app;
+ app_map.set_default(&mock_app);
+ QUICStreamManager sm(&tx, &app_map);
+ std::shared_ptr<QUICTransportParameters> local_tp =
std::make_shared<QUICTransportParametersInEncryptedExtensions>();
+ local_tp->add(QUICTransportParameterId::INITIAL_MAX_STREAM_DATA,
std::unique_ptr<QUICTransportParameterValue>(new
QUICTransportParameterValue(4096, 4)));
+ std::shared_ptr<QUICTransportParameters> remote_tp =
std::make_shared<QUICTransportParametersInClientHello>(static_cast<QUICVersion>(0),
static_cast<QUICVersion>(0));
+ sm.init_flow_control_params(local_tp, remote_tp);
+ uint8_t data[1024] = {0};
+
+ // Create a stream with STREAM_BLOCKED (== noop)
+ std::shared_ptr<QUICFrame> stream_frame_0_r =
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("abc"),
3, 0, 0);
+ std::shared_ptr<QUICFrame> stream_frame_1_r =
QUICFrameFactory::create_stream_frame(reinterpret_cast<const uint8_t *>("abc"),
3, 1, 0);
+ sm.handle_frame(stream_frame_0_r);
+ sm.handle_frame(stream_frame_1_r);
+ CHECK(sm.stream_count() == 2);
+ CHECK(sm.total_offset_sent() == 0);
+
+ // Stream 0 shoud be out of flow control
+ std::unique_ptr<QUICFrame, QUICFrameDeleterFunc> stream_frame_0 =
QUICFrameFactory::create_stream_frame(data, 1024, 0, 0);
+ mock_app.send(data, 1024, 0);
+ sleep(2);
+ CHECK(sm.total_offset_sent() == 0);
+
+ // total_offset should be a integer in unit of 1024 octets
+ std::unique_ptr<QUICFrame, QUICFrameDeleterFunc> stream_frame_1 =
QUICFrameFactory::create_stream_frame(data, 1024, 1, 0);
+ mock_app.send(data, 1024, 1);
+ sleep(2);
+ CHECK(sm.total_offset_sent() == 1);
+}
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].