Skip to content

Commit

Permalink
Remove assumptions in tests about inconsistently-reported qos values,…
Browse files Browse the repository at this point in the history
… just check that they are reported at all

Signed-off-by: Emerson Knapp <[email protected]>
  • Loading branch information
emersonknapp committed Apr 3, 2020
1 parent 53de149 commit aa7ea23
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
10 changes: 4 additions & 6 deletions rosbag2_transport/test/rosbag2_transport/test_qos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,16 @@ TEST(TestQoS, supports_version_4)

rmw_time_t zerotime{0, 0};
// Explicitly set up the same QoS profile in case defaults change
rclcpp::QoS expected_qos(10);
expected_qos
.keep_last(10)
auto expected_qos = rosbag2_transport::Rosbag2QoS{}
.default_history()
.reliable()
.durability_volatile()
.deadline(zerotime)
.lifespan(zerotime)
.liveliness(RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT)
.liveliness_lease_duration(zerotime)
.avoid_ros_namespace_conventions(false);
.liveliness_lease_duration(zerotime);
// Any values not present in the YAML should take the default value in both profiles
EXPECT_EQ(actual_qos, expected_qos);
EXPECT_TRUE(actual_qos.compatibility_policies_equal(expected_qos));
}

TEST(TestQoS, detect_new_qos_fields)
Expand Down
36 changes: 18 additions & 18 deletions rosbag2_transport/test/rosbag2_transport/test_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ TEST_F(RecordIntegrationTestFixture, published_messages_from_multiple_topics_are
EXPECT_THAT(array_messages[0]->float32_values, Eq(array_message->float32_values));
}

#ifdef ROSBAG2_ENABLE_ADAPTIVE_QOS_SUBSCRIPTION
TEST_F(RecordIntegrationTestFixture, qos_is_stored_in_metadata)
{
auto string_message = get_messages_strings()[1];
Expand All @@ -80,26 +79,27 @@ TEST_F(RecordIntegrationTestFixture, qos_is_stored_in_metadata)
auto recorded_topics = writer.get_topics();
std::string serialized_profiles = recorded_topics.at(topic).offered_qos_profiles;
// Basic smoke test that the profile was serialized into the metadata as a string.
EXPECT_THAT(
serialized_profiles, ContainsRegex(
"- history: 3\n"
" depth: 0\n"
" reliability: 1\n"
" durability: 2\n"
" deadline:\n"
" sec: 2147483647\n"
" nsec: 4294967295\n"
" lifespan:\n"
" sec: 2147483647\n"
" nsec: 4294967295\n"
" liveliness: 1\n"
" liveliness_lease_duration:\n"
" sec: 2147483647\n"
" nsec: 4294967295\n"
" avoid_ros_namespace_conventions: false"
EXPECT_THAT(serialized_profiles, ContainsRegex("reliability: 1\n"));
EXPECT_THAT(serialized_profiles, ContainsRegex("durability: 2\n"));
EXPECT_THAT(serialized_profiles, ContainsRegex(
"deadline:\n"
" sec: .+\n"
" nsec: .+\n"
));
EXPECT_THAT(serialized_profiles, ContainsRegex(
"lifespan:\n"
" sec: .+\n"
" nsec: .+\n"
));
EXPECT_THAT(serialized_profiles, ContainsRegex("liveliness: 1\n"));
EXPECT_THAT(serialized_profiles, ContainsRegex(
"liveliness_lease_duration:\n"
" sec: .+\n"
" nsec: .+\n"
));
}

#ifdef ROSBAG2_ENABLE_ADAPTIVE_QOS_SUBSCRIPTION
TEST_F(RecordIntegrationTestFixture, records_sensor_data)
{
using clock = std::chrono::system_clock;
Expand Down

0 comments on commit aa7ea23

Please sign in to comment.