merrimanr commented on a change in pull request #1335: METRON-1998: Only one 
sensor is flushed by tick tuple
URL: https://github.com/apache/metron/pull/1335#discussion_r256098100
 
 

 ##########
 File path: 
metron-platform/metron-writer/src/test/java/org/apache/metron/writer/BulkWriterComponentTest.java
 ##########
 @@ -270,4 +273,37 @@ public void flushShouldAckMissingTuples() throws 
Exception{
     verify(collector, times(1)).ack(missingTuple);
     verifyNoMoreInteractions(collector);
   }
+
+  @Test
+  public void flushTimeoutsShouldFlushAllMessages() throws Exception {
+    Clock clock = mock(Clock.class);
+    BulkMessageWriter<JSONObject> bulkMessageWriter = 
mock(BulkMessageWriter.class);
+    BulkWriterComponent<JSONObject> bulkWriterComponent = new 
BulkWriterComponent<>(collector, false, false).withClock(clock);
+
+    BulkWriterResponse response1 = new BulkWriterResponse();
+    response1.addSuccess(tuple1);
+    when(bulkMessageWriter.write("sensor1", configurations, 
Collections.singletonList(tuple1), 
Collections.singletonList(message1))).thenReturn(response1);
+    BulkWriterResponse response2 = new BulkWriterResponse();
+    response1.addSuccess(tuple2);
+    when(bulkMessageWriter.write("sensor2", configurations, 
Collections.singletonList(tuple2), 
Collections.singletonList(message2))).thenReturn(response2);
+
+    when(clock.currentTimeMillis()).thenReturn(1000L);
+    bulkWriterComponent.write("sensor1", tuple1, message1, bulkMessageWriter, 
configurations, messageGetStrategy);
+    bulkWriterComponent.write("sensor2", tuple2, message2, bulkMessageWriter, 
configurations, messageGetStrategy);
+
+    verify(bulkMessageWriter, times(0)).write(any(), any(), any(), any());
+
+    when(clock.currentTimeMillis()).thenReturn(5000L);
+    bulkWriterComponent.flushTimeouts(bulkMessageWriter, configurations, 
messageGetStrategy);
+
+    verify(bulkMessageWriter, times(0)).write(any(), any(), any(), any());
+
+    when(clock.currentTimeMillis()).thenReturn(7000L);
 
 Review comment:
   Done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to