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

Fixing test-order dependency in org.apache.dubbo.rpc.cluster.StickyTest #2807

Merged
merged 1 commit into from
Dec 10, 2018

Conversation

OrDTesters
Copy link
Contributor

What is the purpose of the change

There are test-order dependencies in org.apache.dubbo.rpc.cluster.StickyTest. testStickyNoCheck fails when run after testStickyForceCheck. The tests depend on the same LoadBalance instance, which enters a different state after testStickyForceCheck runs, which then results in testStickNoCheck to fail when it runs.

The proposed fix introduces a method in ExtensionLoader to reset cached ExtensionLoader instances, for testing purposes only. StickyTest can then use this method to reset the ExtensionLoader for LoadBalance between test runs.

Brief changelog

dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/StickyTest.java
dubbo-common/src/main/java/org/apache/dubbo/common/extension/ExtensionLoader.java

@codecov-io
Copy link

Codecov Report

Merging #2807 into master will increase coverage by 1.03%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2807      +/-   ##
=========================================
+ Coverage   62.46%   63.5%   +1.03%     
=========================================
  Files         599     577      -22     
  Lines       27919   25939    -1980     
  Branches     4829    4543     -286     
=========================================
- Hits        17440   16472     -968     
+ Misses       8213    7302     -911     
+ Partials     2266    2165     -101
Impacted Files Coverage Δ
...apache/dubbo/common/extension/ExtensionLoader.java 80.78% <88.88%> (+0.14%) ⬆️
.../remoting/transport/netty4/NettyClientHandler.java 75% <0%> (-11.12%) ⬇️
...he/dubbo/remoting/transport/netty/NettyClient.java 72.88% <0%> (-10.17%) ⬇️
.../apache/dubbo/remoting/transport/AbstractPeer.java 58.69% <0%> (-8.7%) ⬇️
...in/java/org/apache/dubbo/common/utils/JVMUtil.java 73.58% <0%> (-7.55%) ⬇️
...ng/exchange/support/header/HeartbeatTimerTask.java 73.68% <0%> (-5.27%) ⬇️
.../apache/dubbo/qos/protocol/QosProtocolWrapper.java 64.1% <0%> (-5.13%) ⬇️
...rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java 54.21% <0%> (-3.62%) ⬇️
...pache/dubbo/remoting/transport/AbstractServer.java 45.36% <0%> (-3.1%) ⬇️
...pache/dubbo/remoting/transport/AbstractClient.java 65.94% <0%> (-2.17%) ⬇️
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ea6b33...2224f8d. Read the comment docs.

@carryxyh
Copy link
Member

I will have a check.

@carryxyh
Copy link
Member

I can't reproduce this problem on my mac.
I tried:

  1. run testStickyForceCheck and then run testStickyNoCheck. UT passed.
    2.run the whole test. UT passed.
    3.move the test method testStickyForceCheck before testStickyNoCheck. UT passed.

Is my reproduce way is wrong?

@OrDTesters
Copy link
Contributor Author

The two tests have to be run in the same JVM. The order of the tests written in the file does not control the order that they are actually run by JUnit. To reproduce this issue, there is a way to force JUnit to run the tests in a specific order.

Add the annotation @org.junit.FixMethodOrder(org.junit.runners.MethodSorters.NAME_ASCENDING) to the test class. This will force JUnit to run the tests in the ascending alphabetical order of their names, so testStickyForceCheck will run before testStickyNoCheck.

Since without FixMethodOrder the order of the tests is not guaranteed, it is best to make sure the tests can pass when they are run in any order.

@carryxyh
Copy link
Member

I can reproduce this problem.
I am not sure if this modification is best. Maybe someone else can give a review.

@beiwei30 beiwei30 merged commit aa5637e into apache:master Dec 10, 2018
khanimteyaz pushed a commit to khanimteyaz/incubator-dubbo that referenced this pull request Dec 17, 2018
beiwei30 pushed a commit that referenced this pull request Dec 17, 2018
* added dubbo-rpc-api filter documentation for issue no #2935

* wrong @see java.io.File was added, removed this version of checkins

* Close all ports after tests finish (#2906)

* fix testCustomExecutor (#2904)

* Graceful shutdown enhancement in Spring (#2901)

* Simplify the code logic of the method AbstractClusterInvoker#reselect. (#2826)

* Simplify the code logic of the method AbstractClusterInvoker#reselect.

* Minor modification for code style.

* create AbstractRouter (#2909)

* create AbstractRouter

* router default method

* router default method

* router default method

* mockinvoker

* Added javadoc for dubbo-filter module dubbo github issue 2884 (#2921)

* Enhance unit test (#2920)

* Change Readme dubbo-sample hyperlink (#2927)

* Simply TagRouter (#2924)

* make telnet config work again (#2925)

* Remove the log to putRandomPort when one protocol use random port (#2931)

* optimize findConfigedPorts method of ServiceConfig to log only one time when userandom port

* move the log to method putRandomPort

* Fix DubboShutdownHook Memory Leak (#2922)

* Improve UT grammar and remove unnecessary braces. (#2930)

* Improve UT grammer, fix compiler warnings.

* Remove unnecessary braces.

* re-enable testCustomExecutor  (#2917)

* fix testCustomExecutor

* fix ci

* Fixing test-order dependency for FstObjectInputTest (#2815)

* re-enable testCustomExecutor (#2913)

* Resetting ExtensionLoader to remove test order dependencies in StickyTest (#2807)

* optimize the RondRobinLoadBalance and MockClusterInvoker (#2932)

delete unused logic and take the logger out.

* [Dubbo-2864] Fix build failed with -Prelease (#2923)

fixes #2864

* Fix telnet can not find method with enum type (#2803)

* [dubbo-2766] fix the bug of isMatch method of InvokeTelnetHandler (#2787)

* enhance org.apache.dubbo.rpc.protocol.dubbo.telnet.InvokeTelnetHandler#isMatch (#2941)

* enhance isMatch

* remove useless imports

* [Dubbo-2766]Fix 2766 and enhance the invoke command (#2801)

* add getter and setter for ServiceConfig's interfaceName property#2353

* add interfaceName to ignoreAttributeNames and change the unit test

* delete the demo source code and update the unit test

* unchange ServiceConfig

* update unit test

* update unit test

* fix #2798 and enhance invoke command

* Delete useless assignments (#2939)

* Replace anonymous class with method reference (#2929)

* Replace anonymous class with method reference

* Revert changes as per @beiwei30 code review

* Optimize retry for FailbackRegistry. (#2763)

* Abstract retry task

* Task for retry.

* Fix sth.

* Finish Optimize. fix ci failed.

* Optimize retry for FailbackRegistry.
The retry operation splits into specific operations, such as subscriptions and registrations. This approach allows for very precise retry control.

* Optimize retry for FailbackRegistry.
The retry operation splits into specific operations, such as subscriptions and registrations. This approach allows for very precise retry control.

* Optimize logger warn's msg.

* Optimize FailedNotifiedTask's run method.
Optimize addXXXTask, directly return if we already have a retry task.

* Optimize notify logic, just notify when the urls is not empty.

* Optimize notify logic, just notify when the urls is not empty.

* Optimize timer that use daemon thread.

* standardize semantics of all mergers,enhance mergeFactory and testcase (#2936)

* Modified to lower camel case (#2945)

* Improve several map iteration (#2938)

* added dubbo-rpc-api filter documentation for issue no #2935

* wrong @see java.io.File was added, removed this version of checkins
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