test: 修复测试依赖本地网络环境和权限问题 - #24
Merged
XuHenghenglumia merged 2 commits intoJul 31, 2026
Merged
Conversation
- TestPing 改用公网稳定地址 1.1.1.1,不再硬编码局域网 IP - TestPingWithInvalidIP 改用 IANA 保留地址 192.0.2.1 - CI test 步骤加 sudo(ICMP 需要 root 权限) - Makefile 去掉无效的 -tags integration
GitHub Actions 禁止出站 ICMP,公网地址在 CI 中永远不可达。 回环地址不依赖出站网络,与 TestPingWithLocalhost 合并。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动内容
修复
pkg/lmap/ping_test.go的 3 个问题(详见 #23):TestPing硬编码了局域网 IP192.168.0.106→ 改为公网稳定地址1.1.1.1,不再依赖本地网络环境TestPingWithInvalidIP使用0.0.0.0→ 改为 IANA 保留的 TEST-NET-1 地址192.0.2.1(该地址永不响应,测试结果稳定)sudo-tags integration没有对应 build tag → 删除无效标签验证
gofmt -s -d通过go build通过go vet通过说明
本地非 root 用户跑 ICMP 测试仍会报
operation not permitted,这是系统权限限制,CI 加 sudo 后即可正常执行。Fixes #23