slfan1989 commented on code in PR #7437:
URL: https://github.com/apache/hadoop/pull/7437#discussion_r1976207144


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/ZKFederationStateStoreOpDurations.java:
##########
@@ -236,4 +237,9 @@ public void removeStoredTokenDuration(long startTime, long 
endTime) {
   public void getTokenByRouterStoreTokenDuration(long startTime, long endTime) 
{
     getTokenByRouterStoreToken.add(endTime - startTime);
   }
+
+  @VisibleForTesting
+  protected ZKFederationStateStoreOpDurations resetOpDurations() {

Review Comment:
   Thank you very much for your question! it's a very good one. Apologies for 
the delayed response, as I've been caught up with some work in the past 1-2 
days.
   
   I have noticed a difference in behavior between Junit4 and Junit5 when 
running unit tests with inheritance. In Junit4, the test methods of the parent 
and child classes are executed separately, while in Junit5, the test methods of 
the parent and child classes are coupled together and executed in the child 
class.
   
   - Junit4: The test methods of the parent and child classes are generally 
executed separately. If we define a test method in the parent class, the child 
class can inherit these methods and also define its own test methods. During 
execution, Junit4 will first execute the parent class's test methods, then the 
child class's test methods.
   
   - Junit5: In Junit5, the test methods in the parent class and the child 
class are executed together. The inheritance mechanism in Junit5 causes the 
parent class's test methods to be inherited into the child class, and by 
default, both the parent and child test methods are executed, with a different 
execution order compared to Junit4.
   
   This difference leads to an issue: in the 
`TestZookeeperFederationStateStore#testMetricsInited` test, my goal is to check 
whether the metric accumulation behaves as expected.
   
   In Junit4, `ZKFederationStateStoreOpDurations` is recreated when executing 
the child class's tests, so the data it contains is the initial value, which 
matches the expected result.
   
   However, in Junit5, due to the singleton nature of 
`ZKFederationStateStoreOpDurations`, it accumulates metric data from all 
methods in the unit test, leading to a result that does not meet expectations.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to