You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by "overlogged (via GitHub)" <gi...@apache.org> on 2023/12/01 07:10:52 UTC
[I] 讨论brpc框架的UT实现 (brpc)
overlogged opened a new issue, #2460:
URL: https://github.com/apache/brpc/issues/2460
**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。
--
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: dev-unsubscribe@brpc.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [I] 讨论brpc框架的UT实现 (brpc)
Posted by "TousakaRin (via GitHub)" <gi...@apache.org>.
TousakaRin commented on issue #2460:
URL: https://github.com/apache/brpc/issues/2460#issuecomment-1870791629
gmock应该是可以把 channel 的 CallMethod 直接 mock 掉,替换成你想要的逻辑。但是这样的话可能会对代码有入侵(即用于 rpc 的 channel 是从外部传递进来的)。
--
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: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [I] 讨论brpc框架的UT实现 (brpc)
Posted by "wwbmmm (via GitHub)" <gi...@apache.org>.
wwbmmm commented on issue #2460:
URL: https://github.com/apache/brpc/issues/2460#issuecomment-1861998351
不用每个UT都启动一个server吧。可以启动一个公共的server,然后不同的UT运行不同的client就可以了
--
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: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org