Skip to content

[22592] Fix windows example tests in Debug and mitigate rtps example flakiness #5744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 7, 2025
12 changes: 12 additions & 0 deletions examples/cpp/hello_world/PublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ PublisherApp::PublisherApp(

// Create the data writer
DataWriterQos writer_qos = DATAWRITER_QOS_DEFAULT;
writer_qos.history().depth = 5;
publisher_->get_default_datawriter_qos(writer_qos);
writer_ = publisher_->create_datawriter(topic_, writer_qos, this, StatusMask::all());
if (writer_ == nullptr)
Expand Down Expand Up @@ -135,6 +136,17 @@ void PublisherApp::run()
{
std::cout << "Message: '" << hello_.message() << "' with index: '" << hello_.index()
<< "' SENT" << std::endl;

if (hello_.index() == 1u)
{
ReturnCode_t acked = RETCODE_ERROR;
do
{
dds::Duration_t acked_wait{1, 0};
acked = writer_->wait_for_acknowledgments(acked_wait);
}
while (acked != RETCODE_OK);
}
}
// Wait for period or stop event
std::unique_lock<std::mutex> period_lock(mutex_);
Expand Down
6 changes: 6 additions & 0 deletions examples/cpp/hello_world/hello_world_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<max_samples_per_instance>100</max_samples_per_instance>
</resourceLimitsQos>
</topic>
<times>
<heartbeat_period>
<sec>0</sec>
<nanosec>100000000</nanosec>
</heartbeat_period>
</times>
</data_writer>

<data_reader profile_name="hello_world_datareader_profile" is_default_profile="true">
Expand Down
1 change: 1 addition & 0 deletions examples/cpp/rtps/ReaderApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ ReaderApp::ReaderApp(
const CLIParser::rtps_config& config,
const std::string& topic_name)
: samples_(config.samples)
, samples_received_(0)
, rtps_participant_(nullptr)
, rtps_reader_(nullptr)
, reader_history_(nullptr)
Expand Down
11 changes: 11 additions & 0 deletions examples/cpp/rtps/WriterApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ void WriterApp::run()
std::cout << "Message " << data_->message() << " with index " << data_->index() << " SENT" << std::endl;
}

if (data_->index() == 1u)
{
bool sample_acked = false;
do
{
dds::Duration_t acked_wait{1, 0};
sample_acked = rtps_writer_->wait_for_all_acked(acked_wait);
}
while (!sample_acked);
}

// Wait for period or stop event
std::unique_lock<std::mutex> period_lock(terminate_cv_mtx_);
terminate_cv_.wait_for(period_lock, std::chrono::milliseconds(period_ms_), [&]()
Expand Down
3 changes: 3 additions & 0 deletions test/examples/windows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ RUN choco install -y vcredist140

# Install OpenSSL latest
RUN choco install -y openssl

#Install Runtime Debug Libraries
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
Loading