Skip to content

test(device): add coverage for PodManager update, delete, and ListPodsUID paths - #2358

Merged
hami-robot[bot] merged 2 commits into
Project-HAMi:masterfrom
aaka24:add-podmanager-tests
Aug 6, 2026
Merged

test(device): add coverage for PodManager update, delete, and ListPodsUID paths#2358
hami-robot[bot] merged 2 commits into
Project-HAMi:masterfrom
aaka24:add-podmanager-tests

Conversation

@aaka24

@aaka24 aaka24 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Adds focused unit tests for previously uncovered PodManager paths:

  • Tests AddPod behavior when updating an existing pod
  • Tests DelPod removal behavior and handling of unknown pods
  • Tests ListPodsUID with empty and populated managers

These tests improve coverage without changing runtime behavior.

Which issue(s) this PR fixes:

Fixes #2357

Special notes for reviewer:

Tests were added only; no production code changes were made.

Tests were verified in a WSL2 (Ubuntu) environment by running:

go test ./pkg/device/...

All tests passed successfully.

Does this PR introduce a user-facing change?:

No. This is a test-only change.

Summary by CodeRabbit

  • Tests
    • Added coverage for updating existing pod devices while preserving node associations.
    • Added coverage for safely deleting pods, including repeated and unknown deletions.
    • Added coverage for listing tracked pod identifiers in empty and populated states.

@hami-robot

hami-robot Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Welcome @aaka24! It looks like this is your first PR to Project-HAMi/HAMi 🎉

@hami-robot hami-robot Bot added the size/M label Aug 4, 2026
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This test-only change adds coverage for PodManager updates, deletion, and UID listing. Runtime behavior remains unchanged.

Changes

PodManager test coverage

Layer / File(s) Summary
PodManager behavior coverage
pkg/device/pod_test.go
Tests cover existing-pod updates, safe repeated and unknown-pod deletion, and UID listing for empty and populated managers.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: enhancement

Suggested reviewers: lengrongfu, mesutoezdil

Poem

A rabbit checks each pod with care,
New devices replace the pair.
Deleted pods leave without alarm,
UIDs return in proper form.
Tests keep runtime code calm.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The tests cover AddPod updates, DelPod deletion paths, and ListPodsUID cases required by issue #2357.
Out of Scope Changes check ✅ Passed The changes are test-only and directly match the objectives in issue #2357.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the added tests for PodManager update, delete, and ListPodsUID paths.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…PodsUID

PodManager.AddPod's existing-pod update branch, DelPod, and
ListPodsUID had no direct unit tests, only incidental use inside
scheduler_test.go. This adds focused tests for:

- AddPod re-adding an already-tracked pod (devices replaced,
  NodeID preserved, return value false)
- DelPod removing a tracked pod, and DelPod being a no-op (no
  panic) when called on an already-removed or unknown pod
- ListPodsUID on an empty manager and with multiple tracked pods

Signed-off-by: aaka24 <yaarsuperstar44@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/device/pod_test.go`:
- Around line 316-321: Update the second AddPod call in the podManager test to
pass "node2" instead of "node1", while continuing to assert that the retrieved
pod's NodeID remains "node1".
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bad35942-23d8-4211-9f43-3acb14aec060

📥 Commits

Reviewing files that changed from the base of the PR and between 2cabe29 and 0e88441.

📒 Files selected for processing (1)
  • pkg/device/pod_test.go

Comment thread pkg/device/pod_test.go Outdated
Signed-off-by: aaka24 <yaarsuperstar44@gmail.com>
@aaka24

aaka24 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Updated the AddPod update test based on review feedback by using a different NodeID on the second AddPod call to verify that the original NodeID is preserved.

@SK8-infi

SK8-infi commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@aaka24 I see you mentioned the following

go test ./pkg/device/... was attempted locally, but the test environment was Windows and the build failed due to missing Linux NVIDIA dependency headers (dlfcn.h).

well I would suggest to run the code before submitting... would you like me to test out your changes and review them?
Also I would suggest to setup your testing environment too for future..

@aaka24

aaka24 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@SK8-infi Thanks! I’d really appreciate that. Let me get my testing environment set up first, though. If you have any recommendations or a guide on the preferred setup for this project, I’d love to follow it. Once I’ve got everything working, I’ll rerun the tests and update the PR.

@SK8-infi

SK8-infi commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@SK8-infi Thanks! I’d really appreciate that. Let me get my testing environment set up first, though. If you have any recommendations or a guide on the preferred setup for this project, I’d love to follow it. Once I’ve got everything working, I’ll rerun the tests and update the PR.

Sure. I would say since you are using windows wsl2 would be the easiest and closest. You may give it a shot.

@aaka24

aaka24 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@SK8-infi Followed your suggestion and switched to WSL2. go test ./pkg/device/... passes now. Thanks!

@archlitchi archlitchi left a comment

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.

/lgtm

@hami-robot

hami-robot Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aaka24, archlitchi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hami-robot hami-robot Bot added the approved label Aug 6, 2026
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 61.31% <ø> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for PodManager update, delete, and ListPodsUID paths

3 participants