Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ros2 fix battery and manager tests #319

Merged
merged 4 commits into from
Jun 3, 2024

Conversation

delihus
Copy link
Contributor

@delihus delihus commented Jun 1, 2024

Description

Test fixes. Pulled this #317

Modifications

  • unified QoS of IOState messages in tests,
  • fixed BT plugins tests,
  • fixed Safety BT tests.

Summary by CodeRabbit

  • Bug Fixes

    • Improved quality of service (QoS) settings for the io_state_pub_ publisher to enhance reliability and transient local durability.
  • Refactor

    • Updated conditional checks in lights.xml and safety.xml for better logic clarity and correctness.
  • Tests

    • Enhanced error handling in test cases by replacing direct status checks with EXPECT_THROW statements to manage exceptions more effectively.

@delihus delihus requested a review from pawelirh June 1, 2024 16:00
Copy link
Contributor

coderabbitai bot commented Jun 1, 2024

Walkthrough

The recent updates primarily enhance the quality of service (QoS) settings for ROS 2 publishers and modify error handling mechanisms in test scenarios. Specifically, the TestBatteryNode and TestBatteryPublisher classes now include detailed QoS settings for the io_state_pub_ publisher. Additionally, the error handling in test files has shifted from direct status checking to using EXPECT_THROW statements for robust exception handling. Minor changes also improve conditional checks in XML configuration files.

Changes

Files/Directories Change Summary
panther_battery/test/include/test_battery_node.hpp Updated io_state_pub_ creation to include QoS settings.
panther_battery/test/test_battery_publisher.cpp Modified io_state_pub_ creation to include specific QoS settings.
panther_manager/behavior_trees/lights.xml Updated conditional check in service_name attribute.
panther_manager/behavior_trees/safety.xml Updated condition for fan_state within a sequence block.
panther_manager/test/plugins/test_call_set_bool_service_node.cpp Replaced tree creation and status check logic with EXPECT_THROW for exception handling.
panther_manager/test/plugins/test_call_set_led_animation_service_node.cpp Replaced service creation and status check logic with EXPECT_THROW in specific test cases.

Poem

In the code where batteries beam,
QoS settings now supreme.
Tests now throw with grace,
Handling errors face to face.
XML checks, refined and neat,
Our Panther's upgrades are quite the feat!
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dbf3f47 and ebc97c1.

Files selected for processing (7)
  • panther_battery/test/include/test_battery_node.hpp (1 hunks)
  • panther_battery/test/test_battery_publisher.cpp (1 hunks)
  • panther_manager/behavior_trees/lights.xml (1 hunks)
  • panther_manager/behavior_trees/safety.xml (1 hunks)
  • panther_manager/test/plugins/test_call_set_bool_service_node.cpp (1 hunks)
  • panther_manager/test/plugins/test_call_set_led_animation_service_node.cpp (2 hunks)
  • panther_manager/test/test_safety_manager_node.cpp (1 hunks)
Files skipped from review due to trivial changes (3)
  • panther_manager/behavior_trees/safety.xml
  • panther_manager/test/plugins/test_call_set_led_animation_service_node.cpp
  • panther_manager/test/test_safety_manager_node.cpp
Additional comments not posted (4)
panther_battery/test/test_battery_publisher.cpp (1)

90-90: Updated QoS settings for io_state_pub_ to enhance reliability and behavior.

Verification successful

The new QoS settings for io_state_pub_ have been verified and align with the intended behavior of the tests. The changes ensure reliable delivery of IOStateMsg messages.

  • panther_battery/test/test_battery_node.cpp
  • panther_battery/test/test_battery_publisher.cpp
  • panther_battery/test/test_battery_node_dual_bat.cpp
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the impact of new QoS settings on system behavior.

# Test: Check for any reported issues or errors related to IOState messages.
rg --type python $'io_state_pub_->publish'

Length of output: 74



Script:

#!/bin/bash
# Description: Verify the impact of new QoS settings on system behavior.

# Test: Check for any reported issues or errors related to IOState messages.
rg --type cpp 'io_state_pub_->publish'

Length of output: 291



Script:

#!/bin/bash
# Description: Extract relevant lines to verify the impact of new QoS settings.

# Extract lines where `io_state_pub_->publish` is used.
rg --type cpp --context 5 'io_state_pub_->publish' panther_battery/test/test_battery_node.cpp
rg --type cpp --context 5 'io_state_pub_->publish' panther_battery/test/test_battery_publisher.cpp
rg --type cpp --context 5 'io_state_pub_->publish' panther_battery/test/test_battery_node_dual_bat.cpp

Length of output: 1491

panther_manager/test/plugins/test_call_set_bool_service_node.cpp (1)

151-151: Replaced old logic with EXPECT_THROW to enhance error handling in tests.

Verification successful

The search results confirm that EXPECT_THROW is consistently used across various test files to handle exceptions, including in panther_manager/test/plugins/test_call_set_bool_service_node.cpp. This aligns with the change made in the pull request.

  • panther_manager/test/plugins/test_call_set_bool_service_node.cpp: EXPECT_THROW({CreateTree("CallSetBoolService", service);}, BT::LogicError);

This indicates that the change to use EXPECT_THROW for exception handling is appropriate and consistent with the existing codebase practices.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the correct exceptions are being thrown as expected.

# Test: Check for the presence of `EXPECT_THROW` in other similar test cases.
rg --type python $'EXPECT_THROW'

Length of output: 62



Script:

#!/bin/bash
# Description: Verify that the correct exceptions are being thrown as expected.

# Test: Check for the presence of `EXPECT_THROW` in other similar test cases.
rg --type cpp $'EXPECT_THROW'

Length of output: 6910

panther_manager/behavior_trees/lights.xml (1)

52-52: Refined conditional check in service_name attribute for better logical clarity.

Verification successful

Refined conditional check in service_name attribute for better logical clarity.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the impact of the refined conditional check on behavior tree execution.

# Test: Check for any logical errors or unexpected behaviors in the execution of behavior trees.
rg --type xml $'service_name'

Length of output: 2143



Script:

#!/bin/bash
# Description: Extract the specific line in `lights.xml` where the conditional check was refined.

# Extract the line containing the refined conditional check.
rg --type xml --line-number --context 5 '_skipIf="(!e_stop_state) || (current_anim_id == E_STOP_ANIM_ID)"' panther_manager/behavior_trees/lights.xml

Length of output: 6052

panther_battery/test/include/test_battery_node.hpp (1)

112-112: Updated QoS settings for io_state_pub_ to enhance reliability and behavior.

Verification successful

The updated QoS settings for io_state_pub_ have been verified, and no issues or errors related to IOState messages were found in the codebase.

  • The io_state_pub_ publisher is used in multiple test files and the main codebase.
  • The new QoS settings are applied consistently across these usages.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the impact of new QoS settings on system behavior.

# Test: Check for any reported issues or errors related to IOState messages.
rg --type python $'io_state_pub_->publish'

Length of output: 74



Script:

#!/bin/bash
# Description: Verify the impact of new QoS settings on system behavior.

# Test: Check for any usage of io_state_pub_ in the codebase.
rg 'io_state_pub_'

# Test: Check for any reported issues or errors related to IOState messages.
rg 'IOState'

Length of output: 7617

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ebc97c1 and 5196624.

Files selected for processing (4)
  • panther_battery/test/include/test_battery_node.hpp (1 hunks)
  • panther_battery/test/test_battery_publisher.cpp (1 hunks)
  • panther_manager/test/plugins/test_call_set_bool_service_node.cpp (1 hunks)
  • panther_manager/test/plugins/test_call_set_led_animation_service_node.cpp (2 hunks)
Files skipped from review as they are similar to previous changes (4)
  • panther_battery/test/include/test_battery_node.hpp
  • panther_battery/test/test_battery_publisher.cpp
  • panther_manager/test/plugins/test_call_set_bool_service_node.cpp
  • panther_manager/test/plugins/test_call_set_led_animation_service_node.cpp

@pawelirh pawelirh merged commit af13ab2 into ros2 Jun 3, 2024
@pawelirh pawelirh deleted the ros2-fix-battery-and-manager-tests branch June 3, 2024 12:23
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.

3 participants