ashwintumma23 commented on code in PR #17596:
URL: https://github.com/apache/druid/pull/17596#discussion_r1929261995


##########
extensions-contrib/prometheus-emitter/src/test/java/org/apache/druid/emitter/prometheus/PrometheusEmitterConfigTest.java:
##########
@@ -48,4 +48,82 @@ public void testEmitterConfigWithBadExtraLabels()
     Assert.assertTrue(actualMessage.contains(expectedMessage));
   }
 
+  @Test
+  public void testDefaultConstructor()
+  {
+    PrometheusEmitterConfig config = new PrometheusEmitterConfig(null, null, 
null, null, null, false, false, null, null, null, null);
+    Assert.assertEquals(PrometheusEmitterConfig.Strategy.exporter, 
config.getStrategy());
+    Assert.assertEquals("druid", config.getNamespace());
+    Assert.assertNull(config.getDimensionMapPath());
+  }
+
+  @Test
+  public void testExporterStrategy()
+  {
+    PrometheusEmitterConfig config = new 
PrometheusEmitterConfig(PrometheusEmitterConfig.Strategy.exporter, "druid", 
null, 8080, null, true, true, null, null, null, null);
+    Assert.assertEquals(PrometheusEmitterConfig.Strategy.exporter, 
config.getStrategy());
+    Assert.assertEquals("druid", config.getNamespace());
+    Assert.assertEquals(8080, config.getPort());
+    Assert.assertTrue(config.isAddHostAsLabel());
+    Assert.assertTrue(config.isAddHostAsLabel());
+  }
+
+  @Test
+  public void testExporterStrategyWithoutPort()
+  {
+    Assert.assertThrows(IllegalArgumentException.class, () -> {
+      new PrometheusEmitterConfig(PrometheusEmitterConfig.Strategy.exporter, 
null, null, null, null, false, false, null, null, null, null);
+    });
+  }
+
+  @Test
+  public void testPushgatewayStrategy()
+  {
+    PrometheusEmitterConfig config = new 
PrometheusEmitterConfig(PrometheusEmitterConfig.Strategy.pushgateway, "druid", 
null, null, "localhost:9091", false, false, 30, null, true, 5000L);
+    Assert.assertEquals(PrometheusEmitterConfig.Strategy.pushgateway, 
config.getStrategy());
+    Assert.assertEquals("druid", config.getNamespace());
+    Assert.assertEquals("localhost:9091", config.getPushGatewayAddress());
+    Assert.assertFalse(config.isAddHostAsLabel());
+  }
+
+  @Test
+  public void testPushGatewayStrategyWithoutAddress()
+  {
+    Assert.assertThrows(IllegalArgumentException.class, () -> {
+      new 
PrometheusEmitterConfig(PrometheusEmitterConfig.Strategy.pushgateway, null, 
null, null, null, false, false, null, null, null, null);
+    });
+  }
+
+  @Test
+  public void testDefaultFlushPeriodForPushgateway()

Review Comment:
   Done. Combined the three tests into one test for PushGatewayStrategy. 
Pushing in the next commit.



-- 
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