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

feat(published_time_publisher): add unit test #6610

Merged
merged 6 commits into from
Mar 16, 2024

Conversation

brkay54
Copy link
Member

@brkay54 brkay54 commented Mar 13, 2024

Description

Part of:

Required from:

Depends on:

Tests performed

Not applicable.

Effects on system behavior

Not applicable.

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.

After all checkboxes are checked, anyone who has write access can merge the PR.

@github-actions github-actions bot added the component:common Common packages from the autoware-common repository. (auto-assigned) label Mar 13, 2024
@brkay54 brkay54 marked this pull request as ready for review March 13, 2024 11:24
@brkay54 brkay54 self-assigned this Mar 13, 2024
@brkay54 brkay54 requested a review from xmfcx March 13, 2024 11:24
@brkay54 brkay54 requested a review from xmfcx March 13, 2024 12:02
@brkay54 brkay54 requested a review from xmfcx March 13, 2024 12:56
@xmfcx xmfcx added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Mar 13, 2024
Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 20.20202% with 79 lines in your changes are missing coverage. Please review.

Project coverage is 14.77%. Comparing base (a993a06) to head (7c775fa).
Report is 3 commits behind head on main.

Files Patch % Lines
...ils/test/src/ros/test_published_time_publisher.cpp 20.20% 0 Missing and 79 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #6610    +/-   ##
========================================
  Coverage   14.77%   14.77%            
========================================
  Files        1923     1925     +2     
  Lines      132533   132754   +221     
  Branches    39398    39545   +147     
========================================
+ Hits        19586    19620    +34     
- Misses      91070    91166    +96     
- Partials    21877    21968    +91     
Flag Coverage Δ *Carryforward flag
differential 16.76% <20.20%> (?)
total 14.77% <ø> (ø) Carriedforward from a993a06

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@brkay54 brkay54 force-pushed the feat/pt-test branch 3 times, most recently from 180a921 to 920a511 Compare March 14, 2024 08:27
@brkay54 brkay54 requested a review from xmfcx March 14, 2024 08:27
@xmfcx
Copy link
Contributor

xmfcx commented Mar 15, 2024

Thanks for the work❇️
Once the build-and-test-differential jobs pass, we can merge this.
It checks most of its functionality.

Copy link

github-actions bot commented Mar 15, 2024

Image description CodeRabbit


Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 7f36c52 and 1e28666 commits.
Files selected (1)
  • common/tier4_autoware_utils/test/src/ros/test_published_time_publisher.cpp (1)
Files not summarized due to errors (1)
  • common/tier4_autoware_utils/test/src/ros/test_published_time_publisher.cpp (nothing obtained from openai)
Files not reviewed due to errors (1)
  • common/tier4_autoware_utils/test/src/ros/test_published_time_publisher.cpp (no response)
Review comments generated (0)
  • Review: 0
  • LGTM: 0

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

@xmfcx xmfcx added the tag:pr-agent Mark to enable PR-Agent for automated reviews. (used-by-ci) label Mar 15, 2024
@xmfcx
Copy link
Contributor

xmfcx commented Mar 15, 2024

/review

Copy link

github-actions bot commented Mar 15, 2024

PR Review

(Review updated until commit 7c775fa)

⏱️ Estimated effort to review [1-5]

4, due to the extensive amount of test code added, which requires careful review to ensure correctness, coverage, and adherence to best practices.

🧪 Relevant tests

Yes

🔍 Possible issues

Test Redundancy: The tests for PublishedTimePublisherWithSubscriptionTest and PublishedTimePublisherWithoutSubscriptionTest share a lot of similar setup and teardown code, as well as similar test logic. This redundancy could be reduced by using test fixtures more effectively or by parameterizing tests.

Missing Edge Case Tests: The tests cover basic functionality but may miss edge cases, such as handling of invalid timestamps or frame IDs, and behavior under unusual conditions (e.g., extremely high publishing rates, system clock changes).

🔒 Security concerns

No

Code feedback:
relevant filecommon/tier4_autoware_utils/test/src/ros/test_published_time_publisher.cpp
suggestion      

Consider using a test fixture class for common setup and teardown code to reduce redundancy and improve maintainability. This can be achieved by moving shared setup code into the SetUp() method of a base test fixture class, and shared teardown code into the TearDown() method. [important]

relevant lineclass PublishedTimePublisherWithSubscriptionTest : public ::testing::Test

relevant filecommon/tier4_autoware_utils/test/src/ros/test_published_time_publisher.cpp
suggestion      

Add tests for edge cases, such as invalid timestamps or frame IDs, to ensure robustness. This could involve testing with negative timestamps, empty frame IDs, or extremely large timestamps to verify correct behavior under all conditions. [important]

relevant lineTEST_F(PublishedTimePublisherWithSubscriptionTest, PublishMsgWithHeader)

relevant filecommon/tier4_autoware_utils/test/src/ros/test_published_time_publisher.cpp
suggestion      

Consider parameterizing tests to avoid code duplication and to cover more scenarios with less code. Google Test's TEST_P and INSTANTIATE_TEST_CASE_P can be used to run the same test logic with different inputs, reducing redundancy and making the tests easier to extend. [medium]

relevant lineTEST_F(PublishedTimePublisherWithSubscriptionTest, PublishMsgWithHeader)

relevant filecommon/tier4_autoware_utils/test/src/ros/test_published_time_publisher.cpp
suggestion      

To ensure that the system behaves correctly under high load, add stress tests that simulate a high rate of messages being published. This can help identify performance issues or race conditions that may not be evident under normal operation. [medium]

relevant lineTEST_F(PublishedTimePublisherWithSubscriptionTest, MultiplePublishMsgWithHeader)


✨ Review tool usage guide:

Overview:
The review tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:

/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...

With a configuration file, use the following template:

[pr_reviewer]
some_config1=...
some_config2=...
Utilizing extra instructions

The review tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project.

Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize.

Examples for extra instructions:

[pr_reviewer] # /review #
extra_instructions="""
In the 'possible issues' section, emphasize the following:
- Does the code logic cover relevant edge cases?
- Is the code logic clear and easy to understand?
- Is the code logic efficient?
...
"""

Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

How to enable\disable automation
  • When you first install PR-Agent app, the default mode for the review tool is:
pr_commands = ["/review", ...]

meaning the review tool will run automatically on every PR, with the default configuration.
Edit this field to enable/disable the tool, or to change the used configurations

Auto-labels

The review tool can auto-generate two specific types of labels for a PR:

  • a possible security issue label, that detects possible security issues (enable_review_labels_security flag)
  • a Review effort [1-5]: x label, where x is the estimated effort to review the PR (enable_review_labels_effort flag)
Extra sub-tools

The review tool provides a collection of possible feedbacks about a PR.
It is recommended to review the possible options, and choose the ones relevant for your use case.
Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example:
require_score_review, require_soc2_ticket, and more.

Auto-approve PRs

By invoking:

/review auto_approve

The tool will automatically approve the PR, and add a comment with the approval.

To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following:

[pr_reviewer]
enable_auto_approval = true

(this specific flag cannot be set with a command line argument, only in the configuration file, committed to the repository)

You can also enable auto-approval only if the PR meets certain requirements, such as that the estimated_review_effort is equal or below a certain threshold, by adjusting the flag:

[pr_reviewer]
maximal_review_effort = 5
More PR-Agent commands

To invoke the PR-Agent, add a comment using one of the following commands:

  • /review: Request a review of your Pull Request.
  • /describe: Update the PR title and description based on the contents of the PR.
  • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
  • /ask <QUESTION>: Ask a question about the PR.
  • /update_changelog: Update the changelog based on the PR's contents.
  • /add_docs 💎: Generate docstring for new components introduced in the PR.
  • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
  • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

See the tools guide for more details.
To list the possible configuration parameters, add a /config comment.

See the review usage page for a comprehensive guide on using this tool.

@xmfcx xmfcx mentioned this pull request Mar 15, 2024
4 tasks
@brkay54
Copy link
Member Author

brkay54 commented Mar 16, 2024

/review

Copy link

Persistent review updated to latest commit 7c775fa

@brkay54
Copy link
Member Author

brkay54 commented Mar 16, 2024

@xmfcx I implemented some of the the automated review suggestions. I think it is ready to merge.

@brkay54 brkay54 merged commit c24c3b0 into autowarefoundation:main Mar 16, 2024
27 checks passed
@brkay54
Copy link
Member Author

brkay54 commented Mar 16, 2024

@takayuki5168 Thank you 🙏🏼

kaigohirao pushed a commit to kaigohirao/autoware.universe that referenced this pull request Mar 22, 2024
* feat(published_time_publisher): add unit test

Signed-off-by: Berkay Karaman <[email protected]>

* feat: add nullpointer test

Signed-off-by: Berkay Karaman <[email protected]>

* feat: simplify node and topic names

Signed-off-by: Berkay Karaman <[email protected]>

* feat: modify to test multiple PublishedTime publishers

Signed-off-by: Berkay Karaman <[email protected]>

* feat: change function name publish() -> publish_if_subscribed()

Signed-off-by: Berkay Karaman <[email protected]>

* feat: update

Signed-off-by: Berkay Karaman <[email protected]>

---------

Signed-off-by: Berkay Karaman <[email protected]>
Signed-off-by: kaigohirao <[email protected]>
karishma1911 pushed a commit to Interplai/autoware.universe that referenced this pull request Jun 3, 2024
* feat(published_time_publisher): add unit test

Signed-off-by: Berkay Karaman <[email protected]>

* feat: add nullpointer test

Signed-off-by: Berkay Karaman <[email protected]>

* feat: simplify node and topic names

Signed-off-by: Berkay Karaman <[email protected]>

* feat: modify to test multiple PublishedTime publishers

Signed-off-by: Berkay Karaman <[email protected]>

* feat: change function name publish() -> publish_if_subscribed()

Signed-off-by: Berkay Karaman <[email protected]>

* feat: update

Signed-off-by: Berkay Karaman <[email protected]>

---------

Signed-off-by: Berkay Karaman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:common Common packages from the autoware-common repository. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) tag:pr-agent Mark to enable PR-Agent for automated reviews. (used-by-ci)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants