Re: [PR] Code coverage additions for Processing Directory (druid)
Akshat-Jain merged PR #17622: URL: https://github.com/apache/druid/pull/17622 -- 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]
Re: [PR] Code coverage additions for Processing Directory (druid)
ashwintumma23 commented on code in PR #17622:
URL: https://github.com/apache/druid/pull/17622#discussion_r1921988142
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class HttpPostEmitterMonitorTest
+{
+ private HttpPostEmitter mockHttpPostEmitter;
+ private HttpPostEmitterMonitor monitor;
+
+ @BeforeEach
+ public void setUp()
+ {
+mockHttpPostEmitter = mock(HttpPostEmitter.class);
+monitor = new HttpPostEmitterMonitor("testFeed", mockHttpPostEmitter,
+ImmutableMap.of("dimensionKey", "dimensionValue"));
+ }
+
+ @Test
+ public void testDoMonitor()
+ {
+when(mockHttpPostEmitter.getTotalEmittedEvents()).thenReturn(100L);
+when(mockHttpPostEmitter.getTotalDroppedBuffers()).thenReturn(10);
+when(mockHttpPostEmitter.getTotalAllocatedBuffers()).thenReturn(20);
+when(mockHttpPostEmitter.getTotalFailedBuffers()).thenReturn(5);
+
when(mockHttpPostEmitter.getBatchFillingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+
when(mockHttpPostEmitter.getSuccessfulSendingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+
when(mockHttpPostEmitter.getFailedSendingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+when(mockHttpPostEmitter.getEventsToEmit()).thenReturn(200L);
+when(mockHttpPostEmitter.getLargeEventsToEmit()).thenReturn(75L);
+when(mockHttpPostEmitter.getBuffersToEmit()).thenReturn(30);
+when(mockHttpPostEmitter.getBuffersToReuse()).thenReturn(15);
+
+final StubServiceEmitter stubServiceEmitter = new
StubServiceEmitter("service", "host");
+
+assertTrue(monitor.doMonitor(stubServiceEmitter));
+
+Map>
metricEvents = stubServiceEmitter.getMetricEvents();
+
+assertMetricNameAndValue(metricEvents,
"emitter/successfulSending/maxTimeMs", 0);
+assertMetricNameAndValue(metricEvents, "emitter/events/emitted/delta",
100L);
+assertMetricNameAndValue(metricEvents,
"emitter/successfulSending/minTimeMs", 0);
+assertMetricNameAndValue(metricEvents, "emitter/buffers/emitQueue", 30);
+assertMetricNameAndValue(metricEvents, "emitter/failedSending/minTimeMs",
0);
+assertMetricNameAndValue(metricEvents, "emitter/buffers/allocated/delta",
20);
+assertMetricNameAndValue(metricEvents, "emitter/batchFilling/maxTimeMs",
0);
+assertMetricNameAndValue(metricEvents, "emitter/buffers/dropped/delta",
10);
+assertMetricNameAndValue(metricEvents, "emitter/batchFilling/minTimeMs",
0);
+assertMetricNameAndValue(metricEvents, "emitter/events/emitQueue", 200L);
+assertMetricNameAndValue(metricEvents, "emitter/events/large/emitQueue",
75L);
+assertMetricNameAndValue(metricEvents, "emitter/buffers/reuseQueue", 15);
+assertMetricNameAndValue(metricEvents, "emitter/buffers/failed/delta", 5);
+assertMetricNameAndValue(metricEvents, "emitter/failedSending/maxTimeMs",
0L);
+ }
+
+ private void assertMetricNameAndValue(Map> metricEvents, String
metricName, Number expectedValue)
+ {
+
assertEquals(metricEvents.get(metricName).get(0).getMetricEvent().getMetric(),
metricName);
Review Comment:
Makes sense. Incorporated the change, pushed 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 I
Re: [PR] Code coverage additions for Processing Directory (druid)
ashwintumma23 commented on code in PR #17622:
URL: https://github.com/apache/druid/pull/17622#discussion_r1921985960
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
Review Comment:
Removed the unused import. Pushed in the next commit.
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class HttpPostEmitterMonitorTest
+{
+ private HttpPostEmitter mockHttpPostEmitter;
+ private HttpPostEmitterMonitor monitor;
+
+ @BeforeEach
+ public void setUp()
+ {
+mockHttpPostEmitter = mock(HttpPostEmitter.class);
+monitor = new HttpPostEmitterMonitor("testFeed", mockHttpPostEmitter,
+ImmutableMap.of("dimensionKey", "dimensionValue"));
+ }
+
+ @Test
+ public void testDoMonitor()
+ {
+when(mockHttpPostEmitter.getTotalEmittedEvents()).thenReturn(100L);
+when(mockHttpPostEmitter.getTotalDroppedBuffers()).thenReturn(10);
+when(mockHttpPostEmitter.getTotalAllocatedBuffers()).thenReturn(20);
+when(mockHttpPostEmitter.getTotalFailedBuffers()).thenReturn(5);
+
when(mockHttpPostEmitter.getBatchFillingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+
when(mockHttpPostEmitter.getSuccessfulSendingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+
when(mockHttpPostEmitter.getFailedSendingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+when(mockHttpPostEmitter.getEventsToEmit()).thenReturn(200L);
+when(mockHttpPostEmitter.getLargeEventsToEmit()).thenReturn(75L);
+when(mockHttpPostEmitter.getBuffersToEmit()).thenReturn(30);
+when(mockHttpPostEmitter.getBuffersToReuse()).thenReturn(15);
Review Comment:
Done. Pushed in the next commit.
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+
Re: [PR] Code coverage additions for Processing Directory (druid)
Akshat-Jain commented on code in PR #17622:
URL: https://github.com/apache/druid/pull/17622#discussion_r1921976567
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class HttpPostEmitterMonitorTest
+{
+ private HttpPostEmitter mockHttpPostEmitter;
+ private HttpPostEmitterMonitor monitor;
+
+ @BeforeEach
+ public void setUp()
+ {
+mockHttpPostEmitter = mock(HttpPostEmitter.class);
+monitor = new HttpPostEmitterMonitor("testFeed", mockHttpPostEmitter,
+ImmutableMap.of("dimensionKey", "dimensionValue"));
+ }
+
+ @Test
+ public void testDoMonitor()
+ {
+when(mockHttpPostEmitter.getTotalEmittedEvents()).thenReturn(100L);
+when(mockHttpPostEmitter.getTotalDroppedBuffers()).thenReturn(10);
+when(mockHttpPostEmitter.getTotalAllocatedBuffers()).thenReturn(20);
+when(mockHttpPostEmitter.getTotalFailedBuffers()).thenReturn(5);
+
when(mockHttpPostEmitter.getBatchFillingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+
when(mockHttpPostEmitter.getSuccessfulSendingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+
when(mockHttpPostEmitter.getFailedSendingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+when(mockHttpPostEmitter.getEventsToEmit()).thenReturn(200L);
+when(mockHttpPostEmitter.getLargeEventsToEmit()).thenReturn(75L);
+when(mockHttpPostEmitter.getBuffersToEmit()).thenReturn(30);
+when(mockHttpPostEmitter.getBuffersToReuse()).thenReturn(15);
+
+final StubServiceEmitter stubServiceEmitter = new
StubServiceEmitter("service", "host");
+
+assertTrue(monitor.doMonitor(stubServiceEmitter));
+
+Map>
metricEvents = stubServiceEmitter.getMetricEvents();
+
+assertMetricNameAndValue(metricEvents,
"emitter/successfulSending/maxTimeMs", 0);
+assertMetricNameAndValue(metricEvents, "emitter/events/emitted/delta",
100L);
+assertMetricNameAndValue(metricEvents,
"emitter/successfulSending/minTimeMs", 0);
+assertMetricNameAndValue(metricEvents, "emitter/buffers/emitQueue", 30);
+assertMetricNameAndValue(metricEvents, "emitter/failedSending/minTimeMs",
0);
+assertMetricNameAndValue(metricEvents, "emitter/buffers/allocated/delta",
20);
+assertMetricNameAndValue(metricEvents, "emitter/batchFilling/maxTimeMs",
0);
+assertMetricNameAndValue(metricEvents, "emitter/buffers/dropped/delta",
10);
+assertMetricNameAndValue(metricEvents, "emitter/batchFilling/minTimeMs",
0);
+assertMetricNameAndValue(metricEvents, "emitter/events/emitQueue", 200L);
+assertMetricNameAndValue(metricEvents, "emitter/events/large/emitQueue",
75L);
+assertMetricNameAndValue(metricEvents, "emitter/buffers/reuseQueue", 15);
+assertMetricNameAndValue(metricEvents, "emitter/buffers/failed/delta", 5);
+assertMetricNameAndValue(metricEvents, "emitter/failedSending/maxTimeMs",
0L);
+ }
+
+ private void assertMetricNameAndValue(Map> metricEvents, String
metricName, Number expectedValue)
+ {
+
assertEquals(metricEvents.get(metricName).get(0).getMetricEvent().getMetric(),
metricName);
+
+if (metricEvents.get(metricName).get(0).getMetricEvent().getValue()
instanceof Long)
+{
+
assertEquals(metricEvents.get(metricName).get(0).getMetricEvent().getValue(),
expectedValue.longValue());
+}
+else if (metricEvents.get(metricName).get(0).getMetricEvent().getValue()
instanceof Integer)
+{
+
assertEquals(metricEvents.get(me
Re: [PR] Code coverage additions for Processing Directory (druid)
Akshat-Jain commented on code in PR #17622:
URL: https://github.com/apache/druid/pull/17622#discussion_r1921968606
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
Review Comment:
Unused import.
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class HttpPostEmitterMonitorTest
+{
+ private HttpPostEmitter mockHttpPostEmitter;
+ private HttpPostEmitterMonitor monitor;
+
+ @BeforeEach
+ public void setUp()
+ {
+mockHttpPostEmitter = mock(HttpPostEmitter.class);
+monitor = new HttpPostEmitterMonitor("testFeed", mockHttpPostEmitter,
+ImmutableMap.of("dimensionKey", "dimensionValue"));
+ }
+
+ @Test
+ public void testDoMonitor()
+ {
+when(mockHttpPostEmitter.getTotalEmittedEvents()).thenReturn(100L);
+when(mockHttpPostEmitter.getTotalDroppedBuffers()).thenReturn(10);
+when(mockHttpPostEmitter.getTotalAllocatedBuffers()).thenReturn(20);
+when(mockHttpPostEmitter.getTotalFailedBuffers()).thenReturn(5);
+
when(mockHttpPostEmitter.getBatchFillingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+
when(mockHttpPostEmitter.getSuccessfulSendingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+
when(mockHttpPostEmitter.getFailedSendingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+when(mockHttpPostEmitter.getEventsToEmit()).thenReturn(200L);
+when(mockHttpPostEmitter.getLargeEventsToEmit()).thenReturn(75L);
+when(mockHttpPostEmitter.getBuffersToEmit()).thenReturn(30);
+when(mockHttpPostEmitter.getBuffersToReuse()).thenReturn(15);
+
+final StubServiceEmitter stubServiceEmitter = new
StubServiceEmitter("service", "host");
+
+assertTrue(monitor.doMonitor(stubServiceEmitter));
+
+Map>
metricEvents = stubServiceEmitter.getMetricEvents();
+
+assertMetricNameAndValue(metricEvents,
"emitter/successfulSending/maxTimeMs", 0);
+assertMetricNameAndValue(metricEvents, "emitter/events/emitted/delta",
100L);
+assertMetricNameAndValue(metricEvents,
"emitter/successfulSending/minTimeMs", 0);
+assertMetricNameAndValue(metricEvents, "emitter/buffers/emitQueue", 30);
+assertMetricNameAndValue(metricEvents, "emitter/failedSending/minTimeMs",
0);
+assertMetricNameAndVa
Re: [PR] Code coverage additions for Processing Directory (druid)
ashwintumma23 commented on code in PR #17622:
URL: https://github.com/apache/druid/pull/17622#discussion_r1921961256
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class HttpPostEmitterMonitorTest
+{
+ private HttpPostEmitter mockHttpPostEmitter;
+ private ServiceEmitter mockServiceEmitter;
Review Comment:
Removed it. Pushed the changes in the next commit.
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class HttpPostEmitterMonitorTest
+{
+ private HttpPostEmitter mockHttpPostEmitter;
+ private ServiceEmitter mockServiceEmitter;
+ private HttpPostEmitterMonitor monitor;
+
+ @BeforeEach
+ public void setUp()
+ {
+mockHttpPostEmitter = mock(HttpPostEmitter.class);
+mockServiceEmitter = mock(ServiceEmitter.class);
+monitor = new HttpPostEmitterMonitor("testFeed", mockHttpPostEmitter,
+ImmutableMap.of("dimensionKey", "dimensionValue"));
+ }
+
+ @Test
+ public void testDoMonitor()
+ {
+when(mockHttpPostEmitter.getTotalEmittedEvents()).thenReturn(100L);
+when(mockHttpPostEmitter.getTotalDroppedBuffers()).thenReturn(10);
+when(mockHttpPostEmitter.getTotalAllocatedBuffers()).thenReturn(20);
+when(mockHttpPostEmitter.getTotalFailedBuffers()).thenReturn(5);
+
when(mockHttpPostEmitter.getBatchFillingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+
when(mockHttpPostEmitter.getSuccessfulSendingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+
when(mockHttpPostEmitter.getFailedSendingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+when(mockHttpPostEmitter.getEventsToEmit()).thenReturn(200L);
+when(mockHttpPostEmitter.getLargeEventsToEmit()).thenReturn(75L);
+when(mockHttpPostEmitter.getBuffersToEmit()).thenReturn(30);
+when(mockHttpPostEmitter.getBuffersToReuse()).thenReturn(15);
+
+final StubServiceEmitter stubServiceEmitter = new
St
Re: [PR] Code coverage additions for Processing Directory (druid)
Akshat-Jain commented on code in PR #17622:
URL: https://github.com/apache/druid/pull/17622#discussion_r1921853184
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class HttpPostEmitterMonitorTest
+{
+ private HttpPostEmitter mockHttpPostEmitter;
+ private ServiceEmitter mockServiceEmitter;
Review Comment:
`mockServiceEmitter` is unused now.
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class HttpPostEmitterMonitorTest
+{
+ private HttpPostEmitter mockHttpPostEmitter;
+ private ServiceEmitter mockServiceEmitter;
+ private HttpPostEmitterMonitor monitor;
+
+ @BeforeEach
+ public void setUp()
+ {
+mockHttpPostEmitter = mock(HttpPostEmitter.class);
+mockServiceEmitter = mock(ServiceEmitter.class);
+monitor = new HttpPostEmitterMonitor("testFeed", mockHttpPostEmitter,
+ImmutableMap.of("dimensionKey", "dimensionValue"));
+ }
+
+ @Test
+ public void testDoMonitor()
+ {
+when(mockHttpPostEmitter.getTotalEmittedEvents()).thenReturn(100L);
+when(mockHttpPostEmitter.getTotalDroppedBuffers()).thenReturn(10);
+when(mockHttpPostEmitter.getTotalAllocatedBuffers()).thenReturn(20);
+when(mockHttpPostEmitter.getTotalFailedBuffers()).thenReturn(5);
+
when(mockHttpPostEmitter.getBatchFillingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+
when(mockHttpPostEmitter.getSuccessfulSendingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+
when(mockHttpPostEmitter.getFailedSendingTimeCounter()).thenReturn(mock(ConcurrentTimeCounter.class));
+when(mockHttpPostEmitter.getEventsToEmit()).thenReturn(200L);
+when(mockHttpPostEmitter.getLargeEventsToEmit()).thenReturn(75L);
+when(mockHttpPostEmitter.getBuffersToEmit()).thenReturn(30);
+when(mockHttpPostEmitter.getBuffersToReuse()).thenReturn(15);
+
+final StubServiceEmitter stubServiceEmitter = new
StubServiceEmitter(
Re: [PR] Code coverage additions for Processing Directory (druid)
ashwintumma23 commented on PR #17622: URL: https://github.com/apache/druid/pull/17622#issuecomment-2601459581 > Thank you for your contribution! Have added a few comments, appreciate if you could take a look. Thanks! Thank you for the suggestions, Akshat! I have pushed commits for incorporating the changes. Verified that these changes keep the code coverage intact as well for the respective files. -- 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]
Re: [PR] Code coverage additions for Processing Directory (druid)
ashwintumma23 commented on code in PR #17622: URL: https://github.com/apache/druid/pull/17622#discussion_r1921821751 ## processing/src/test/java/org/apache/druid/js/JavaScriptConfigTest.java: ## @@ -60,4 +60,46 @@ public void testSerdeWithDefaults() throws Exception Assert.assertFalse(config.isEnabled()); } + + @Test + public void testEquals() Review Comment: Incorporated the suggestion in the next commit. Verified that the `equals` and `hashCode` methods are covered in code coverage report. -- 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]
Re: [PR] Code coverage additions for Processing Directory (druid)
ashwintumma23 commented on code in PR #17622:
URL: https://github.com/apache/druid/pull/17622#discussion_r1921820786
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceMetricEvent;
+import org.junit.Assert;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.atMost;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class HttpPostEmitterMonitorTest
+{
+ private HttpPostEmitter mockHttpPostEmitter;
+ private ServiceEmitter mockServiceEmitter;
+ private ImmutableMap mockExtraDimensions;
+ private HttpPostEmitterMonitor monitor;
+
+ @BeforeEach
+ public void setUp()
+ {
+mockHttpPostEmitter = mock(HttpPostEmitter.class);
+mockServiceEmitter = mock(ServiceEmitter.class);
+mockExtraDimensions = ImmutableMap.of("dimensionKey", "dimensionValue");
+
+monitor = new HttpPostEmitterMonitor("testFeed", mockHttpPostEmitter,
mockExtraDimensions);
+ }
+
+ @Test
+ public void testDoMonitor()
Review Comment:
Incorporated the suggestion in the next commit. I verified that with
`StubServiceEmitter` as well, the code coverage stays intact.
--
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]
Re: [PR] Code coverage additions for Processing Directory (druid)
ashwintumma23 commented on code in PR #17622:
URL: https://github.com/apache/druid/pull/17622#discussion_r1921819652
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceMetricEvent;
+import org.junit.Assert;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.atMost;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class HttpPostEmitterMonitorTest
+{
+ private HttpPostEmitter mockHttpPostEmitter;
+ private ServiceEmitter mockServiceEmitter;
+ private ImmutableMap mockExtraDimensions;
Review Comment:
Thanks for the suggestion, @Akshat-Jain , incorporated it 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]
Re: [PR] Code coverage additions for Processing Directory (druid)
Akshat-Jain commented on code in PR #17622:
URL: https://github.com/apache/druid/pull/17622#discussion_r1921105216
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceMetricEvent;
+import org.junit.Assert;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.atMost;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class HttpPostEmitterMonitorTest
+{
+ private HttpPostEmitter mockHttpPostEmitter;
+ private ServiceEmitter mockServiceEmitter;
+ private ImmutableMap mockExtraDimensions;
Review Comment:
`mockExtraDimensions` is only used in `setUp()`, hence can be moved there as
a local variable.
Also, since it's used just at one place, you could also consider removing
the variable in favour of directly doing:
```java
monitor = new HttpPostEmitterMonitor(
"testFeed",
mockHttpPostEmitter,
ImmutableMap.of("dimensionKey", "dimensionValue")
);
```
##
processing/src/test/java/org/apache/druid/java/util/metrics/HttpPostEmitterMonitorTest.java:
##
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.metrics;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.emitter.core.ConcurrentTimeCounter;
+import org.apache.druid.java.util.emitter.core.HttpPostEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceMetricEvent;
+import org.junit.Assert;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.atMost;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class HttpPostEmitterMonitorTest
+{
+ private HttpPostEmitter mockHttpPostEmitter;
+ private ServiceEmitter mockServiceEmitter;
+ private ImmutableMap mockExtraDimensions;
+ private HttpPostEmitterMonitor monitor;
+
+ @BeforeEach
+ public void setUp()
+ {
+mockHttpPostEmitter = mock(HttpPostEmitter.class);
+mockServiceEmitter = mock(ServiceEmitter.class);
+mockExtraDimensions = ImmutableMap.of("dimensionKey", "dimensionValue");
+
+monitor = new HttpPostEmitterMonitor(
