Skip to content

Commit

Permalink
Deadline error when no Reliable DataReaders in VOLATILE DataWriters (#…
Browse files Browse the repository at this point in the history
…2112)

* Refs #12321: Change handle reference

Signed-off-by: jparisu <javierparis@eprosima.com>

* Refs #12321: Add regression tests

Signed-off-by: Eduardo Ponz Segrelles <eduardoponz@eprosima.com>

* Refs #12321: Make test more robust

Signed-off-by: Eduardo Ponz Segrelles <eduardoponz@eprosima.com>

* Refs 12321: Apply suggestions

Signed-off-by: Eduardo Ponz Segrelles <eduardoponz@eprosima.com>

Co-authored-by: Eduardo Ponz Segrelles <eduardoponz@eprosima.com>
  • Loading branch information
jparisu and EduPonz authored Aug 5, 2021
1 parent 9ca513c commit e357fe8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cpp/fastdds/publisher/DataWriterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ ReturnCode_t DataWriterImpl::perform_create_new_change(
if (qos_.deadline().period != c_TimeInfinite)
{
if (!history_.set_next_deadline(
ch->instanceHandle,
handle,
steady_clock::now() + duration_cast<system_clock::duration>(deadline_duration_us_)))
{
logError(PUBLISHER, "Could not set the next deadline in the history");
Expand Down
55 changes: 55 additions & 0 deletions test/blackbox/common/BlackboxTestsDeadlineQos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,61 @@ TEST_P(DeadlineQos, KeyedTopicShortDeadline)
EXPECT_GE(reader.missed_deadlines(), writer_samples);
}

/**
* This test creates a volatile writer with a deadline of 10 ms and no readers.
* The writer is used to send one sample, and after the deadline period has elapsed, a check is
* performed to verify that one offered deadline was missed.
*/
TEST_P(DeadlineQos, KeyedTopicNoReaderVolatileWriterSetDeadline)
{
PubSubWriter<KeyedHelloWorldType> writer(TEST_TOPIC_NAME);

writer.durability_kind(VOLATILE_DURABILITY_QOS);

uint32_t deadline_period_ms = 50;

writer.deadline_period(deadline_period_ms * 1e-3).init();
ASSERT_TRUE(writer.isInitialized());

auto data = default_keyedhelloworld_data_generator(1);

writer.send_sample(data.front());
std::this_thread::sleep_for(std::chrono::milliseconds(deadline_period_ms * 2));

EXPECT_GE(writer.missed_deadlines(), 1u);
}

/**
* This test creates a volatile writer with a deadline of 10 ms and a best effort reader.
* The writer is used to send one sample, and after the deadline period has elapsed, a check is
* performed to verify that one offered deadline was missed.
*/
TEST_P(DeadlineQos, KeyedTopicBestEffortReaderVolatileWriterSetDeadline)
{
PubSubWriter<KeyedHelloWorldType> writer(TEST_TOPIC_NAME);
PubSubReader<KeyedHelloWorldType> reader(TEST_TOPIC_NAME);

writer.durability_kind(VOLATILE_DURABILITY_QOS);

uint32_t deadline_period_ms = 50;

writer.deadline_period(deadline_period_ms * 1e-3).init();
reader.init();

ASSERT_TRUE(reader.isInitialized());
ASSERT_TRUE(writer.isInitialized());

writer.wait_discovery();
reader.wait_discovery();

auto data = default_keyedhelloworld_data_generator(1);

writer.send_sample(data.front());
std::this_thread::sleep_for(std::chrono::milliseconds(deadline_period_ms * 2));

EXPECT_GE(writer.missed_deadlines(), 1u);
}

#ifdef INSTANTIATE_TEST_SUITE_P
#define GTEST_INSTANTIATE_TEST_MACRO(x, y, z, w) INSTANTIATE_TEST_SUITE_P(x, y, z, w)
#else
Expand Down

0 comments on commit e357fe8

Please sign in to comment.