Skip to content

Commit 8f63449

Browse files
authored
Include all example tests in windows CI (#5851)
* Refs #22593: Add necesary CMake variables for configuring .compose test files, split configuration example and expose all example tests in windows Signed-off-by: Mario Dominguez <[email protected]> * Refs #22593: Add benchmark to windows ci Signed-off-by: Mario Dominguez <[email protected]> * Refs #22593: Add configuration example to windows ci Signed-off-by: Mario Dominguez <[email protected]> * Refs #22593: Add delivery_mechanisms* examples to windows ci Signed-off-by: Mario Dominguez <[email protected]> * Refs #22593: Add discovery_server example to windows ci Signed-off-by: Mario Dominguez <[email protected]> * Refs #22593: Add security example to windows ci Signed-off-by: Mario Dominguez <[email protected]> * Refs #22593: Add static_edp example to windows ci Signed-off-by: Mario Dominguez <[email protected]> * Refs #22593: Add topic_instances example to windows ci Signed-off-by: Mario Dominguez <[email protected]> * Refs #22593: Add xtypes examples to windows ci Signed-off-by: Mario Dominguez <[email protected]> * Refs #22593: Linter Signed-off-by: Mario Dominguez <[email protected]> * Refs #22593: Increase timeouts in configuration and delivery_mechanisms Signed-off-by: Mario Dominguez <[email protected]> * Refs #22593: Add random container ids to avoid collision when an attemp fails Signed-off-by: Mario Dominguez <[email protected]> * Refs #22593: Increase topic_instances timeout Signed-off-by: Mario Dominguez <[email protected]> --------- Signed-off-by: Mario Dominguez <[email protected]>
1 parent d1545d1 commit 8f63449

35 files changed

+1010
-454
lines changed

examples/cpp/benchmark/PublisherApp.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ PublisherApp::PublisherApp(
6868
, vSamples(0)
6969
, startTime(std::chrono::steady_clock::now())
7070
{
71-
7271
if (samples_ > 0)
7372
{
7473
timeout_ = 0;
@@ -507,6 +506,18 @@ bool PublisherApp::publish()
507506
throw std::runtime_error("Type invalid");
508507
}
509508
}
509+
510+
if (benchmark_.index() == 0u)
511+
{
512+
ReturnCode_t acked = RETCODE_ERROR;
513+
do
514+
{
515+
dds::Duration_t acked_wait{1, 0};
516+
acked = writer_->wait_for_acknowledgments(acked_wait);
517+
}
518+
while (acked != RETCODE_OK);
519+
}
520+
510521
return ret;
511522
}
512523

examples/cpp/configuration/CLIParser.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,8 @@ class CLIParser
10431043
try
10441044
{
10451045
int input = std::stoi(argv[i]);
1046-
if (static_cast<long>(input) < static_cast<long>(std::numeric_limits<uint32_t>::min()) ||
1047-
static_cast<long>(input) > static_cast<long>(std::numeric_limits<uint32_t>::max()))
1046+
if (input < 1 ||
1047+
static_cast<unsigned int>(input) > std::numeric_limits<uint32_t>::max())
10481048
{
10491049
throw std::out_of_range("ownership strength argument " + std::string(
10501050
argv[i]) + " out of range [0, " +

examples/cpp/delivery_mechanisms/CLIParser.hpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class CLIParser
6565
CLIParser::EntityKind entity = CLIParser::EntityKind::UNDEFINED;
6666
bool ignore_local_endpoints = false;
6767
uint16_t samples = 0;
68+
uint16_t matched = 1;
6869
uint32_t domain = 0;
6970
DeliveryMechanismKind delivery_mechanism = DeliveryMechanismKind::DEFAULT;
7071
std::string tcp_ip_address = "";
@@ -110,6 +111,8 @@ class CLIParser
110111
std::cout << " -s <num>, --samples <num> Number of samples to send or receive" << std::endl;
111112
std::cout << " [0 <= <num> <= 65535]" << std::endl;
112113
std::cout << " (Default: 0 [unlimited])" << std::endl;
114+
std::cout << " -m, --matched Number of participants to discover" << std::endl;
115+
std::cout << " before start publishing (Default: 1)" << std::endl;
113116
std::cout << "" << std::endl;
114117
std::cout << "\"pubsub\" options:" << std::endl;
115118
std::cout << " -i , --ignore-local-endpoints Avoid matching compatible datareaders and" << std::endl;
@@ -306,6 +309,10 @@ class CLIParser
306309
{
307310
config.delivery_mechanism = DeliveryMechanismKind::SHM;
308311
}
312+
else if (mechanism == "DEFAULT" || mechanism == "default")
313+
{
314+
config.delivery_mechanism = DeliveryMechanismKind::DEFAULT;
315+
}
309316
else
310317
{
311318
EPROSIMA_LOG_ERROR(CLI_PARSER, "parsing mechanism argument");
@@ -330,6 +337,41 @@ class CLIParser
330337
print_help(EXIT_FAILURE);
331338
}
332339
}
340+
else if (arg == "-m" || arg == "--matched")
341+
{
342+
try
343+
{
344+
int input = std::stoi(argv[++i]);
345+
if (input < std::numeric_limits<std::uint16_t>::min() ||
346+
input > std::numeric_limits<std::uint16_t>::max())
347+
{
348+
throw std::out_of_range("matched argument out of range");
349+
}
350+
else
351+
{
352+
if (config.entity == CLIParser::EntityKind::PUBLISHER ||
353+
config.entity == CLIParser::EntityKind::PUBSUB)
354+
{
355+
config.matched = static_cast<uint16_t>(input);
356+
}
357+
else
358+
{
359+
EPROSIMA_LOG_ERROR(CLI_PARSER, "matched can only be used with the publisher entity");
360+
print_help(EXIT_FAILURE);
361+
}
362+
}
363+
}
364+
catch (const std::invalid_argument& e)
365+
{
366+
EPROSIMA_LOG_ERROR(CLI_PARSER, "invalid sample argument for " + arg + ": " + e.what());
367+
print_help(EXIT_FAILURE);
368+
}
369+
catch (const std::out_of_range& e)
370+
{
371+
EPROSIMA_LOG_ERROR(CLI_PARSER, "sample argument out of range for " + arg + ": " + e.what());
372+
print_help(EXIT_FAILURE);
373+
}
374+
}
333375
else
334376
{
335377
EPROSIMA_LOG_ERROR(CLI_PARSER, "parsing argument: " + arg);

examples/cpp/delivery_mechanisms/PubSubApp.cpp

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ PubSubApp::PubSubApp(
6262
, writer_(nullptr)
6363
, type_(new DeliveryMechanismsPubSubType())
6464
, matched_(0)
65+
, expected_matches_(config.matched)
6566
, index_of_last_sample_sent_(0)
6667
, received_samples_(0)
6768
, samples_(config.samples)
@@ -291,13 +292,13 @@ void PubSubApp::on_publication_matched(
291292
{
292293
if (info.current_count_change == 1)
293294
{
294-
matched_ = info.current_count;
295+
matched_ = static_cast<int16_t>(info.current_count);
295296
std::cout << "Pub matched." << std::endl;
296297
cv_.notify_one();
297298
}
298299
else if (info.current_count_change == -1)
299300
{
300-
matched_ = info.current_count;
301+
matched_ = static_cast<int16_t>(info.current_count);
301302
std::cout << "Pub unmatched." << std::endl;
302303
}
303304
else
@@ -345,6 +346,10 @@ void PubSubApp::on_data_available(
345346
received_samples_++;
346347
std::cout << "Sample: '" << delivery_mechanisms_.message().data() << "' with index: '" <<
347348
delivery_mechanisms_.index() << "' RECEIVED" << std::endl;
349+
if ((samples_ > 0) && (received_samples_ >= samples_))
350+
{
351+
break;
352+
}
348353
}
349354
}
350355
reader->return_loan(delivery_mechanisms_sequence, info_sequence);
@@ -362,6 +367,32 @@ void PubSubApp::run()
362367
{
363368
std::cout << "Error sending sample with index: '" << index_of_last_sample_sent_ << "'" << std::endl;
364369
}
370+
371+
// Wait for acking the first sample
372+
if (index_of_last_sample_sent_ == 1u)
373+
{
374+
ReturnCode_t acked = RETCODE_ERROR;
375+
do
376+
{
377+
dds::Duration_t acked_wait{1, 0};
378+
acked = writer_->wait_for_acknowledgments(acked_wait);
379+
}
380+
while (acked != RETCODE_OK);
381+
}
382+
383+
#ifdef _WIN32
384+
// Wait for acking the last sample
385+
if (samples_ > 0 && index_of_last_sample_sent_ == samples_ - 1)
386+
{
387+
ReturnCode_t acked = RETCODE_ERROR;
388+
do
389+
{
390+
dds::Duration_t acked_wait{1, 0};
391+
acked = writer_->wait_for_acknowledgments(acked_wait);
392+
}
393+
while (acked != RETCODE_OK);
394+
}
395+
#endif // _WIN32
365396
}
366397

367398
// Wait for period or stop event
@@ -386,7 +417,7 @@ bool PubSubApp::publish()
386417
cv_.wait(matched_lock, [&]()
387418
{
388419
// at least one has been discovered
389-
return ((matched_ > 0) || is_stopped());
420+
return ((matched_ >= expected_matches_) || is_stopped());
390421
});
391422
void* sample_ = nullptr;
392423
if (!is_stopped() && (RETCODE_OK == writer_->loan_sample(sample_)))

examples/cpp/delivery_mechanisms/PubSubApp.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ class PubSubApp : public Application, public dds::DataReaderListener, public dds
9595

9696
std::condition_variable cv_;
9797

98-
int32_t matched_;
98+
int16_t matched_;
99+
100+
uint16_t expected_matches_;
99101

100102
std::mutex mutex_;
101103

examples/cpp/delivery_mechanisms/PublisherApp.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ PublisherApp::PublisherApp(
5555
, writer_(nullptr)
5656
, type_(new DeliveryMechanismsPubSubType())
5757
, matched_(0)
58+
, expected_matches_(config.matched)
5859
, index_of_last_sample_sent_(0)
5960
, samples_(config.samples)
6061
, stop_(false)
@@ -241,13 +242,13 @@ void PublisherApp::on_publication_matched(
241242
{
242243
if (info.current_count_change == 1)
243244
{
244-
matched_ = info.current_count;
245+
matched_ = static_cast<int16_t>(info.current_count);
245246
std::cout << "Publisher matched." << std::endl;
246247
cv_.notify_one();
247248
}
248249
else if (info.current_count_change == -1)
249250
{
250-
matched_ = info.current_count;
251+
matched_ = static_cast<int16_t>(info.current_count);
251252
std::cout << "Publisher unmatched." << std::endl;
252253
}
253254
else
@@ -265,6 +266,18 @@ void PublisherApp::run()
265266
{
266267
std::cout << "Error sending sample with index: '" << index_of_last_sample_sent_ << "'" << std::endl;
267268
}
269+
270+
if (index_of_last_sample_sent_ == 1u)
271+
{
272+
ReturnCode_t acked = RETCODE_ERROR;
273+
do
274+
{
275+
dds::Duration_t acked_wait{1, 0};
276+
acked = writer_->wait_for_acknowledgments(acked_wait);
277+
}
278+
while (acked != RETCODE_OK);
279+
}
280+
268281
// Wait for period or stop event
269282
std::unique_lock<std::mutex> terminate_lock(mutex_);
270283
cv_.wait_for(terminate_lock, std::chrono::milliseconds(period_ms_), [&]()
@@ -282,7 +295,7 @@ bool PublisherApp::publish()
282295
cv_.wait(matched_lock, [&]()
283296
{
284297
// at least one has been discovered
285-
return ((matched_ > 0) || is_stopped());
298+
return ((matched_ >= expected_matches_) || is_stopped());
286299
});
287300
void* sample_ = nullptr;
288301
if (!is_stopped() && (RETCODE_OK == writer_->loan_sample(sample_)))

examples/cpp/delivery_mechanisms/PublisherApp.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ class PublisherApp : public Application, public dds::DataWriterListener
7676

7777
std::condition_variable cv_;
7878

79-
int32_t matched_;
79+
int16_t matched_;
80+
81+
uint16_t expected_matches_;
8082

8183
std::mutex mutex_;
8284

examples/cpp/discovery_server/ClientPublisherApp.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,17 @@ void ClientPublisherApp::run()
247247
{
248248
std::cout << "Message: '" << hello_.message() << "' with index: '" << hello_.index()
249249
<< "' SENT" << std::endl;
250+
251+
if (hello_.index() == 1u)
252+
{
253+
ReturnCode_t acked = RETCODE_ERROR;
254+
do
255+
{
256+
dds::Duration_t acked_wait{1, 0};
257+
acked = writer_->wait_for_acknowledgments(acked_wait);
258+
}
259+
while (acked != RETCODE_OK);
260+
}
250261
}
251262
// Wait for period or stop event
252263
std::unique_lock<std::mutex> period_lock(mutex_);

examples/cpp/xtypes/CLIParser.hpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class CLIParser
4545
{
4646
CLIParser::EntityKind entity = CLIParser::EntityKind::UNDEFINED;
4747
uint16_t samples = 0;
48+
uint16_t matched = 1;
4849
bool use_xml = false;
4950
};
5051

@@ -74,6 +75,8 @@ class CLIParser
7475
std::cout << " The xml file to use must be set " << std::endl;
7576
std::cout << " through environment variable." << std::endl;
7677
std::cout << " (Default: Types defined with C++ API) " << std::endl;
78+
std::cout << " -m, --matched Number of participants to discover" << std::endl;
79+
std::cout << " before start publishing (Default: 1)" << std::endl;
7780
std::exit(return_code);
7881
}
7982

@@ -181,6 +184,40 @@ class CLIParser
181184
print_help(EXIT_FAILURE);
182185
}
183186
}
187+
else if (arg == "-m" || arg == "--matched")
188+
{
189+
try
190+
{
191+
int input = std::stoi(argv[++i]);
192+
if (input < std::numeric_limits<std::uint16_t>::min() ||
193+
input > std::numeric_limits<std::uint16_t>::max())
194+
{
195+
throw std::out_of_range("matched argument out of range");
196+
}
197+
else
198+
{
199+
if (config.entity == CLIParser::EntityKind::PUBLISHER)
200+
{
201+
config.matched = static_cast<uint16_t>(input);
202+
}
203+
else
204+
{
205+
EPROSIMA_LOG_ERROR(CLI_PARSER, "matched can only be used with the publisher entity");
206+
print_help(EXIT_FAILURE);
207+
}
208+
}
209+
}
210+
catch (const std::invalid_argument& e)
211+
{
212+
EPROSIMA_LOG_ERROR(CLI_PARSER, "invalid sample argument for " + arg + ": " + e.what());
213+
print_help(EXIT_FAILURE);
214+
}
215+
catch (const std::out_of_range& e)
216+
{
217+
EPROSIMA_LOG_ERROR(CLI_PARSER, "sample argument out of range for " + arg + ": " + e.what());
218+
print_help(EXIT_FAILURE);
219+
}
220+
}
184221

185222
else
186223
{

examples/cpp/xtypes/PublisherApp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ PublisherApp::PublisherApp(
5050
, writer_(nullptr)
5151
, matched_(0)
5252
, samples_(config.samples)
53+
, expected_matches_(config.matched)
5354
, stop_(false)
5455
{
5556
// Create the participant
@@ -203,7 +204,7 @@ bool PublisherApp::publish()
203204
cv_.wait(matched_lock, [&]()
204205
{
205206
// at least one has been discovered
206-
return ((matched_ > 0) || is_stopped());
207+
return ((matched_ >= expected_matches_) || is_stopped());
207208
});
208209

209210
if (!is_stopped())

0 commit comments

Comments
 (0)