ywxzm03 commented on PR #148:
URL: 
https://github.com/apache/dubbo-go-pixiu-samples/pull/148#issuecomment-4451600496

   > Read-only review: 发现 1 个 P0、1 个 P1 问题。golangci-lint 未运行,当前环境缺少 
golangci-lint;go test ./https/test -run Test -count=1 未完成,测试依赖本地 8443 HTTPS 
样例服务,5 分钟超时
   
   这里的 `go test ./https/test` 不是该样例的预期运行入口
   
   `https/test` 是依赖外部样例环境的集成测试,不是可以单独运行的单元测试。它本身不会启动 Pixiu、Dubbo 
provider、Zookeeper,也不会准备 HTTPS 证书。它只会向 `https://sample.domain.com:8443` 发请求
   
   这个样例需要通过:
   
   `./integrate_test.sh https`
   
   来运行。脚本会先通过 Docker Compose 启动 Pixiu、Dubbo provider、Zookeeper 
和证书初始化任务,然后再执行集成测试
   
   直接运行 `go test ./https/test` 会失败/超时,主要是因为必要的样例环境没有被拉起:
   
   - `go test` 不会启动 Pixiu,因此本地 `8443` 上没有 HTTPS 服务可访问
   - `go test` 不会启动证书初始化任务,也不会为 Pixiu 准备 `sample.domain.com` 的本地证书缓存
   - `go test` 不会启动 Zookeeper 和 Dubbo provider
   - 当前 Pixiu 和 provider 配置中的 Zookeeper 地址是 `zookeeper:2181`,这是 Docker Compose 
网络里的 service name;如果绕开 Compose、改为宿主机直接启动相关进程,这个地址通常无法解析
   
   这里使用 Docker Compose 是有意设计的,主要原因是:
   
   - Pixiu v1.1.0 的 HTTPS listener 使用 autocert,并会监听标准 HTTPS 端口 `443`;如果直接在宿主机启动 
Pixiu,普通用户进程在 macOS/Linux 上无法稳定监听 `443`
   - 本地样例不能依赖真实 ACME 证书申请,所以 Compose 中增加了 `pixiu-cert-init`,用于生成 
`sample.domain.com` 的本地自签证书缓存
   - Pixiu、provider 和 Zookeeper 放在同一个 Docker Compose 网络中,可以保证 provider 注册到 
Zookeeper 的地址能被 Pixiu 访问
   
   因此,直接运行 `go test ./https/test` 超时是预期内的,因为必要的样例环境没有启动;正确的验证方式是运行 
`./integrate_test.sh https`
   
   如果一定希望 `go test ./https/test` 也能独立触发完整链路,那就需要让测试本身负责拉起和清理 Docker 
Compose,或者在测试里间接调用 `./integrate_test.sh https`,但似乎会显得有些臃肿


-- 
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]

Reply via email to