apache / apache/brpc

讨论brpc框架的UT实现

Open
#2,460 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
17.6k
Forks
4.1k
Avg merge
2d 12h
Merged PRs (30d)
69

Description

**Is your feature request related to a problem? (你需要的功能是否与某个问题有关?)**

**Describe the solution you'd like (描述你期望的解决方法)**

**Describe alternatives you've considered (描述你想到的折衷方案)**

**Additional context/screenshots (更多上下文/截图)**

想请教一下大家,怎样比较优雅地实现 UT。我目前的代码的角色是 brpc client,然后我 mock 了一个 brpc service,让它在本地端口启动,然后让我的业务代码去向那个临时端口发请求,以验证我的业务逻辑。
现在问题有两个,一个ut没法并行运行,因为它们要占用同一个测试端口,如果给每一个ut都配一个端口,端口数量不太够。
第二个是 ut 运行的时候,本地端口的通信总是会有一些问题,可能是之前的请求的残留或是其他,而且在 valgrind 测试时,rpc框架就更慢了,这有时候导致rpc超时进而ut失败。

所以想请教一下,有没有办法,通过mock直接把rpc层绕过,让我的client层直接调用mock service。

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are named. Start by examining the existing client and mocked-service test setup, then clarify the intended mock boundary and acceptance criteria for parallel execution, port allocation, and Valgrind-safe timeout behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.