Skip to content

Commit

Permalink
Test with and without topic statistics
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Jan 29, 2024
1 parent 5887c99 commit 5efc81c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ TEST(twoProcPubSub, PubSubTwoProcsTwoNodesSubscriber)
//////////////////////////////////////////////////
int main(int argc, char **argv)
{
gz::utils::setenv("GZ_TRANSPORT_TOPIC_STATISTICS", "1");
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
38 changes: 25 additions & 13 deletions test/integration/twoProcsPubSub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@

using namespace gz;

using twoProcPubSub = testing::PartitionedTransportTest;
class twoProcPubSub: public testing::PartitionedTransportTest,
public testing::WithParamInterface<bool>
{
protected: void SetUp() override {
testing::PartitionedTransportTest::SetUp();
gz::utils::setenv("GZ_TRANSPORT_TOPIC_STATISTICS",
GetParam() ? "1" : "0");
}
};

static std::string g_FQNPartition; // NOLINT(*)
static const std::string g_topic = "/foo"; // NOLINT(*)
Expand Down Expand Up @@ -106,7 +114,7 @@ void cbRaw(const char * /*_msgData*/, const size_t /*_size*/,
/// subscriber process there are two nodes. Both should receive the message.
/// After some time one of them unsubscribe. After that check that only one
/// node receives the message.
TEST_F(twoProcPubSub, PubSubTwoProcsThreeNodes)
TEST_P(twoProcPubSub, PubSubTwoProcsThreeNodes)
{
transport::Node node;
auto pub = node.Advertise<msgs::Vector3d>(g_topic);
Expand Down Expand Up @@ -138,7 +146,7 @@ TEST_F(twoProcPubSub, PubSubTwoProcsThreeNodes)
//////////////////////////////////////////////////
/// \brief This is the same as the last test, but we use PublishRaw(~) instead
/// of Publish(~).
TEST_F(twoProcPubSub, RawPubSubTwoProcsThreeNodes)
TEST_P(twoProcPubSub, RawPubSubTwoProcsThreeNodes)
{
transport::Node node;
auto pub = node.Advertise<msgs::Vector3d>(g_topic);
Expand Down Expand Up @@ -173,7 +181,7 @@ TEST_F(twoProcPubSub, RawPubSubTwoProcsThreeNodes)
//////////////////////////////////////////////////
/// \brief Check that a message is not received if the callback does not use
/// the advertised types.
TEST_F(twoProcPubSub, PubSubWrongTypesOnSubscription)
TEST_P(twoProcPubSub, PubSubWrongTypesOnSubscription)
{
this->SpawnSubprocess({test_executables::kTwoProcsPublisher});

Expand All @@ -193,7 +201,7 @@ TEST_F(twoProcPubSub, PubSubWrongTypesOnSubscription)

//////////////////////////////////////////////////
/// \brief Same as above, but using a raw subscription.
TEST_F(twoProcPubSub, PubRawSubWrongTypesOnSubscription)
TEST_P(twoProcPubSub, PubRawSubWrongTypesOnSubscription)
{
this->SpawnSubprocess({test_executables::kTwoProcsPublisher});

Expand All @@ -218,7 +226,7 @@ TEST_F(twoProcPubSub, PubRawSubWrongTypesOnSubscription)
/// advertised type). The second subscriber uses the correct callback. The third
/// uses a generic callback. Check that only two of the callbacks are executed
/// (correct and generic).
TEST_F(twoProcPubSub, PubSubWrongTypesTwoSubscribers)
TEST_P(twoProcPubSub, PubSubWrongTypesTwoSubscribers)
{
this->SpawnSubprocess({test_executables::kTwoProcsPublisher});

Expand Down Expand Up @@ -250,7 +258,7 @@ TEST_F(twoProcPubSub, PubSubWrongTypesTwoSubscribers)
/// match the advertised type). The second subscriber requests the correct type.
/// The third accepts the generic (default) type. Check that only two of the
/// callbacks are executed (correct and generic).
TEST_F(twoProcPubSub, PubSubWrongTypesTwoRawSubscribers)
TEST_P(twoProcPubSub, PubSubWrongTypesTwoRawSubscribers)
{
this->SpawnSubprocess({test_executables::kTwoProcsPublisher});

Expand Down Expand Up @@ -306,7 +314,7 @@ TEST_F(twoProcPubSub, PubSubWrongTypesTwoRawSubscribers)
/// subscribes to a topic and the other advertises, publishes a message and
/// terminates. This test checks that the subscriber doesn't get affected by
/// the prompt termination of the publisher.
TEST_F(twoProcPubSub, FastPublisher)
TEST_P(twoProcPubSub, FastPublisher)
{
this->SpawnSubprocess({test_executables::kFastPub});

Expand All @@ -321,7 +329,7 @@ TEST_F(twoProcPubSub, FastPublisher)
/// \brief This test creates one publisher and one subscriber on different
/// processes. The publisher publishes at higher frequency than the rate set
/// by the subscriber.
TEST_F(twoProcPubSub, SubThrottled)
TEST_P(twoProcPubSub, SubThrottled)
{
this->SpawnSubprocess({test_executables::kPub});

Expand All @@ -346,7 +354,7 @@ TEST_F(twoProcPubSub, SubThrottled)
//////////////////////////////////////////////////
/// \brief This test creates one publisher and one subscriber on different
/// processes. The publisher publishes at a throttled frequency.
TEST_F(twoProcPubSub, PubThrottled)
TEST_P(twoProcPubSub, PubThrottled)
{
this->SpawnSubprocess({test_executables::kPubThrottled});

Expand All @@ -369,7 +377,7 @@ TEST_F(twoProcPubSub, PubThrottled)
//////////////////////////////////////////////////
/// \brief Check that a message is received after Advertise->Subscribe->Publish
/// using a callback that accepts message information.
TEST_F(twoProcPubSub, PubSubMessageInfo)
TEST_P(twoProcPubSub, PubSubMessageInfo)
{
this->SpawnSubprocess({test_executables::kTwoProcsPublisher});
reset();
Expand All @@ -390,7 +398,7 @@ TEST_F(twoProcPubSub, PubSubMessageInfo)
/// \brief This test spawns two nodes on different processes. One of the nodes
/// advertises a topic and the other uses TopicList() for getting the list of
/// available topics.
TEST_F(twoProcPubSub, TopicList)
TEST_P(twoProcPubSub, TopicList)
{
this->SpawnSubprocess({test_executables::kTwoProcsPublisher});

Expand Down Expand Up @@ -435,7 +443,7 @@ TEST_F(twoProcPubSub, TopicList)
/// \brief This test spawns two nodes on different processes. One of the nodes
/// advertises a topic and the other uses TopicInfo() for getting information
/// about the topic.
TEST_F(twoProcPubSub, TopicInfo)
TEST_P(twoProcPubSub, TopicInfo)
{
this->SpawnSubprocess({test_executables::kTwoProcsPublisher});

Expand All @@ -459,3 +467,7 @@ TEST_F(twoProcPubSub, TopicInfo)

reset();
}

INSTANTIATE_TEST_SUITE_P(TransportStatistics,
twoProcPubSub,
testing::Bool());

0 comments on commit 5efc81c

Please sign in to comment.