test/blackbox/BlackboxTestsVolatile.cpp
TEST(BlackBox, AsyncPubSubAsNonReliableVolatileKeepAllHelloworld)
{
    RTPSAsSocketReader<HelloWorldType> reader(TEST_TOPIC_NAME);
    RTPSAsSocketWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
    std::string ip("239.255.1.4");

    reader.reliability(eprosima::fastrtps::rtps::ReliabilityKind_t::BEST_EFFORT).
        add_to_multicast_locator_list(ip, global_port).init();

    ASSERT_TRUE(reader.isInitialized());

    writer.reliability(eprosima::fastrtps::rtps::ReliabilityKind_t::BEST_EFFORT).
        durability(eprosima::fastrtps::rtps::DurabilityKind_t::VOLATILE).
        add_to_multicast_locator_list(ip, global_port).
        auto_remove_on_volatile().init();

    ASSERT_TRUE(writer.isInitialized());

    auto data = default_helloworld_data_generator();

    reader.expected_data(data);
    reader.startReception();

    // Send data
    writer.send(data);
    // In this test all data should be sent.
    ASSERT_TRUE(data.empty());
    // Block reader until reception finished or timeout.
    reader.block_for_all();

    // Wait for acks to be sent and check writer history is empty
    std::this_thread::sleep_for(std::chrono::seconds(1));

    ASSERT_TRUE(writer.is_history_empty());
}
// Test created to check a bug with writers that use BEST_EFFORT WITH VOLATILE that don't remove messages from history.
Test created to check a bug with writers that use BEST_EFFORT WITH VOLATILE that don't remove messages from history.
Test created to check a bug with writers that use BEST_EFFORT WITH VOLATILE that don ' t remove messages from history .
TEST(BlackBox, AsyncPubSubAsNonReliableVolatileKeepAllHelloworld)
{
    RTPSAsSocketReader<HelloWorldType> reader(TEST_TOPIC_NAME);
    RTPSAsSocketWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
    std::string ip("239.255.1.4");
    reader.reliability(eprosima::fastrtps::rtps::ReliabilityKind_t::BEST_EFFORT).
        add_to_multicast_locator_list(ip, global_port).init();
    ASSERT_TRUE(reader.isInitialized());
    writer.reliability(eprosima::fastrtps::rtps::ReliabilityKind_t::BEST_EFFORT).
        durability(eprosima::fastrtps::rtps::DurabilityKind_t::VOLATILE).
        add_to_multicast_locator_list(ip, global_port).
        auto_remove_on_volatile().init();
    ASSERT_TRUE(writer.isInitialized());
    auto data = default_helloworld_data_generator();
    reader.expected_data(data);
    reader.startReception();
    writer.send(data);
    ASSERT_TRUE(data.empty());
    reader.block_for_all();
    std::this_thread::sleep_for(std::chrono::seconds(1));
    ASSERT_TRUE(writer.is_history_empty());
}
TEST ( BlackBox , AsyncPubSubAsNonReliableVolatileKeepAllHelloworld ) { RTPSAsSocketReader < HelloWorldType > reader ( TEST_TOPIC_NAME ) ; RTPSAsSocketWriter < HelloWorldType > writer ( TEST_TOPIC_NAME ) ; std :: string ip ( " " ) ; reader . reliability ( eprosima :: fastrtps :: rtps :: ReliabilityKind_t :: BEST_EFFORT ) . add_to_multicast_locator_list ( ip , global_port ) . init ( ) ; ASSERT_TRUE ( reader . isInitialized ( ) ) ; writer . reliability ( eprosima :: fastrtps :: rtps :: ReliabilityKind_t :: BEST_EFFORT ) . durability ( eprosima :: fastrtps :: rtps :: DurabilityKind_t :: VOLATILE ) . add_to_multicast_locator_list ( ip , global_port ) . auto_remove_on_volatile ( ) . init ( ) ; ASSERT_TRUE ( writer . isInitialized ( ) ) ; auto data = default_helloworld_data_generator ( ) ; reader . expected_data ( data ) ; reader . startReception ( ) ; writer . send ( data ) ; ASSERT_TRUE ( data . empty ( ) ) ; reader . block_for_all ( ) ; std :: this_thread :: sleep_for ( std :: chrono :: seconds ( 1 ) ) ; ASSERT_TRUE ( writer . is_history_empty ( ) ) ; }
Test created to check a bug with writers that use BEST_EFFORT WITH VOLATILE that don't remove messages from history.
Test created to check a bug with writers that use BEST_EFFORT WITH VOLATILE that don ' t remove messages from history .
// Send data // In this test all data should be sent. // Block reader until reception finished or timeout. // Wait for acks to be sent and check writer history is empty