Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two junit tests failed #3657

Closed
2 tasks done
zhaixiaoxiang opened this issue Mar 14, 2019 · 1 comment
Closed
2 tasks done

Two junit tests failed #3657

zhaixiaoxiang opened this issue Mar 14, 2019 · 1 comment

Comments

@zhaixiaoxiang
Copy link
Contributor

zhaixiaoxiang commented Mar 14, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Steps to reproduce this issue

Run AbstractMonitorFactoryTest.testMonitorFactoryGroupCache() or DubboMonitorTest.testCount() many times(may be less than 10 is enough), you will get junit test failed.

Cause Analysis

  • AbstractMonitorFactoryTest.testMonitorFactoryGroupCache()

In AbstractMonitorFactory.getMonitor(), if we call thenRunAsync() first, then call FUTURES.put(),
in MonitorListener.run, FUTRUE.get() may get null, then the junit test failed.
image

image

image


  • DubboMonitorTest.testCount()
  1. In DubboMonitor constructor, we starter a schedule that call send() every 20 milliseconds!!
  2. In testCount(), we collect() first, then send(), and send() every 20 milliseconds backend, but we will reset data in send() everytime, so let's consider this sequence: we call collect(), and then call send(), and before Assertions.assertEquals... , call send() backend by the schedule to reset the statisticsMap.

image

image

image

image

I describe it in Chinese again:
这个问题是偶现的, 但是可以通过多次执行testCount()来复现(执行最多10次一般就能复现出来), 原因是, 在构造Du bboMonitor 的时候, 会启动一个定时器, 每个20毫秒来执行send()方法, 且在send()设置值以后, 就会reset 全局的statisticsMap, testCount()中考虑这么一个执行顺序: 先执行collect(), 在执行send(), 然后在执行诸多的Assertions.assertEquals之前, 可能会执行每20毫秒执行一次的send(), 在这个send()方法执行完成后, statisticsMap就会被重置, 导致junit test失败

@zhaixiaoxiang zhaixiaoxiang changed the title Test AbstractMonitorFactoryTest.testMonitorFactoryGroupCache() may failed. Two junit tests failed Mar 15, 2019
zhaixiaoxiang added a commit to zhaixiaoxiang/incubator-dubbo that referenced this issue Mar 15, 2019
@ralf0131
Copy link
Contributor

This issue has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants