Skip to content

chore: ut coverage for same src/dst but different direction#1399

Merged
kmesh-bot merged 1 commit intokmesh-net:mainfrom
yp969803:issue1384
May 15, 2025
Merged

chore: ut coverage for same src/dst but different direction#1399
kmesh-bot merged 1 commit intokmesh-net:mainfrom
yp969803:issue1384

Conversation

@yp969803
Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind enhancement

What this PR does / why we need it:
ut coverage for same src/dst but different direction

Which issue(s) this PR fixes:
Fixes #1384

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Signed-off-by: Yash Patel <yp969803@gmail.com>
Copilot AI review requested due to automatic review settings May 14, 2025 17:18
@kmesh-bot kmesh-bot added the kind/enhancement New feature or request label May 14, 2025
@kmesh-bot kmesh-bot requested review from YaoZengzeng and kwb0523 May 14, 2025 17:18
@yp969803
Copy link
Copy Markdown
Contributor Author

@hzxuzhonghu can u review !!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances unit test coverage by adding tests for cases where the same source/destination pair use different communication directions and by refactoring the metric request structure. Key changes include updating test cases in metric_test.go to include a “direction” field in connectionSrcDst, removing the redundant direction field from requestMetric in metric.go, and updating switch statements to reference the new nested field.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/controller/telemetry/metric_test.go Added direction fields in various test cases to cover both inbound and outbound scenarios and updated expected reporter labels accordingly
pkg/controller/telemetry/metric.go Removed redundant direction field from requestMetric and modified functions to reference connectionSrcDst.direction

dst: [4]uint32{nets.ConvertIpToUint32("10.19.25.31"), 0, 0, 0},
dstPort: uint16(8000),
srcPort: uint16(8000),
direction: uint32(2),
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

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

Consider replacing the numeric literal 'uint32(2)' with a named constant (such as constants.INBOUND or constants.OUTBOUND) to improve code readability and consistency across tests.

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov bot commented May 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.31%. Comparing base (897be44) to head (579f10b).
Report is 5 commits behind head on main.

Files with missing lines Coverage Δ
pkg/controller/telemetry/metric.go 59.64% <100.00%> (+0.03%) ⬆️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d4a7ce1...579f10b. Read the comment docs.

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

@hzxuzhonghu
Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

@kmesh-bot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

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

@kmesh-bot kmesh-bot merged commit c5d11ab into kmesh-net:main May 15, 2025
10 of 11 checks passed
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.

ut coverage for same src/dst but different direction in metrics.go

4 participants