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

[ISSUE #8092] Fixed non-idempotent test #8093

Merged
merged 2 commits into from
May 8, 2024
Merged

Conversation

kaiyaok2
Copy link
Contributor

@kaiyaok2 kaiyaok2 commented May 5, 2024

Which Issue(s) This PR Fixes

Fixes #8092

Brief Description

The test org.apache.rocketmq.filter.FilterSpiTest#testRegister is non-idempotent, as it passes in the first run but fails in the second run in the same JVM. The test fails in subsequent runs in the same environment because it registers a NothingFilter without unregistering it. The repeated run will then throw a Filter already exist error. A fix is recommended as unit tests shall be idempotent, and state pollution shall be mitigated so that newly introduced tests do not fail in the future due to polluted shared states.

Failure Message in the 2nd Run:

java.lang.IllegalArgumentException: Filter spi type(Nothing) already exist!
	at org.apache.rocketmq.filter.FilterFactory.register(FilterFactory.java:44)
	at org.apache.rocketmq.filter.FilterSpiTest.testRegister(FilterSpiTest.java:53)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)

How Did You Test This Change?

Unset NothingFilter before exiting the test. All tests pass and are idempotent after the fix.

@kaiyaok2 kaiyaok2 changed the title fixed non-idempotent test [ISSUE #8092] Fixed non-idempotent test May 5, 2024
@cserwen
Copy link
Member

cserwen commented May 7, 2024

rebase with the latest develop branch which has fixed some errors of check @kaiyaok2

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 42.86%. Comparing base (1a2fc17) to head (9db1d3f).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #8093      +/-   ##
=============================================
+ Coverage      42.84%   42.86%   +0.02%     
- Complexity     10351    10362      +11     
=============================================
  Files           1270     1270              
  Lines          88690    88690              
  Branches       11399    11399              
=============================================
+ Hits           37998    38020      +22     
+ Misses         45993    45979      -14     
+ Partials        4699     4691       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RongtongJin RongtongJin merged commit 52c5d89 into apache:develop May 8, 2024
10 checks passed
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.

[Bug] Non-idempotent unit test org.apache.rocketmq.filter.FilterSpiTest#testRegister
4 participants