@@ -32,19 +32,14 @@ using namespace SilKit::Services::Orchestration;
3232using namespace SilKit ::Config;
3333using namespace SilKit ::Services::PubSub;
3434
35- const std::string systemControllerParticipantName{ " systemControllerParticipant" } ;
36- const std::string topic{ " Topic" } ;
37- const std::string mediaType{ " A " } ;
35+ constexpr auto SYSTEM_CONTROLLER_PARTICIPANT_NAME = " systemControllerParticipant" ;
36+ constexpr auto PUBSUB_TOPIC = " Topic" ;
37+ constexpr auto PUBSUB_MEDIA_TYPE = " MediaType " ;
3838
39- std::atomic<bool > abortSystemControllerRequested{false };
39+ constexpr auto COMMUNICATION_TIMEOUT = 10000ms;
40+ constexpr auto ASYNC_DELAY_BETWEEN_PUBLICATION = 50ms;
4041
41- static size_t expectedReceptions = 0 ;
42- static size_t globalParticipantIndex = 0 ;
43-
44- static constexpr std::chrono::seconds TEST_TIMEOUT{20 };
45-
46- std::chrono::milliseconds communicationTimeout{10000ms};
47- std::chrono::milliseconds asyncDelayBetweenPublication{50ms};
42+ size_t globalParticipantIndex = 0 ;
4843
4944enum class TimeMode
5045{
@@ -131,7 +126,7 @@ class ITest_Internals_ParticipantModes : public testing::Test
131126
132127 void AwaitCommunication ()
133128 {
134- auto futureStatus = allReceivedPromise.get_future ().wait_for (communicationTimeout );
129+ auto futureStatus = allReceivedPromise.get_future ().wait_for (COMMUNICATION_TIMEOUT );
135130 if (futureStatus != std::future_status::ready)
136131 {
137132 FAIL () << " Test Failure: Awaiting test communication timed out" ;
@@ -140,7 +135,7 @@ class ITest_Internals_ParticipantModes : public testing::Test
140135
141136 void AwaitErrorState ()
142137 {
143- auto futureStatus = errorStatePromise.get_future ().wait_for (communicationTimeout );
138+ auto futureStatus = errorStatePromise.get_future ().wait_for (COMMUNICATION_TIMEOUT );
144139 if (futureStatus != std::future_status::ready)
145140 {
146141 FAIL () << " Test Failure: Awaiting error state timed out" ;
@@ -213,12 +208,12 @@ class ITest_Internals_ParticipantModes : public testing::Test
213208 timeSyncService = lifecycleService->CreateTimeSyncService ();
214209 }
215210
216- SilKit::Services::PubSub::PubSubSpec dataSpec{topic, mediaType };
217- SilKit::Services::PubSub::PubSubSpec matchingDataSpec{topic, mediaType };
211+ SilKit::Services::PubSub::PubSubSpec dataSpec{PUBSUB_TOPIC, PUBSUB_MEDIA_TYPE };
212+ SilKit::Services::PubSub::PubSubSpec matchingDataSpec{PUBSUB_TOPIC, PUBSUB_MEDIA_TYPE };
218213 auto publisher = participant->CreateDataPublisher (" TestPublisher" , dataSpec, 0 );
219214 participant->CreateDataSubscriber (
220215 " TestSubscriber" , matchingDataSpec,
221- [&testParticipant](IDataSubscriber* /* subscriber*/ , const DataMessageEvent& dataMessageEvent) {
216+ [&testParticipant, this ](IDataSubscriber* /* subscriber*/ , const DataMessageEvent& dataMessageEvent) {
222217 if (!testParticipant.i .allReceived )
223218 {
224219 auto participantId = dataMessageEvent.data [0 ];
@@ -258,7 +253,7 @@ class ITest_Internals_ParticipantModes : public testing::Test
258253 if (testParticipant.lifeCycleOperationMode != OperationMode::Invalid)
259254 {
260255 auto finalStateFuture = lifecycleService->StartLifecycle ();
261- finalStateFuture.wait_for (TEST_TIMEOUT );
256+ finalStateFuture.get ( );
262257 }
263258 }
264259
@@ -314,12 +309,12 @@ class ITest_Internals_ParticipantModes : public testing::Test
314309 }
315310 });
316311
317- SilKit::Services::PubSub::PubSubSpec dataSpec{topic, mediaType };
318- SilKit::Services::PubSub::PubSubSpec matchingDataSpec{topic, mediaType };
312+ SilKit::Services::PubSub::PubSubSpec dataSpec{PUBSUB_TOPIC, PUBSUB_MEDIA_TYPE };
313+ SilKit::Services::PubSub::PubSubSpec matchingDataSpec{PUBSUB_TOPIC, PUBSUB_MEDIA_TYPE };
319314 auto publisher = participant->CreateDataPublisher (" TestPublisher" , dataSpec, 0 );
320315 participant->CreateDataSubscriber (
321316 " TestSubscriber" , matchingDataSpec,
322- [&testParticipant](IDataSubscriber* /* subscriber*/ , const DataMessageEvent& dataMessageEvent) {
317+ [&testParticipant, this ](IDataSubscriber* /* subscriber*/ , const DataMessageEvent& dataMessageEvent) {
323318 if (!testParticipant.i .allReceived )
324319 {
325320 auto participantId = dataMessageEvent.data [0 ];
@@ -340,7 +335,7 @@ class ITest_Internals_ParticipantModes : public testing::Test
340335 while (!testParticipant.i .stopRequested )
341336 {
342337 publisher->Publish (std::vector<uint8_t >{testParticipant.id });
343- std::this_thread::sleep_for (asyncDelayBetweenPublication );
338+ std::this_thread::sleep_for (ASYNC_DELAY_BETWEEN_PUBLICATION );
344339 }
345340 testParticipant.simTaskFinishedPromise .set_value ();
346341 };
@@ -353,7 +348,7 @@ class ITest_Internals_ParticipantModes : public testing::Test
353348 {
354349 // Wait for ParticipantState::Running
355350 auto runningStateFutureStatus =
356- testParticipant.runningStatePromise .get_future ().wait_for (communicationTimeout );
351+ testParticipant.runningStatePromise .get_future ().wait_for (COMMUNICATION_TIMEOUT );
357352 if (runningStateFutureStatus != std::future_status::ready)
358353 {
359354 FAIL () << " Test Failure: Awaiting running state timed out" ;
@@ -366,12 +361,12 @@ class ITest_Internals_ParticipantModes : public testing::Test
366361
367362 // Wait for task to have received a stop request
368363 auto simTaskFinishedFuture = testParticipant.simTaskFinishedPromise .get_future ();
369- ( void ) simTaskFinishedFuture.wait_for (TEST_TIMEOUT );
364+ simTaskFinishedFuture.get ( );
370365
371366 // Stop the lifecycle
372367 lifecycleService->Stop (" End Test" );
373368
374- ( void ) finalStateFuture.wait_for (TEST_TIMEOUT );
369+ finalStateFuture.get ( );
375370
376371 if (runTaskThread.joinable ())
377372 {
@@ -397,7 +392,7 @@ class ITest_Internals_ParticipantModes : public testing::Test
397392 }
398393
399394 auto systemControllerParticipant =
400- SilKit::CreateParticipantImpl (config, systemControllerParticipantName , _registryUri);
395+ SilKit::CreateParticipantImpl (config, SYSTEM_CONTROLLER_PARTICIPANT_NAME , _registryUri);
401396
402397 auto participantInternal = dynamic_cast <SilKit::Core::IParticipantInternal*>(systemControllerParticipant.get ());
403398 auto systemController = participantInternal->GetSystemController ();
@@ -468,14 +463,14 @@ class ITest_Internals_ParticipantModes : public testing::Test
468463 };
469464 std::thread abortThread{waitForAbortTask};
470465 abortThread.detach ();
471- abortThreadDone.get_future ().wait_for (TEST_TIMEOUT );
466+ abortThreadDone.get_future ().get ( );
472467 if (abortThread.joinable ())
473468 {
474469 abortThread.join ();
475470 }
476471 abortSystemControllerRequested = false ;
477472
478- finalState.wait_for (TEST_TIMEOUT );
473+ finalState.get ( );
479474 }
480475
481476 void RunSystemController (const std::vector<std::string>& requiredParticipants)
@@ -487,7 +482,7 @@ class ITest_Internals_ParticipantModes : public testing::Test
487482 {
488483 required.push_back (p);
489484 }
490- required.push_back (systemControllerParticipantName );
485+ required.push_back (SYSTEM_CONTROLLER_PARTICIPANT_NAME );
491486
492487 participantThread_SystemController =
493488 ParticipantThread{[this , required] { SystemControllerParticipantThread (required); }};
@@ -497,7 +492,7 @@ class ITest_Internals_ParticipantModes : public testing::Test
497492 void AbortSystemController ()
498493 {
499494 abortSystemControllerRequested = true ;
500- participantThread_SystemController.shutdownFuture .wait_for (TEST_TIMEOUT );
495+ participantThread_SystemController.shutdownFuture .get ( );
501496 if (participantThread_SystemController.thread .joinable ())
502497 {
503498 participantThread_SystemController.thread .join ();
@@ -597,7 +592,7 @@ class ITest_Internals_ParticipantModes : public testing::Test
597592 {
598593 try
599594 {
600- ( void ) shutdownFuture.wait_for (TEST_TIMEOUT );
595+ shutdownFuture.wait ( );
601596 }
602597 catch (...)
603598 {
@@ -625,8 +620,6 @@ class ITest_Internals_ParticipantModes : public testing::Test
625620 {
626621 if (thread.shutdownFuture .valid ())
627622 {
628- auto && status = thread.shutdownFuture .wait_for (TEST_TIMEOUT);
629- ASSERT_EQ (status, std::future_status::ready); // signal failure
630623 thread.shutdownFuture .get ();
631624 }
632625 }
@@ -660,6 +653,9 @@ class ITest_Internals_ParticipantModes : public testing::Test
660653
661654 std::string _registryUri{" not yet defined" };
662655
656+ std::atomic<bool > abortSystemControllerRequested{false };
657+
658+ size_t expectedReceptions = 0 ;
663659};
664660
665661// --------------------------
0 commit comments