lizining1231 commented on code in PR #3590:
URL: https://github.com/apache/dubbo-go/pull/3590#discussion_r3720263347
##########
Makefile:
##########
@@ -40,6 +41,12 @@ test: clean
GOTOOLCHAIN=go1.25.0+auto go test ./... -coverprofile=coverage.txt
-covermode=atomic
cd $(CLI_DIR) && GOTOOLCHAIN=go1.25.0+auto go test ./...
+# Run race detector on packages that start background goroutines in tests.
+# TestServiceDiscoveryRegistryUnRegister_Concurrent intentionally simulates a
+# data race, so it is excluded from the race detector via -skip.
+test-race:
+ GOTOOLCHAIN=go1.25.0+auto go test -race ./registry/servicediscovery/...
-skip '^TestServiceDiscoveryRegistryUnRegister_Concurrent$$'
+
Review Comment:
好的, 感谢review! 我已尝试做出此改动, 发现报错多处原有问题。具体情形如下:
### 原始报错日志
```text
=== ERROR SUMMARY (grep of FAIL/DATA RACE) ===
32:WARNING: DATA RACE
75:--- FAIL: TestFailbackRetryFailed (2.10s)
76: testing.go:1617: race detected during execution of test
227:WARNING: DATA RACE
274:--- FAIL: TestFailbackOutOfLimit (0.01s)
275: testing.go:1617: race detected during execution of test
276:FAIL
277:FAIL dubbo.apache.org/dubbo-go/v3/cluster/cluster/failback 4.346s
306:WARNING: DATA RACE
349:--- FAIL: TestRouteCacheGenerationRace (1.02s)
350: testing.go:1617: race detected during execution of test
351:FAIL
352:FAIL dubbo.apache.org/dubbo-go/v3/cluster/router/chain 1.155s
373:WARNING: DATA RACE
417:WARNING: DATA RACE
475:WARNING: DATA RACE
529:WARNING: DATA RACE
579:WARNING: DATA RACE
627:WARNING: DATA RACE
675:WARNING: DATA RACE
728:--- FAIL: TestListener (4.02s)
729: testing.go:1617: race detected during execution of test
730:FAIL
731:FAIL dubbo.apache.org/dubbo-go/v3/config_center/apollo 4.265s
1104:WARNING: DATA RACE
1231:--- FAIL: TestDubboProtocol_Refer (0.01s)
1232: testing.go:1617: race detected during execution of test
1233:FAIL
1234:FAIL dubbo.apache.org/dubbo-go/v3/protocol/dubbo 6.373s
1242:WARNING: DATA RACE
1280:WARNING: DATA RACE
1322:WARNING: DATA RACE
1364:WARNING: DATA RACE
1406:--- FAIL: TestGrpcHealthWatchEmitsClosingEvent (0.03s)
1407: testing.go:1617: race detected during execution of test
1637:FAIL
1638:FAIL dubbo.apache.org/dubbo-go/v3/protocol/grpc 0.464s
1715:WARNING: DATA RACE
1753:WARNING: DATA RACE
1791:WARNING: DATA RACE
1833:WARNING: DATA RACE
1870:--- FAIL: TestServiceDiscoveryRegistryUnRegister_Concurrent (0.03s)
1871: testing.go:1617: race detected during execution of test
1902:FAIL
1903:FAIL dubbo.apache.org/dubbo-go/v3/registry/servicediscovery 0.189s
1985:WARNING: DATA RACE
2045:WARNING: DATA RACE
2172:--- FAIL: TestTCPPackageHandle (2.01s)
2173: testing.go:1617: race detected during execution of test
2174:FAIL
2175:FAIL dubbo.apache.org/dubbo-go/v3/remoting/getty 4.163s
2325:WARNING: DATA RACE
2393:WARNING: DATA RACE
2461:WARNING: DATA RACE
2531:--- FAIL: TestCfgAPI_Export (0.00s)
2532: testing.go:1617: race detected during execution of test
2545:FAIL
2546:FAIL dubbo.apache.org/dubbo-go/v3/server 1.288s
2548:FAIL
```
### 对应测试与源码
| 包 | 测试 | 测试位置 | 相关源码位置 |
|---|---|---|---|
| `cluster/cluster/failback` | TestFailbackRetryFailed |
[cluster_test.go#L136-L180](https://github.com/apache/dubbo-go/blob/master/cluster/cluster/failback/cluster_test.go#L136-L180)
|
[cluster_invoker.go#L109](https://github.com/apache/dubbo-go/blob/master/cluster/cluster/failback/cluster_invoker.go#L109)
/
[L198-L212](https://github.com/apache/dubbo-go/blob/master/cluster/cluster/failback/cluster_invoker.go#L198-L212)
|
| `cluster/cluster/failback` | TestFailbackOutOfLimit |
[cluster_test.go#L231-L263](https://github.com/apache/dubbo-go/blob/master/cluster/cluster/failback/cluster_test.go#L231-L263)
|
[cluster_invoker.go#L95](https://github.com/apache/dubbo-go/blob/master/cluster/cluster/failback/cluster_invoker.go#L95)
/
[L173](https://github.com/apache/dubbo-go/blob/master/cluster/cluster/failback/cluster_invoker.go#L173)
|
| `cluster/router/chain` | TestRouteCacheGenerationRace |
[chain_test.go#L423-L474](https://github.com/apache/dubbo-go/blob/master/cluster/router/chain/chain_test.go#L423-L474)
|
[chain_test.go#L386](https://github.com/apache/dubbo-go/blob/master/cluster/router/chain/chain_test.go#L386)
/
[L401](https://github.com/apache/dubbo-go/blob/master/cluster/router/chain/chain_test.go#L401)
|
| `config_center/apollo` | TestListener |
[impl_test.go#L257-L288](https://github.com/apache/dubbo-go/blob/master/config_center/apollo/impl_test.go#L257-L288)
|
[listener.go#L56](https://github.com/apache/dubbo-go/blob/master/config_center/apollo/listener.go#L56)
/
[L68](https://github.com/apache/dubbo-go/blob/master/config_center/apollo/listener.go#L68)
/
[L74](https://github.com/apache/dubbo-go/blob/master/config_center/apollo/listener.go#L74);
[impl_test.go#L98](https://github.com/apache/dubbo-go/blob/master/config_center/apollo/impl_test.go#L98)
vs
[L261](https://github.com/apache/dubbo-go/blob/master/config_center/apollo/impl_test.go#L261)[impl_test.go#L300-L302](https://github.com/apache/dubbo-go/blob/master/config_center/apollo/impl_test.go#L300-L302)
vs
[L273-L274](https://github.com/apache/dubbo-go/blob/master/config_center/apollo/impl_test.go#L273-L274)
|
| `protocol/dubbo` | TestDubboProtocol_Refer |
[dubbo_protocol_test.go#L129-L152](https://github.com/apache/dubbo-go/blob/master/protocol/dubbo/dubbo_protocol_test.go#L129-L152)
| 第三方
dubbo-getty:[session.go#L857](https://github.com/apache/dubbo-getty/blob/v1.4.10/session.go#L857)
/
[connection.go#L277-L278](https://github.com/apache/dubbo-getty/blob/v1.4.10/connection.go#L277-L278)
|
| `protocol/grpc` | TestGrpcHealthWatchEmitsClosingEvent |
[active_notify_test.go#L88-L139](https://github.com/apache/dubbo-go/blob/master/protocol/grpc/active_notify_test.go#L88-L139)
|
[active_notify_test.go#L51](https://github.com/apache/dubbo-go/blob/master/protocol/grpc/active_notify_test.go#L51)
/
[L133](https://github.com/apache/dubbo-go/blob/master/protocol/grpc/active_notify_test.go#L133)
|
| `registry/servicediscovery` |
TestServiceDiscoveryRegistryUnRegister_Concurrent |
[service_discovery_registry_test.go#L1307-L1371](https://github.com/apache/dubbo-go/blob/master/registry/servicediscovery/service_discovery_registry_test.go#L1307-L1371)
|
[service_discovery_registry_test.go#L1368](https://github.com/apache/dubbo-go/blob/master/registry/servicediscovery/service_discovery_registry_test.go#L1368)
|
| `remoting/getty` | TestTCPPackageHandle |
[readwriter_test.go#L45-L50](https://github.com/apache/dubbo-go/blob/master/remoting/getty/readwriter_test.go#L45-L50)
|
[readwriter.go#L128](https://github.com/apache/dubbo-go/blob/master/remoting/getty/readwriter.go#L128)
/
[getty_server.go#L116-L117](https://github.com/apache/dubbo-go/blob/master/remoting/getty/getty_server.go#L116-L117)
|
| `server` | TestCfgAPI_Export |
[inst_test.go#L85-L90](https://github.com/apache/dubbo-go/blob/master/server/inst_test.go#L85-L90)
|
[triple_protocol/server.go#L200](https://github.com/apache/dubbo-go/blob/master/protocol/triple/triple_protocol/server.go#L200)
/
[L326](https://github.com/apache/dubbo-go/blob/master/protocol/triple/triple_protocol/server.go#L326)
|
部分测试不类似于测试 TestServiceDiscoveryRegistryUnRegister_Concurrent 故意制造竞态, 与
test-race 冲突, 我不确定是否能用 -skip
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]