Skip to content

Two junit tests failed #3657

Closed
Closed

Description

@maoyiz
  • 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失败

Activity

  1. changed the title [-]Test AbstractMonitorFactoryTest.testMonitorFactoryGroupCache() may failed.[/-] [+]Two junit tests failed[/+] on Mar 15, 2019
  2. ralf0131 commented on Mar 19, 2019

    @ralf0131
    Contributor

    This issue has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions