Skip to content

Feat/3255 new config api tests#3283

Open
Snow-kal wants to merge 8 commits intoapache:developfrom
Snow-kal:feat/3255-new-config-api-tests
Open

Feat/3255 new config api tests#3283
Snow-kal wants to merge 8 commits intoapache:developfrom
Snow-kal:feat/3255-new-config-api-tests

Conversation

@Snow-kal
Copy link
Copy Markdown
Contributor

@Snow-kal Snow-kal commented Mar 29, 2026

New Config API 集成测试的补全

测试到文件映射表

测试文件 目标 主要覆盖 直接涉及的 New Config API 文件
inst_test.go 验证主链路可用:NewInstance -> NewServer/NewClient -> 实际调用成功 实例初始化、服务注册与导出、客户端引用 dubbo.gooptions.goserver/server.goserver/options.goserver/action.goclient/client.goclient/options.goclient/action.goprotocol/options.goprotocol/triple/triple.goprotocol/triple/server.goprotocol/triple/client.goprotocol/triple/triple_invoker.go
prio_test.go 验证优先级:Instance 默认值可被 Client/Server 覆盖且不互相污染 NewServer/NewClient 配置注入与覆盖顺序、server/service 生效值、client/reference 生效值 dubbo.gooptions.goserver/options.goserver/server.goclient/options.goclient/client.goclient/action.go
compat_test.go 验证 compat 一致性:compatRootConfig <-> compatInstanceOptions 关键字段 round-trip 不丢失 新旧配置模型的转换、nil/空集合边界 compat.gooptions.goglobal/application_config.goglobal/protocol_config.goglobal/client_protocol_config.goglobal/triple_config.goglobal/http3_config.goglobal/registry_config.goglobal/provider_config.goglobal/service_config.goglobal/consumer_config.goglobal/reference_config.goglobal/method_config.goglobal/metric_config.goglobal/otel_config.goglobal/shutdown_config.goglobal/custom_config.goglobal/profiles_config.go

为什么放根目录 :测试是 package dubbo 顶层 API,且 compat 需要访问未导出函数(compatRootConfig/compatInstanceOptions)

未覆盖范围: Nacos/ZK/Apollo 外部联调,不修改 CI 流程,不改 samples

Description

issue #3255

Checklist

  • I confirm the target branch is develop
  • Code has passed local testing
  • I have added tests that prove my fix is effective or that my feature works

cover NewInstance -> NewServer/NewClient -> unary call path with tri direct url

include required SPI imports for cluster/loadbalance and deterministic cleanup
replace broad SPI imports with minimal required ones

set server filter to echo and client cluster to available to reduce registration requirements
cover server and client precedence between instance defaults and per-layer overrides

verify overrides do not pollute later NewServer/NewClient creations
add compat round-trip and nil-handling tests for key config sections

align inst/prio test files with concise English comments following repo style
rename inst/prio/compat test files to integration naming

keep test behavior unchanged and update integration instance name
Copilot AI review requested due to automatic review settings March 29, 2026 08:47
replace Len(..., 0) with Empty(...) in compat integration test
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 adds root-level integration tests to validate the new Config API’s core behavior: end-to-end instance/server/client wiring, option precedence (Instance defaults vs Server/Client overrides), and compat round-trip conversions between the new and legacy config models.

Changes:

  • Add an end-to-end unary invocation integration test using NewInstance -> NewServer/NewClient -> CallUnary.
  • Add priority/override integration tests to ensure Server/Client options override Instance defaults without leaking across subsequent creations.
  • Add compat conversion round-trip tests, including nil/empty-collection edge cases.

Reviewed changes

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

File Description
inst_integration_test.go End-to-end new Config API integration test with real Triple unary invocation.
prio_integration_test.go Tests precedence/isolation of Instance vs Server/Client overrides for group/version.
compat_integration_test.go Tests compat conversion round-trip and nil/empty handling for key config sections.

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

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.08%. Comparing base (fb8eff2) to head (f0062a2).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3283      +/-   ##
===========================================
+ Coverage    48.96%   50.08%   +1.12%     
===========================================
  Files          467      469       +2     
  Lines        34006    34601     +595     
===========================================
+ Hits         16652    17331     +679     
+ Misses       16019    15869     -150     
- Partials      1335     1401      +66     

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

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

use context.WithTimeout per retry to prevent hanging CallUnary from wedging CI
@Alanxtl Alanxtl added 🧹 Updates 3.3.2 version 3.3.2 labels Mar 29, 2026
@Alanxtl Alanxtl linked an issue Mar 29, 2026 that may be closed by this pull request
1 task
@Alanxtl
Copy link
Copy Markdown
Contributor

Alanxtl commented Mar 29, 2026

  1. 这几个文件放到根目录下也太丑陋了
  2. 为什么文件名称是集成测试(integration_test)它和集成测试有什么关系吗

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 5, 2026

@Snow-kal
Copy link
Copy Markdown
Contributor Author

Snow-kal commented Apr 5, 2026

感谢建议
目前是按职责把测试放到 server/client/config 子目录

dubbo-go/server/inst_test.go
dubbo-go/client/prio_test.go
dubbo-go/config/compat_test.go

然后那个文件命名我想请问一下是多加了 integration 这个的原因吗 因为我是看项目里也有类似的命名 比如 triple_case_route_integration_test.go 这样照着写的

@Alanxtl
Copy link
Copy Markdown
Contributor

Alanxtl commented Apr 5, 2026

感谢建议 目前是按职责把测试放到 server/client/config 子目录

dubbo-go/server/inst_test.go dubbo-go/client/prio_test.go dubbo-go/config/compat_test.go

然后那个文件命名我想请问一下是多加了 integration 这个的原因吗 因为我是看项目里也有类似的命名 比如 triple_case_route_integration_test.go 这样照着写的

是的 integration test 是集成测试的意思,但是你加的这些都是单元测试呀

Copy link
Copy Markdown
Contributor

@Alanxtl Alanxtl 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

@AlexStocks AlexStocks left a comment

Choose a reason for hiding this comment

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

Code review for new config API tests

"github.com/stretchr/testify/require"
)

import (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1] 规范级问题:常量命名可以适当缩短以提高可读性,如 newConfigAPIPriorityInstanceGroup 可改为 prioTestInstanceGroup。过长的标识符降低了代码的可读性。

// TestNewConfigAPI_CompatRoundTripPreservesKeyFields verifies that the
// compatibility bridge keeps key fields consistent in root config.
func TestNewConfigAPI_CompatRoundTripPreservesKeyFields(t *testing.T) {
_, err := dubbo.NewInstance(buildNewConfigAPICompatFixture())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1] 规范级问题:TestNewConfigAPI_CompatRoundTripPreservesKeyFields 函数过长,建议拆分为多个更小的测试函数,每个测试特定配置部分(应用配置、协议配置等),便于维护和定位问题。

},
},
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P0] 阻断级问题:虽然添加了 context.WithTimeout 防止挂起,但错误处理仍可能掩盖底层问题。建议在重试循环中添加更详细的错误日志记录,以便在调试时更容易发现问题根源。

require.NoError(t, callErr)
assert.Equal(t, newConfigAPIHelloBody, resp.Value)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1] 规范级问题:导入顺序不完全符合 Go 语言规范,建议按照标准库、第三方库、项目内模块的顺序整理导入语句。

Copy link
Copy Markdown
Contributor

@AlexStocks AlexStocks left a comment

Choose a reason for hiding this comment

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

Additional code review comments

"dubbo.apache.org/dubbo-go/v3/protocol"
_ "dubbo.apache.org/dubbo-go/v3/protocol/triple"
tri "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol"
_ "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1] 规范级问题:测试函数 TestNewConfigAPI_InstanceNewServerNewClientCallUnary 集成了太多步骤,建议将其分解为更小的单元测试。当前的测试涵盖了实例创建、服务注册、客户端连接和调用等多个步骤,不利于故障隔离。

opts.Protocols = map[string]*global.ProtocolConfig{
newConfigAPICompatProtocolID: {
Name: "tri",
Ip: "127.0.0.1",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] 建议级问题:buildNewConfigAPICompatFixture 函数构建了大量配置项,可考虑使用测试构建器模式或工厂函数简化测试配置的创建,提高可维护性。

newConfigAPIPriorityServiceMethod = "Ping"
)

type newConfigAPIReferenceSnapshot struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] 建议级问题:registerNewConfigAPIPriorityService 函数中使用了 require.NotZero 和 require.NotNil,可以考虑添加更多的断言来验证服务选项的其他属性,以增强测试的完整性。

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Proposal] Integration test new Config API

5 participants