[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.
I think you can throw an exception, so like:
throw new IllegalArgumentException("metadataStoreName is required");
There was a problem hiding this comment.
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.
So can we just need to close the metadatastore to fix the flaky test?
There was a problem hiding this comment.
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.
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.
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.
|
/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.testBatchMetadataStoreMetricssome 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
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: