|
81 | 81 | #define GET_PID getpid
|
82 | 82 | #endif // if defined(_WIN32)
|
83 | 83 |
|
| 84 | +void stop_background_servers() |
| 85 | +{ |
| 86 | +#ifndef _WIN32 // The feature is not supported on Windows yet |
| 87 | + // Stop server(s) |
| 88 | + int res = std::system("fastdds discovery stop"); |
| 89 | + ASSERT_EQ(res, 0); |
| 90 | +#endif // _WIN32 |
| 91 | +} |
84 | 92 |
|
85 | 93 | namespace eprosima {
|
86 | 94 | namespace fastdds {
|
@@ -1077,6 +1085,17 @@ void set_environment_variable(
|
1077 | 1085 | #endif // _WIN32
|
1078 | 1086 | }
|
1079 | 1087 |
|
| 1088 | +void set_easy_mode_environment_variable( |
| 1089 | + const std::string ip = "127.0.0.1" |
| 1090 | + ) |
| 1091 | +{ |
| 1092 | +#ifdef _WIN32 |
| 1093 | + ASSERT_EQ(0, _putenv_s(rtps::EASY_MODE_URI, ip.c_str())); |
| 1094 | +#else |
| 1095 | + ASSERT_EQ(0, setenv(rtps::EASY_MODE_URI, ip.c_str(), 1)); |
| 1096 | +#endif // _WIN32 |
| 1097 | +} |
| 1098 | + |
1080 | 1099 | void set_environment_file(
|
1081 | 1100 | const std::string& filename)
|
1082 | 1101 | {
|
@@ -1483,6 +1502,70 @@ TEST(ParticipantTests, ServerParticipantRemoteServerListConfiguration)
|
1483 | 1502 | EXPECT_EQ(RETCODE_OK, DomainParticipantFactory::get_instance()->delete_participant(participant));
|
1484 | 1503 | }
|
1485 | 1504 |
|
| 1505 | +TEST(ParticipantTests, EasyModeParticipantLoadsServiceDataWriterQos) |
| 1506 | +{ |
| 1507 | + // Use get_datawriter_qos_from_profile to check if the profile is correctly loaded. |
| 1508 | + { |
| 1509 | + // Default participant |
| 1510 | + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( |
| 1511 | + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); |
| 1512 | + ASSERT_NE(nullptr, participant); |
| 1513 | + Publisher* default_publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT); |
| 1514 | + ASSERT_NE(default_publisher, nullptr); |
| 1515 | + DataWriterQos dw_qos; |
| 1516 | + EXPECT_EQ(default_publisher->get_datawriter_qos_from_profile("service", dw_qos), RETCODE_BAD_PARAMETER); |
| 1517 | + |
| 1518 | + EXPECT_EQ(RETCODE_OK, participant->delete_publisher(default_publisher)); |
| 1519 | + EXPECT_EQ(RETCODE_OK, DomainParticipantFactory::get_instance()->delete_participant(participant)); |
| 1520 | + } |
| 1521 | + |
| 1522 | + { |
| 1523 | + // Easy mode participant |
| 1524 | + set_easy_mode_environment_variable(); |
| 1525 | + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( |
| 1526 | + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); |
| 1527 | + ASSERT_NE(nullptr, participant); |
| 1528 | + Publisher* easy_mode_publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT); |
| 1529 | + ASSERT_NE(easy_mode_publisher, nullptr); |
| 1530 | + DataWriterQos dw_qos; |
| 1531 | + EXPECT_EQ(easy_mode_publisher->get_datawriter_qos_from_profile("service", dw_qos), RETCODE_OK); |
| 1532 | + EXPECT_EQ(dw_qos.reliability().max_blocking_time.seconds, 1); // Easy Mode value |
| 1533 | + EXPECT_EQ(dw_qos.reliability().max_blocking_time.nanosec, 0u); // Easy Mode value |
| 1534 | + EXPECT_EQ(dw_qos.durability().kind, TRANSIENT_LOCAL_DURABILITY_QOS); // Default value |
| 1535 | + |
| 1536 | + EXPECT_EQ(RETCODE_OK, participant->delete_publisher(easy_mode_publisher)); |
| 1537 | + EXPECT_EQ(RETCODE_OK, DomainParticipantFactory::get_instance()->delete_participant(participant)); |
| 1538 | + stop_background_servers(); |
| 1539 | + } |
| 1540 | +} |
| 1541 | + |
| 1542 | +TEST(ParticipantTests, EasyModeParticipantDoNotOverwriteCustomDataWriterQos) |
| 1543 | +{ |
| 1544 | + { |
| 1545 | + // Easy mode participant with existing profile |
| 1546 | + // Set XML profile as environment variable: "export FASTDDS_DEFAULT_PROFILES_FILE=test_xml_service_easy_mode.xml" |
| 1547 | + eprosima::testing::set_environment_variable("FASTDDS_DEFAULT_PROFILES_FILE", "test_xml_service_easy_mode.xml"); |
| 1548 | + set_easy_mode_environment_variable(); |
| 1549 | + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( |
| 1550 | + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); |
| 1551 | + ASSERT_NE(nullptr, participant); |
| 1552 | + Publisher* easy_mode_publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT); |
| 1553 | + ASSERT_NE(easy_mode_publisher, nullptr); |
| 1554 | + PublisherQos profile_qos; |
| 1555 | + EXPECT_EQ(easy_mode_publisher->get_participant()->get_publisher_qos_from_profile("service", profile_qos), |
| 1556 | + RETCODE_OK); |
| 1557 | + DataWriterQos dw_qos; |
| 1558 | + easy_mode_publisher->get_datawriter_qos_from_profile("service", dw_qos); |
| 1559 | + EXPECT_EQ(dw_qos.reliability().max_blocking_time.seconds, 5); // XML value |
| 1560 | + EXPECT_EQ(dw_qos.reliability().max_blocking_time.nanosec, 0u); // XML value |
| 1561 | + EXPECT_EQ(dw_qos.durability().kind, VOLATILE_DURABILITY_QOS); // XML value |
| 1562 | + |
| 1563 | + EXPECT_EQ(RETCODE_OK, participant->delete_publisher(easy_mode_publisher)); |
| 1564 | + EXPECT_EQ(RETCODE_OK, DomainParticipantFactory::get_instance()->delete_participant(participant)); |
| 1565 | + stop_background_servers(); |
| 1566 | + } |
| 1567 | +} |
| 1568 | + |
1486 | 1569 | /**
|
1487 | 1570 | * Dynamic modification of servers. Replacing previous servers with new ones.
|
1488 | 1571 | */
|
|
0 commit comments