Skip to content

Commit a7f2258

Browse files
authored
Fix windows example tests in Debug and mitigate rtps example flakiness (#5744)
* Refs #22592: Fix windows Debug example tests Signed-off-by: Mario-DL <mariodominguez@eprosima.com> * Refs #22592: Initialize samples_received_ in rtps example ReaderApp Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> * Refs #22592: fix rtps example: Include a mechanism to ensure that the first sample is acked by all the matched readers and to prevent the next sample to piss it Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> * TODO: REMOVE THIS COMMIT. (Dis)Enable workflows for windows testing Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> * Revert "TODO: REMOVE THIS COMMIT. (Dis)Enable workflows for windows testing" This reverts commit 7c4b08c. Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> * Refs #22592: Apply Miguels rev Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> * Refs #22592: Decrease HB period for hello_world publisher Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> --------- Signed-off-by: Mario-DL <mariodominguez@eprosima.com> Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
1 parent f2e47da commit a7f2258

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

examples/cpp/hello_world/PublisherApp.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ PublisherApp::PublisherApp(
8585

8686
// Create the data writer
8787
DataWriterQos writer_qos = DATAWRITER_QOS_DEFAULT;
88+
writer_qos.history().depth = 5;
8889
publisher_->get_default_datawriter_qos(writer_qos);
8990
writer_ = publisher_->create_datawriter(topic_, writer_qos, this, StatusMask::all());
9091
if (writer_ == nullptr)
@@ -135,6 +136,17 @@ void PublisherApp::run()
135136
{
136137
std::cout << "Message: '" << hello_.message() << "' with index: '" << hello_.index()
137138
<< "' SENT" << std::endl;
139+
140+
if (hello_.index() == 1u)
141+
{
142+
ReturnCode_t acked = RETCODE_ERROR;
143+
do
144+
{
145+
dds::Duration_t acked_wait{1, 0};
146+
acked = writer_->wait_for_acknowledgments(acked_wait);
147+
}
148+
while (acked != RETCODE_OK);
149+
}
138150
}
139151
// Wait for period or stop event
140152
std::unique_lock<std::mutex> period_lock(mutex_);

examples/cpp/hello_world/hello_world_profile.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
<max_samples_per_instance>100</max_samples_per_instance>
2727
</resourceLimitsQos>
2828
</topic>
29+
<times>
30+
<heartbeat_period>
31+
<sec>0</sec>
32+
<nanosec>100000000</nanosec>
33+
</heartbeat_period>
34+
</times>
2935
</data_writer>
3036

3137
<data_reader profile_name="hello_world_datareader_profile" is_default_profile="true">

examples/cpp/rtps/ReaderApp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ ReaderApp::ReaderApp(
7878
const CLIParser::rtps_config& config,
7979
const std::string& topic_name)
8080
: samples_(config.samples)
81+
, samples_received_(0)
8182
, rtps_participant_(nullptr)
8283
, rtps_reader_(nullptr)
8384
, reader_history_(nullptr)

examples/cpp/rtps/WriterApp.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,17 @@ void WriterApp::run()
154154
std::cout << "Message " << data_->message() << " with index " << data_->index() << " SENT" << std::endl;
155155
}
156156

157+
if (data_->index() == 1u)
158+
{
159+
bool sample_acked = false;
160+
do
161+
{
162+
dds::Duration_t acked_wait{1, 0};
163+
sample_acked = rtps_writer_->wait_for_all_acked(acked_wait);
164+
}
165+
while (!sample_acked);
166+
}
167+
157168
// Wait for period or stop event
158169
std::unique_lock<std::mutex> period_lock(terminate_cv_mtx_);
159170
terminate_cv_.wait_for(period_lock, std::chrono::milliseconds(period_ms_), [&]()

test/examples/windows/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ RUN choco install -y vcredist140
1010

1111
# Install OpenSSL latest
1212
RUN choco install -y openssl
13+
14+
#Install Runtime Debug Libraries
15+
RUN choco install -y visualstudio2022buildtools --package-parameters '--includeRecommended --includeOptional --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.Component.VC.Runtime.UCRTSDK' --no-progress

0 commit comments

Comments
 (0)