Skip to content

fix: mock http server for volcenginecr adapt ut#22810

Merged
wy65701436 merged 5 commits intogoharbor:mainfrom
hyy0322:fix-volc-adapter-ut
Feb 4, 2026
Merged

fix: mock http server for volcenginecr adapt ut#22810
wy65701436 merged 5 commits intogoharbor:mainfrom
hyy0322:fix-volc-adapter-ut

Conversation

@hyy0322
Copy link
Copy Markdown
Contributor

@hyy0322 hyy0322 commented Feb 3, 2026

Thank you for contributing to Harbor!

Comprehensive Summary of your change

Issue being fixed

Fixes #22808

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

@hyy0322 hyy0322 requested a review from a team as a code owner February 3, 2026 11:59
Signed-off-by: Yiyang Huang <691795636@qq.com>
@hyy0322 hyy0322 force-pushed the fix-volc-adapter-ut branch from 6b67b84 to bc02207 Compare February 3, 2026 12:02
Copy link
Copy Markdown
Contributor

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 refactors the volcenginecr adapter unit tests to use a mock HTTP server instead of connecting to the real Volcengine registry service. This addresses issue #22808 where tests failed due to network timeouts and instability.

Changes:

  • Introduced a resolveHost function variable for dependency injection to enable test mocking
  • Added an HTTP test server in Test_getRealmService that mimics the bearer authentication challenge
  • Modified getRealmService to use the injectable resolveHost function

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/pkg/reg/adapter/volcenginecr/helper.go Added resolveHost variable function for test injection and modified getRealmService to use it
src/pkg/reg/adapter/volcenginecr/helper_test.go Added mock HTTP server setup and test infrastructure to redirect requests to the mock server

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/pkg/reg/adapter/volcenginecr/helper.go
Comment thread src/pkg/reg/adapter/volcenginecr/helper_test.go Outdated
Comment thread src/pkg/reg/adapter/volcenginecr/helper.go Outdated
hyy0322 and others added 2 commits February 4, 2026 11:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Yiyang Huang <huangyiyang.huangyy@bytedance.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Yiyang Huang <huangyiyang.huangyy@bytedance.com>
Copy link
Copy Markdown
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Copy Markdown
Contributor

@wy65701436 wy65701436 left a comment

Choose a reason for hiding this comment

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

lgtm

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 65.93%. Comparing base (c8c11b4) to head (26f13d4).
⚠️ Report is 664 commits behind head on main.

Files with missing lines Patch % Lines
src/pkg/reg/adapter/volcenginecr/helper.go 75.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main   #22810       +/-   ##
===========================================
+ Coverage   45.36%   65.93%   +20.56%     
===========================================
  Files         244     1074      +830     
  Lines       13333   116415   +103082     
  Branches     2719     2937      +218     
===========================================
+ Hits         6049    76760    +70711     
- Misses       6983    35407    +28424     
- Partials      301     4248     +3947     
Flag Coverage Δ
unittests 65.93% <75.00%> (+20.56%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/pkg/reg/adapter/volcenginecr/helper.go 94.28% <75.00%> (ø)

... and 988 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wy65701436 wy65701436 merged commit e6af44d into goharbor:main Feb 4, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/update Update or Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Volc adapter UT not stable

4 participants