eclipse-cyclonedds / cyclonedds

Eclipse Cyclone DDS project
https://projects.eclipse.org/projects/iot.cyclonedds
Other
845 stars 350 forks source link

Status mask is not effective if it is previously set to none #891

Closed sumanth-nirmal closed 3 years ago

sumanth-nirmal commented 3 years ago

Required information

Operating system: Ubuntu 18.04 LTS

Compiler version:

Observed result or behaviour:

When we create a status condition for a reader and set the status mask to none first, and then set the status mask to some status (for eg. requested_incompatible_qos) and attach it to a waitset, then the wait set doesn't get triggered for this status condition. The below example should show the behavior

TEST(tooch, event)
{
  using DDSType = test_msgs::msg::dds_::Strings_;
  dds::domain::DomainParticipant dp(0);
  dds::pub::Publisher pub(dp);
  dds::sub::Subscriber sub(dp);
  dds::topic::Topic<DDSType> topic(dp, "test");
  dds::pub::qos::DataWriterQos dw_qos{};
  dw_qos.policy<dds::core::policy::Durability>().kind(
    dds::core::policy::DurabilityKind::VOLATILE);
  dds::pub::DataWriter<DDSType> dw(pub, topic, dw_qos);
  dds::sub::qos::DataReaderQos dr_qos{};
  dr_qos.policy<dds::core::policy::Durability>().kind(
    dds::core::policy::DurabilityKind::TRANSIENT_LOCAL);
  dds::sub::DataReader<DDSType> dr(sub, topic, dr_qos);

  dds::sub::cond::ReadCondition rc(dr,
    dds::sub::status::SampleState::not_read());
  dds::core::cond::StatusCondition sc_w(dw);
  sc_w.enabled_statuses(dds::core::status::StatusMask::offered_incompatible_qos());
  dds::core::cond::StatusCondition sc_r(dr);
  sc_r.enabled_statuses(dds::core::status::StatusMask::none());
  sc_r.enabled_statuses(dds::core::status::StatusMask::requested_incompatible_qos());

  DDSType msg{};
  msg.string_value_("tooch");
  //dw.write(msg);

  dds::core::cond::WaitSet ws{};
  //ws.attach_condition(rc);
  ws.attach_condition(sc_w);
  ws.attach_condition(sc_r);

  auto attched_conds = ws.conditions();
  auto conds = ws.wait(dds::core::Duration{3, 0});

  EXPECT_EQ(conds.size(), 2);
  EXPECT_EQ(conds[0]->get_ddsc_entity(), sc_w->get_ddsc_entity());
  EXPECT_EQ(conds[1]->get_ddsc_entity(), sc_r->get_ddsc_entity());

  EXPECT_EQ(dr.requested_incompatible_qos_status().total_count(), 1);
  EXPECT_EQ(dw.offered_incompatible_qos_status().total_count(), 1);
}

Expected result or behaviour:

Is this expected behavior or I am miss using the API?

sumanth-nirmal commented 3 years ago

@eboasson I use C++ API for the reproducer, but it should show the behavior of the status mask when it is set none.

sumanth-nirmal commented 3 years ago

@eboasson I took the changes from #900 but my example here https://github.com/eclipse-cyclonedds/cyclonedds/issues/891#issue-949448250 still fails. Am I doing something incorrectly here or my assumption in the test is incorrect?

eboasson commented 3 years ago

@sumanth-nirmal that's weird, because I made sure to verify that my changes solve the problem that you ran into, the only thing I changed in your reproducer is the data type. It is such a simple, sequential test that I don't see how one could reasonably expect different machines to exhibit different behaviours ...

ctest -VV -R tooch
UpdateCTestConfiguration  from :/Users/erik/C/cxx/CC/DartConfiguration.tcl
Parse Config file:/Users/erik/C/cxx/CC/DartConfiguration.tcl
UpdateCTestConfiguration  from :/Users/erik/C/cxx/CC/DartConfiguration.tcl
Parse Config file:/Users/erik/C/cxx/CC/DartConfiguration.tcl
Test project /Users/erik/C/cxx/CC
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 10
    Start 10: tooch.event

10: Test command: /Users/erik/C/cxx/CC/bin/ddscxx_tests "--gtest_filter=tooch.event"
10: Environment variables: 
10:  DYLD_LIBRARY_PATH=/opt/homebrew/lib:/opt/homebrew/lib:/opt/homebrew/lib:/opt/homebrew/lib:/Users/erik/C/cdds/CC/install/lib
10: Test timeout computed to be: 1500
10: Running main() from /tmp/googletest-20201223-50959-1t0y8cu/googletest-release-1.10.0/googletest/src/gtest_main.cc
10: Note: Google Test filter = tooch.event
10: [==========] Running 1 test from 1 test suite.
10: [----------] Global test environment set-up.
10: [----------] 1 test from tooch
10: [ RUN      ] tooch.event
10: [       OK ] tooch.event (4 ms)
10: [----------] 1 test from tooch (4 ms total)
10: 
10: [----------] Global test environment tear-down
10: [==========] 1 test from 1 test suite ran. (4 ms total)
10: [  PASSED  ] 1 test.
1/1 Test #10: tooch.event ......................   Passed    0.03 sec

The following tests passed:
    tooch.event

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.06 sec
sumanth-nirmal commented 3 years ago

@eboasson The test still fails and can't find the reason. To make sure that it is not something with my setup, I made a PR with this test here https://github.com/eclipse-cyclonedds/cyclonedds-cxx/pull/141 and the test also fails on the CI here https://dev.azure.com/eclipse-cyclonedds/cyclonedds-cxx/_build/results?buildId=905&view=logs&j=9c723939-9148-5f6a-3101-ca017cb22518&t=42b7edb5-0b1f-5f1a-9720-086d92442d29&l=1031


I have also observed that the CI fails in finding iceoryx_posh_roudi_environment here https://dev.azure.com/eclipse-cyclonedds/cyclonedds-cxx/_build/results?buildId=905&view=logs&j=69944193-f126-526b-b021-abb6fb4b38ee&t=b51c32e4-afb7-5d6f-d65f-10ab7bc83c23&l=87, which is a different problem, but I will check what is going on with that.

sumanth-nirmal commented 3 years ago

The problem was with my setup. The actual issue described here https://github.com/eclipse-cyclonedds/cyclonedds/issues/891#issue-949448250 is fixed in #900.

Closing the issue.