Skip to content

Commit b7f468d

Browse files
KonradBreitsprecherBkdVJanKraemer
authored andcommitted
Modified Demos to trigger bug; Add integrationtest to trigger bug
Signed-off-by: Konrad Breitsprecher <Konrad.Breitsprecher@vector.com>
1 parent 5e0e8dc commit b7f468d

3 files changed

Lines changed: 85 additions & 3 deletions

File tree

SilKit/IntegrationTests/ITest_Internals_DataPubSub.cpp

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,4 +805,83 @@ TEST_F(ITest_Internals_DataPubSub, test_1pub_1sub_async_rejoin)
805805
ShutdownSystem();
806806
}
807807

808+
809+
// Two publishers (optional label1), one subscriber (optional label1, label2); publishers start first; subscriber joins
810+
TEST_F(ITest_Internals_DataPubSub, test_2pub_1sub_async_starting_order)
811+
{
812+
const uint32_t numMsgToPublish = 1;
813+
const uint32_t numMsgToReceive = 1 * numMsgToPublish;
814+
815+
std::vector<PubSubParticipant> publishers;
816+
publishers.push_back({"Pub1",
817+
{{"PubCtrl1",
818+
"TopicA",
819+
{"A"},
820+
{{"K1", "V1", SilKit::Services::MatchingLabel::Kind::Optional}},
821+
1,
822+
defaultMsgSize,
823+
numMsgToPublish}},
824+
{}});
825+
publishers.push_back({"Pub2",
826+
{{"PubCtrl1",
827+
"TopicA",
828+
{"A"},
829+
{{"K1", "V1", SilKit::Services::MatchingLabel::Kind::Optional}},
830+
1,
831+
defaultMsgSize,
832+
numMsgToPublish}},
833+
{}});
834+
835+
std::vector<PubSubParticipant> subscribers;
836+
std::vector<std::vector<uint8_t>> expectedDataUnordered;
837+
expectedDataUnordered.reserve(numMsgToReceive);
838+
for (uint32_t d = 0; d < numMsgToReceive; d++)
839+
{
840+
// Receive the same blob several times (once from every publisher)
841+
expectedDataUnordered.emplace_back(std::vector<uint8_t>(defaultMsgSize, 0));
842+
}
843+
subscribers.push_back(
844+
{"Sub1",
845+
{},
846+
{{
847+
"SubCtrl1",
848+
"TopicA",
849+
{"A"},
850+
{{"K1", "V1", SilKit::Services::MatchingLabel::Kind::Optional},
851+
{"K2", "V2", SilKit::Services::MatchingLabel::Kind::Optional}
852+
}, // BUGHUNT: Second label breaks communication
853+
defaultMsgSize,
854+
numMsgToReceive,
855+
1,
856+
expectedDataUnordered,
857+
}}});
858+
859+
for (auto& sub : subscribers)
860+
{
861+
sub.communicationTimeout = std::chrono::milliseconds(1000);
862+
}
863+
864+
_testSystem.SetupRegistryAndSystemMaster("silkit://localhost:0", false, {});
865+
866+
867+
//BUGHUNT: Subscribers start first fails SOMETIMES
868+
//RunParticipants(subscribers, _testSystem.GetRegistryUri(), false);
869+
870+
//BUGHUNT: Publishers start first fails ALWAYS
871+
872+
// Start publishers
873+
RunParticipants(publishers, _testSystem.GetRegistryUri(), false);
874+
for (auto& p : publishers)
875+
{
876+
p.WaitForAllSent();
877+
}
878+
879+
// Start subscriber
880+
RunParticipants(subscribers, _testSystem.GetRegistryUri(), false);
881+
882+
883+
JoinPubSubThreads();
884+
ShutdownSystem();
885+
}
886+
808887
} // anonymous namespace

SilKit/IntegrationTests/ITest_Internals_DataPubSub.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ class ITest_Internals_DataPubSub : public testing::Test
380380
participant.allSentPromise.set_value();
381381
}
382382

383-
if (!participant.dataSubscribers.empty())
383+
if (!participant.dataSubscribers.empty() && !participant.allReceived)
384384
{
385385
participant.WaitForAllReceived();
386386
}

SilKit/IntegrationTests/IntegrationTestInfrastructure.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ class TestInfrastructure
2525
{
2626
std::stringstream ss;
2727
ss << "Something went wrong: " << error.what() << std::endl;
28-
_systemMaster.systemController->AbortSimulation();
28+
if (_systemMaster.systemController)
29+
{
30+
_systemMaster.systemController->AbortSimulation();
31+
}
2932
FAIL() << ss.str();
3033
}
3134

@@ -127,7 +130,7 @@ class TestInfrastructure
127130
struct SystemMaster
128131
{
129132
std::unique_ptr<IParticipant> participant;
130-
SilKit::Experimental::Services::Orchestration::ISystemController* systemController;
133+
SilKit::Experimental::Services::Orchestration::ISystemController* systemController{nullptr};
131134
ISystemMonitor* systemMonitor;
132135
ILifecycleService* lifecycleService;
133136

0 commit comments

Comments
 (0)