zrlw edited a comment on issue #8689:
URL: https://github.com/apache/dubbo/issues/8689#issuecomment-917364813


   总结一下截止目前发现的主要问题:
   1. 部分测试类执行结果影响后续测试类执行结果
   有些测试类测试结束后,运行环境并未恢复,会影响下一个测试类执行结果,甚至导致下一个测试类的测试方法抛异常。
   比如dubbo-config-api,对其单独做junit测试, 
ReferenceConfigTest测试之后会影响ServiceConfigTest测试,后者testServiceListener方法执行MockServiceListener
 mockServiceListener = (MockServiceListener) 
extensionLoader.getExtension("mock")语句时会抛异常。
   2. 部分测试类需要其他测试类预先设置环境(吐个槽,这种测试类还是UT么?)
   比如DubboTelnetDecodeTest这个测试类,如果单独跑junit测试,就是这样的结果:
   [ERROR]   DubboTelnetDecodeTest.testDubboDecode:127 expected: <1> but was: 
<0>
   [ERROR]   DubboTelnetDecodeTest.testDubboDubboDecoded:381 expected: <2> but 
was: <0>
   [ERROR]   DubboTelnetDecodeTest.testDubboTelnetDecoded:452 expected: <2> but 
was: <1>
   [ERROR]   DubboTelnetDecodeTest.testTelnetDubboDecoded:243 expected: <2> but 
was: <1>
   3. 
测试类每个测试方法执行结束后执行DubboBootstrap.reset()或destroy()释放全局资源(比如关闭zk连接)与仍在运行中的dubbo守护线程(如DubboSaveMetadataReport)之间存在冲突,可能触发后续测试方法执行失败。
   
   解决问题1需要将forkMode设置为always:为每个测试类创建一个单独的进程,然后顺序执行每个测试类,以避免环境污染;
   解决问题2需要将forkMode设置为once:所有测试类共享一个测试进程;
   所以如果不修改测试类,问题1和2是无解的。
   
   问题3可以在释放全局资源时停止相关的dubbo线程,代价是集成构建时间变长了,可以试试效果。
   


-- 
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: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to