Conversation
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
replace Len(..., 0) with Empty(...) in compat integration test
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
use context.WithTimeout per retry to prevent hanging CallUnary from wedging CI
|
|
|
感谢建议 dubbo-go/server/inst_test.go 然后那个文件命名我想请问一下是多加了 integration 这个的原因吗 因为我是看项目里也有类似的命名 比如 triple_case_route_integration_test.go 这样照着写的 |
是的 integration test 是集成测试的意思,但是你加的这些都是单元测试呀 |
AlexStocks
left a comment
There was a problem hiding this comment.
Code review for new config API tests
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| import ( |
There was a problem hiding this comment.
[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()) |
There was a problem hiding this comment.
[P1] 规范级问题:TestNewConfigAPI_CompatRoundTripPreservesKeyFields 函数过长,建议拆分为多个更小的测试函数,每个测试特定配置部分(应用配置、协议配置等),便于维护和定位问题。
| }, | ||
| }, | ||
| } | ||
|
|
There was a problem hiding this comment.
[P0] 阻断级问题:虽然添加了 context.WithTimeout 防止挂起,但错误处理仍可能掩盖底层问题。建议在重试循环中添加更详细的错误日志记录,以便在调试时更容易发现问题根源。
| require.NoError(t, callErr) | ||
| assert.Equal(t, newConfigAPIHelloBody, resp.Value) | ||
| } | ||
|
|
There was a problem hiding this comment.
[P1] 规范级问题:导入顺序不完全符合 Go 语言规范,建议按照标准库、第三方库、项目内模块的顺序整理导入语句。
AlexStocks
left a comment
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
[P1] 规范级问题:测试函数 TestNewConfigAPI_InstanceNewServerNewClientCallUnary 集成了太多步骤,建议将其分解为更小的单元测试。当前的测试涵盖了实例创建、服务注册、客户端连接和调用等多个步骤,不利于故障隔离。
| opts.Protocols = map[string]*global.ProtocolConfig{ | ||
| newConfigAPICompatProtocolID: { | ||
| Name: "tri", | ||
| Ip: "127.0.0.1", |
There was a problem hiding this comment.
[P2] 建议级问题:buildNewConfigAPICompatFixture 函数构建了大量配置项,可考虑使用测试构建器模式或工厂函数简化测试配置的创建,提高可维护性。
| newConfigAPIPriorityServiceMethod = "Ping" | ||
| ) | ||
|
|
||
| type newConfigAPIReferenceSnapshot struct { |
There was a problem hiding this comment.
[P2] 建议级问题:registerNewConfigAPIPriorityService 函数中使用了 require.NotZero 和 require.NotNil,可以考虑添加更多的断言来验证服务选项的其他属性,以增强测试的完整性。



New Config API 集成测试的补全
测试到文件映射表
inst_test.goNewInstance -> NewServer/NewClient -> 实际调用成功dubbo.go、options.go、server/server.go、server/options.go、server/action.go、client/client.go、client/options.go、client/action.go、protocol/options.go、protocol/triple/triple.go、protocol/triple/server.go、protocol/triple/client.go、protocol/triple/triple_invoker.goprio_test.goInstance默认值可被Client/Server覆盖且不互相污染NewServer/NewClient配置注入与覆盖顺序、server/service 生效值、client/reference 生效值dubbo.go、options.go、server/options.go、server/server.go、client/options.go、client/client.go、client/action.gocompat_test.gocompatRootConfig <-> compatInstanceOptions关键字段 round-trip 不丢失compat.go、options.go、global/application_config.go、global/protocol_config.go、global/client_protocol_config.go、global/triple_config.go、global/http3_config.go、global/registry_config.go、global/provider_config.go、global/service_config.go、global/consumer_config.go、global/reference_config.go、global/method_config.go、global/metric_config.go、global/otel_config.go、global/shutdown_config.go、global/custom_config.go、global/profiles_config.go为什么放根目录 :测试是 package dubbo 顶层 API,且 compat 需要访问未导出函数(compatRootConfig/compatInstanceOptions)
未覆盖范围: Nacos/ZK/Apollo 外部联调,不修改 CI 流程,不改 samples
Description
issue #3255
Checklist
develop