This is an automated email from the ASF dual-hosted git repository.

Jackie-Jiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new b4f9fe180bf Make BaseTableDataManagerTest register its ServerMetrics 
mock regardless of prior registrations (#19678)
b4f9fe180bf is described below

commit b4f9fe180bf559f7a3f269a009628c7de8e71f53
Author: Xiaotian (Jackie) Jiang <[email protected]>
AuthorDate: Fri Sep 25 17:53:17 2026 -0700

    Make BaseTableDataManagerTest register its ServerMetrics mock regardless of 
prior registrations (#19678)
---
 .../pinot/core/data/manager/BaseTableDataManagerTest.java  | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git 
a/pinot-core/src/test/java/org/apache/pinot/core/data/manager/BaseTableDataManagerTest.java
 
b/pinot-core/src/test/java/org/apache/pinot/core/data/manager/BaseTableDataManagerTest.java
index 2bb3267ab54..ef4bd26ac32 100644
--- 
a/pinot-core/src/test/java/org/apache/pinot/core/data/manager/BaseTableDataManagerTest.java
+++ 
b/pinot-core/src/test/java/org/apache/pinot/core/data/manager/BaseTableDataManagerTest.java
@@ -86,6 +86,7 @@ import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
 import org.apache.pinot.spi.utils.builder.TableNameBuilder;
 import org.apache.pinot.spi.utils.retry.AttemptsExceededException;
 import org.apache.pinot.util.TestUtils;
+import org.testng.annotations.AfterClass;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
@@ -137,12 +138,25 @@ public class BaseTableDataManagerTest {
       new SegmentOperationsThrottler(2, 4, true),
       new SegmentOperationsThrottler(2, 4, true));
 
+  private ServerMetrics _previousServerMetrics;
+
+  /// Registers the mock the tests verify against. [ServerMetrics#register] 
only swaps in against the NOOP default,
+  /// so the instance an earlier test class in the same JVM registered is 
cleared first, and restored in [#tearDown]
+  /// for the test classes that run afterwards.
   @BeforeClass
   public void setUp()
       throws Exception {
+    _previousServerMetrics = ServerMetrics.get();
+    ServerMetrics.deregister();
     ServerMetrics.register(mock(ServerMetrics.class));
   }
 
+  @AfterClass(alwaysRun = true)
+  public void tearDown() {
+    ServerMetrics.deregister();
+    ServerMetrics.register(_previousServerMetrics);
+  }
+
   @BeforeMethod
   public void setUpMethod()
       throws Exception {


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

Reply via email to