-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fix] [test] Fix flaky test MetadataStoreStatsTest.testBatchMetadataStoreMetrics
#19793
[fix] [test] Fix flaky test MetadataStoreStatsTest.testBatchMetadataStoreMetrics
#19793
Conversation
1. set metadata store name to avoid generate metric with name cause relate unit test fail. 2. auto generate metadata store name if caller not specify one for avoid this problem occur again.
@lifepuzzlefun Please add the following content to your PR description and select a checkbox:
|
the auto generate metadata store name will be like I made some change in my local repo to capture the caller lifepuzzlefun#10 and see CI job fail message which wil print stack trace if check metric tag with name empty and make unit test fail. |
Is the root cause that the metadatastoreName is empty? |
@nodece The root cause is create one MetadataStore with no name set and not close it. |
@Override | ||
public MetadataStoreConfig build() { | ||
if (Strings.isEmpty(this.callerSetMetadataStoreName)) { | ||
Exception e = new Exception("stack trace"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can throw an exception, so like:
throw new IllegalArgumentException("metadataStoreName is required");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. the problem is there is a lot of ut didn't set name. If they don't set name but they close the object the flaky test won't occur.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So can we just need to close the metadatastore to fix the flaky test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, other modification is for this case not happen again and supply some method to find the wrong usage.
the modification won't hurt production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, other modification is for this case not happen again and supply some method to find the wrong usage.
Makes sense! But this is rare.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes i agree with you. maybe we can add one comment in this unit test point to the current modification to catch up new wrong usage. and the branch will be retain for those who is block by this problem.
I'll remove the current metadataStore name generate code for this patch to merge.
pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/MetadataStoreStatsTest.java
Outdated
Show resolved
Hide resolved
...ker/src/test/java/org/apache/pulsar/broker/zookeeper/MultiBrokerMetadataConsistencyTest.java
Outdated
Show resolved
Hide resolved
/pulsarbot rerun-failure-checks |
/pulsarbot rerun-failure-checks |
This fix is invalid, see https://github.com/apache/pulsar/actions/runs/4424020709/jobs/7763604452#step:11:1277 |
Fixes #19792
Motivation
Fix flaky test
MetadataStoreStatsTest.testBatchMetadataStoreMetrics
some unit test create MetadataStore without setting name and not close will cause prometheus metric not unregisterd.
the unittest above will check promethues metric tag name not null.
Modifications
set metadata store name to avoid generate metric with name cause relate unit test fail.
auto generate metadata store name if caller not specify one for avoid this problem occur again.
Verifying this change
This change is already covered by existing tests, such as (please describe tests).
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: