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(kmod): unit test for AGNOCAST_PUBLISH_MSG_CMD #449

Merged
merged 17 commits into from
Mar 4, 2025

Conversation

Koichi98
Copy link
Contributor

@Koichi98 Koichi98 commented Feb 28, 2025

Description

kmodにおけるpublish_msg()のunit testです。

以下の9つのテストがあります。

  • void test_case_no_topic(struct kunit * test)
    • 該当topicがない
  • void test_case_no_publisher(struct kunit * test);
    • 該当publisherがいない   
  • void test_case_simple_publish_without_any_release(struct kunit * test);
    • 何もreleaseしないsimpleなpublish
  • void test_case_excessive_unreleased_entry_nodes(struct kunit * test);
    • leak_warn_thresholdを超えるentry_nodeが解放されていない場合
  • void test_case_different_publisher_no_release(struct kunit * test);
    • 異なるpublisherのentry_nodeは解放されないことを確認
  • void test_case_referenced_node_not_released(struct kunit * test);
    • reference countが正のentry_nodeは解放されないことを確認
  • void test_case_single_release_return(struct kunit * test);
    • 解放されるべきentry_nodeが一つある場合
  • void test_case_excessive_release_count(struct kunit * test);
    • 解放されるべきentry_nodeがMAX_RELESED_NUMを超える場合
  • void test_case_ret_one_subscriber(struct kunit * test);
    • subscriberが一人いる場合
  • void test_case_ret_many_subscribers(struct kunit * test);
    • subscriberがMAX_SUBSCRIBER_NUMいる場合

解放されるべきノードが正しく解放されているかと、subscriberのidをreturnするという処理は完全に分離できるためこれらを組み合わせてはテストしていません。
また、qos_depthはpublisher的にはMAX_QOS_DEPTHに縛られておらず10, 100, 1000といくらでも取り得て境界値が存在しないため、本テストではqos_depthは1の場合のみとしています。(0を明示的にユーザが指定しまった場合のエラーハンドリングはpublisher_addで弾くべきなので別PRで対応します。)

Related links

How was this PR tested?

  • Autoware (required)
  • bash scripts/e2e_test_1to1_with_ros2sub (required)
  • bash scripts/e2e_test_2to2 (required)
  • sample application

Notes for reviewers

leak_warn_threshold周りのテストをするためにLEAK_WARN_THというマクロ定数を導入しましたが、実際のthresholdは

  • qos_depthが100以下の場合は、LEAK_WARN_TH + qos_depth
  • 100より大きい場合はLEAK_WARN_TH * 2

直接thresholdになるわけではないので少しややこしかったりします。いい案があればコメントお願いします。

Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Koichi98 and others added 4 commits February 28, 2025 15:47
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Koichi98 and others added 2 commits February 28, 2025 17:18
Co-authored-by: atsushi yano <55824710+atsushi421@users.noreply.github.com>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
@atsushi421
Copy link
Contributor

leak_warn_threshold周りのテストをするためにLEAK_WARN_THというマクロ定数を導入しましたが、実際のthresholdは
qos_depthが100以下の場合は、LEAK_WARN_TH + qos_depth
100より大きい場合はLEAK_WARN_TH * 2
直接thresholdになるわけではないので少しややこしかったりします。いい案があればコメントお願いします。

そんなに厳密なしきい値ではないのと、テストのために内部実装をpublicにするのはあまり良くないので、このテストケースは無くても良いかもと思いました

Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
@Koichi98 Koichi98 marked this pull request as draft February 28, 2025 08:41
@Koichi98
Copy link
Contributor Author

Koichi98 commented Feb 28, 2025

@atsushi421

そんなに厳密なしきい値ではないのと、テストのために内部実装をpublicにするのはあまり良くないので、このテストケースは無くても良いかもと思いました

確かに。
この件そもそもこれエラーで落とすのはやりすぎだったりするかな、と思いましたがどうでしょう?今まではOoM killer的なイメージで落とすのありだなと思っていたのですが、そのような処理を「アプリケーションが見えていない」かつ「カーネルでもない」ミドルウェアレベルで行うのはおかしかったりしないでしょうか?ちょっと違うかもですが、ros2でいうところのlo通信量を圧迫しているノードを勝手に殺すに近いかと思いました。
カーネルレベルでのwarning(できたらuserレベルでも)を出すくらいでいいのではってなってます。

@Koichi98 Koichi98 marked this pull request as ready for review March 3, 2025 08:59
Co-authored-by: Ryuta Kambe <ryuta.kambe@tier4.jp>
veqcc
veqcc previously approved these changes Mar 3, 2025
Copy link
Contributor

@veqcc veqcc left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@atsushi421
Copy link
Contributor

@Koichi98
warnigにしてテストケースから除く、で良いと思います!

Signed-off-by: koichiimai <kotty.0704@gmail.com>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
@atsushi421 atsushi421 self-requested a review March 4, 2025 07:08
Copy link
Contributor

@atsushi421 atsushi421 left a comment

Choose a reason for hiding this comment

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

LGTM

@atsushi421 atsushi421 added the run-build-test Run build-test in CI label Mar 4, 2025
@Koichi98 Koichi98 merged commit b76a16d into main Mar 4, 2025
5 checks passed
@Koichi98 Koichi98 deleted the feat/kunit_publish_msg branch March 4, 2025 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-build-test Run build-test in CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants