[HUDI-2213] Remove unnecessary parameter for HoodieMetrics constructor and fix NPE in UT (#3333)
This commit is contained in:
@@ -41,7 +41,7 @@ public class TestHoodieConsoleMetrics {
|
||||
when(config.getTableName()).thenReturn("console_metrics_test");
|
||||
when(config.isMetricsOn()).thenReturn(true);
|
||||
when(config.getMetricsReporterType()).thenReturn(MetricsReporterType.CONSOLE);
|
||||
new HoodieMetrics(config, "raw_table");
|
||||
new HoodieMetrics(config);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
|
||||
@@ -52,7 +52,7 @@ public class TestHoodieJmxMetrics {
|
||||
when(config.getMetricsReporterType()).thenReturn(MetricsReporterType.JMX);
|
||||
when(config.getJmxHost()).thenReturn("localhost");
|
||||
when(config.getJmxPort()).thenReturn(String.valueOf(NetworkTestUtils.nextFreePort()));
|
||||
new HoodieMetrics(config, "raw_table");
|
||||
new HoodieMetrics(config);
|
||||
registerGauge("jmx_metric1", 123L);
|
||||
assertEquals("123", Metrics.getInstance().getRegistry().getGauges()
|
||||
.get("jmx_metric1").getValue().toString());
|
||||
@@ -65,7 +65,7 @@ public class TestHoodieJmxMetrics {
|
||||
when(config.getMetricsReporterType()).thenReturn(MetricsReporterType.JMX);
|
||||
when(config.getJmxHost()).thenReturn("localhost");
|
||||
when(config.getJmxPort()).thenReturn(String.valueOf(NetworkTestUtils.nextFreePort()));
|
||||
new HoodieMetrics(config, "raw_table");
|
||||
new HoodieMetrics(config);
|
||||
registerGauge("jmx_metric2", 123L);
|
||||
assertEquals("123", Metrics.getInstance().getRegistry().getGauges()
|
||||
.get("jmx_metric2").getValue().toString());
|
||||
|
||||
@@ -50,8 +50,9 @@ public class TestHoodieMetrics {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
when(config.isMetricsOn()).thenReturn(true);
|
||||
when(config.getTableName()).thenReturn("raw_table");
|
||||
when(config.getMetricsReporterType()).thenReturn(MetricsReporterType.INMEMORY);
|
||||
metrics = new HoodieMetrics(config, "raw_table");
|
||||
metrics = new HoodieMetrics(config);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
|
||||
@@ -46,10 +46,11 @@ public class TestPrometheusReporter {
|
||||
@Test
|
||||
public void testRegisterGauge() {
|
||||
when(config.isMetricsOn()).thenReturn(true);
|
||||
when(config.getTableName()).thenReturn("foo");
|
||||
when(config.getMetricsReporterType()).thenReturn(MetricsReporterType.PROMETHEUS);
|
||||
when(config.getPrometheusPort()).thenReturn(9090);
|
||||
assertDoesNotThrow(() -> {
|
||||
new HoodieMetrics(config, "raw_table");
|
||||
new HoodieMetrics(config);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public class TestPushGateWayReporter {
|
||||
@Test
|
||||
public void testRegisterGauge() {
|
||||
when(config.isMetricsOn()).thenReturn(true);
|
||||
when(config.getTableName()).thenReturn("foo");
|
||||
when(config.getMetricsReporterType()).thenReturn(MetricsReporterType.PROMETHEUS_PUSHGATEWAY);
|
||||
when(config.getPushGatewayHost()).thenReturn("localhost");
|
||||
when(config.getPushGatewayPort()).thenReturn(9091);
|
||||
@@ -57,7 +58,7 @@ public class TestPushGateWayReporter {
|
||||
when(config.getPushGatewayRandomJobNameSuffix()).thenReturn(false);
|
||||
|
||||
assertDoesNotThrow(() -> {
|
||||
new HoodieMetrics(config, "raw_table");
|
||||
new HoodieMetrics(config);
|
||||
});
|
||||
|
||||
registerGauge("pushGateWayReporter_metric", 123L);
|
||||
|
||||
Reference in New Issue
Block a user