kfaraz commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1582071140


##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -131,8 +135,21 @@ public void setUp()
     monitorSchedulerConfig = EasyMock.mock(DruidMonitorSchedulerConfig.class);
     supervisorStateManagerConfig = 
EasyMock.mock(SupervisorStateManagerConfig.class);
     supervisor4 = EasyMock.mock(SeekableStreamSupervisor.class);
+    lagStats = EasyMock.mock(LagStats.class);
+    timesLagStatsMaxCalled = 0;
+    timesLagStatsSumCalled = 0;
 
     
EasyMock.expect(spec.getContextValue(DruidMetrics.TAGS)).andReturn(null).anyTimes();
+    
EasyMock.expect(lagStats.getAggregateForScaling()).andReturn(AggregateFunction.SUM).anyTimes();
+    EasyMock.expect(lagStats.getMetric(AggregateFunction.SUM)).andAnswer(() -> 
{
+      timesLagStatsSumCalled++;
+      return 0L;
+    }).anyTimes();
+    EasyMock.expect(lagStats.getMetric(AggregateFunction.MAX)).andAnswer(() -> 
{
+      timesLagStatsMaxCalled++;
+      return 0L;
+    }).anyTimes();
+    EasyMock.replay(lagStats);

Review Comment:
   These are weird expectations. Why do we care how many times sum and max were 
called?



##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -131,8 +135,21 @@ public void setUp()
     monitorSchedulerConfig = EasyMock.mock(DruidMonitorSchedulerConfig.class);
     supervisorStateManagerConfig = 
EasyMock.mock(SupervisorStateManagerConfig.class);
     supervisor4 = EasyMock.mock(SeekableStreamSupervisor.class);
+    lagStats = EasyMock.mock(LagStats.class);

Review Comment:
   `LagStats` is a simple POJO. We shouldn't have to mock it.



##########
server/src/main/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/LagStats.java:
##########
@@ -58,6 +60,7 @@ public long getAvgLag()
    * The preferred scaling metric that supervisor may specify to be used.
    * This could be overrided by the autscaler.
    */
+  @Nullable

Review Comment:
   This is not nullable (see constructor of this class). 
`LagStatsAutoScalerConfig.getLagAggregate()` is nullable.



##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -988,7 +1007,8 @@ public void testSeekableStreamSupervisorSpecWithScaleIn() 
throws InterruptedExce
     Thread.sleep(1000);
     int taskCountAfterScaleOut = supervisor.getIoConfig().getTaskCount();
     Assert.assertEquals(1, taskCountAfterScaleOut);
-
+    Assert.assertTrue(timesLagStatsMaxCalled == 0);
+    Assert.assertTrue(timesLagStatsSumCalled > 0);

Review Comment:
   Instead of these assertions, we just need a test in `LagStatsTest` that 
verifies the results of the method `LagStats.getMetric()`.



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