Skip to content

Fix bond tests#76

Closed
mjcarroll wants to merge 2 commits intoros2from
mjcarroll/fix_tests
Closed

Fix bond tests#76
mjcarroll wants to merge 2 commits intoros2from
mjcarroll/fix_tests

Conversation

@mjcarroll
Copy link
Copy Markdown
Member

Fix unit tests for CI.

Signed-off-by: Michael Carroll michael@openrobotics.org

Michael Carroll added 2 commits March 26, 2021 13:17
Signed-off-by: Michael Carroll <michael@openrobotics.org>
Signed-off-by: Michael Carroll <michael@openrobotics.org>
sm_.HeartbeatTimeout();
if (sm_.getState().getId() != SM::WaitingForSister.getId()) {
sm_.HeartbeatTimeout();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjcarroll why the change? why the difference with bondpy?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WaitingForSister state doesn't have an implementation for HeartbeatTimeout as you can see here:

class SM_WaitingForSister :
public SM_Default
{
public:
SM_WaitingForSister(const char *name, int stateId)
: SM_Default(name, stateId)
{};
void ConnectTimeout(BondSMContext& context);
void Die(BondSMContext& context);
void SisterAlive(BondSMContext& context);
void SisterDead(BondSMContext& context);
};

This was causing a segfault in the remoteNeverConnects test:

TEST_F(TestCallbacksCpp, remoteNeverConnects)
{
auto nh2 = rclcpp::Node::make_shared("test_callbacks_cpp_2");
std::string id2 = genId();
bond::Bond a1(TOPIC, id2, nh2);
a1.start();
EXPECT_FALSE(a1.waitUntilFormed(rclcpp::Duration(5.0s)));
EXPECT_TRUE(a1.waitUntilBroken(rclcpp::Duration(10.0s)));
}

I don't believe that this impacts behavior, just guards against an undefined condition that wasn't previously exposed from the unit tests.

Copy link
Copy Markdown

@hidmic hidmic Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super familiar with bond's architecture, but if a heartbeat timeout can occur while waiting for sister, should said state handle that condition (even if ignoring it)? By implementing HeartbeatTimeout I mean. That applies to both bondcpp and bondpy (where I don't an if clause like this one).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjcarroll bump (this is in the list of things to triage for Galactic)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC ros2 bondcpp has this new method start() that resets the heartbeat timer, while kinetic-devel bondcpp only reset the heartbeat timer the first time someone called Heartbeat. It probably wasn't possible for the WaitingForSister state to see HeartbeatTimeout in ROS 1.

Maybe the heartbeat timer should be reset only when the connection is formed? I also agree with @hidmic that WaitingForSister should implement that callback too, but the implementation should be a warning or error that the callback is unexpected.

@sloretz
Copy link
Copy Markdown

sloretz commented May 11, 2021

@mjcarroll is this still targeting initial Galactic release, or is patch 1 more likely?

@mjcarroll
Copy link
Copy Markdown
Member Author

Probably patch 1 at this point.

@mjcarroll mjcarroll mentioned this pull request Jun 2, 2022
mjcarroll pushed a commit that referenced this pull request Jun 13, 2022
* Remove a condition variable that wasn't used
* Use a type alias rather than std::function
* Use a delegating constructor and default initialization to reduce some boilerplate
* Improve locking by separating the state machine locks from the pending callbacks lock, as well as reducing the scope of locks wherever possible
* Other test improvements from Fix bond tests #76

Signed-off-by: Michael Carroll <michael@openrobotics.org>
@mjcarroll
Copy link
Copy Markdown
Member Author

Going to backport some of the fixes from #87 in place of this.

@mjcarroll mjcarroll closed this Jun 13, 2022
@mjcarroll mjcarroll deleted the mjcarroll/fix_tests branch June 13, 2022 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants