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

Use singleton RegistryProtocol in tests #3849

Merged
merged 1 commit into from
Apr 12, 2019

Conversation

OrDTesters
Copy link
Contributor

What is the purpose of the change

Currently some tests in RegistryProtocolTest do not use the RegistryProtocol.getRegistryProtocol() method to get the singleton RegistryProtocol instance. These tests directly create new instances of RegistryProtocol, which changes the singleton to point to the newly created instance. Doing so leads to tests in test class to fail when run in certain orders. For example, running the tests [testNotifyOverride_notmatch, testExportUrlNull, testNotifyOverride] in that exact order leads to testNotifyOverride to fail.

The proposed change is to have every test use the RegistryProtocol.getRegistryProtocol() method to get the same instance of RegistryProtocol.

Brief changelog

dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryProtocolTest.java

Copy link
Contributor

@chenlushun chenlushun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you send an error stack?

@OrDTesters
Copy link
Contributor Author

OrDTesters commented Apr 11, 2019

For example, when the tests [testNotifyOverride_notmatch, testExportUrlNull, testNotifyOverride] are run in this order, the test testNotifyOverride fails with the error:

testNotifyOverride Time elapsed: 0.022 s <<< ERROR!

java.util.NoSuchElementException
    at org.apache.dubbo.registry.dubbo.RegistryProtocolTest.getListener(RegistryProtocolTest.java:185)
    at org.apache.dubbo.registry.dubbo.RegistryProtocolTest.testNotifyOverride(RegistryProtocolTest.java:111)

@ralf0131
Copy link
Contributor

Hi, I can reproduce this issue by adding the following code:

    @Test
    public void test() throws Exception {
        testNotifyOverride_notmatch();
        testExportUrlNull();
        testNotifyOverride();
    }

Excpetion:

java.util.NoSuchElementException
	at java.base/java.util.concurrent.ConcurrentHashMap$ValueIterator.next(ConcurrentHashMap.java:3473)
	at org.apache.dubbo.registry.dubbo.RegistryProtocolTest.getListener(RegistryProtocolTest.java:189)
	at org.apache.dubbo.registry.dubbo.RegistryProtocolTest.testNotifyOverride(RegistryProtocolTest.java:116)
	at org.apache.dubbo.registry.dubbo.RegistryProtocolTest.test(RegistryProtocolTest.java:86)
	...

I think you are right, we should use RegistryProtocol.getRegistryProtocol() instead.

@ralf0131 ralf0131 merged commit 1706807 into apache:master Apr 12, 2019
vio-lin pushed a commit to vio-lin/incubator-dubbo that referenced this pull request Apr 29, 2019
@ralf0131
Copy link
Contributor

@OrDTesters I am trying to contact you privately, but got no response from ordtesters at gmail.com. If you happen to receive this message please check your email, or contact me privately via huxing at apache.org

@cvictory cvictory added this to the 2.7.2 milestone May 28, 2019
@OrDTesters
Copy link
Contributor Author

Hello, I am very sorry for having not respond in so long. Please let me know if there is anything more you want to discuss.

@ralf0131
Copy link
Contributor

ralf0131 commented Aug 4, 2019

@OrDTesters Please check you email: ordtesters at gmail.com. I have sent an email to that address in April or May. You can also leave me an email address that you can receive email, or contact me privately via huxing at apache.org

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

Successfully merging this pull request may close these issues.

4 participants