You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2022/07/22 06:46:34 UTC

[GitHub] [hive] ghanko commented on a diff in pull request #3458: HIVE-26411 Fix TestReplicationMetricCollector flakiness

ghanko commented on code in PR #3458:
URL: https://github.com/apache/hive/pull/3458#discussion_r927340981


##########
ql/src/test/org/apache/hadoop/hive/ql/parse/repl/metric/TestReplicationMetricCollector.java:
##########
@@ -75,6 +84,12 @@ public void setup() throws Exception {
     MetricCollector.getInstance().init(conf);
     Mockito.when(fmd.getFailoverEventId()).thenReturn(10L);
     Mockito.when(fmd.getFilePath()).thenReturn("dummyDir");
+    disableBackgroundThreads();
+  }
+
+  private void disableBackgroundThreads() {
+    PowerMockito.mockStatic(MetricSink.class);
+    Mockito.when(MetricSink.getInstance()).thenReturn(metricSinkInstance);

Review Comment:
   Yes, this is the main idea and I verified locally with the debugger that the background threads are not started. Precisely what happens is that whenever MetricSink.getInstance() is called, it returns the mock metricSinkInstance and even if its init() is called, it does nothing because it's an empty method provided by the mock framework.



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org