aplex commented on a change in pull request #2876: GOBBLIN-1034: Ensure 
underlying writers are expired from the Partitio…
URL: https://github.com/apache/incubator-gobblin/pull/2876#discussion_r372672919
 
 

 ##########
 File path: 
gobblin-core/src/test/java/org/apache/gobblin/writer/PartitionedWriterTest.java
 ##########
 @@ -176,4 +165,31 @@ public void testControlMessageHandler() throws 
IOException {
 
     writer.close();
   }
+
+  @Test
+  public void testPartitionWriterCacheRemovalListener()
+      throws IOException, InterruptedException {
+    State state = new State();
+    state.setProp(ConfigurationKeys.WRITER_PARTITIONER_CLASS, 
TestPartitioner.class.getCanonicalName());
+    state.setProp(PartitionedDataWriter.PARTITIONED_WRITER_CACHE_TTL_SECONDS, 
1);
+    TestPartitionAwareWriterBuilder builder = new 
TestPartitionAwareWriterBuilder();
+
+    PartitionedDataWriter writer = new PartitionedDataWriter<String, 
String>(builder, state);
+
+    String record1 = "abc";
+    writer.writeEnvelope(new RecordEnvelope(record1));
+
+    String record2 = "123";
+    writer.writeEnvelope(new RecordEnvelope(record2));
+
+    //Sleep for more than cache expiration interval
+    Thread.sleep(1500);
 
 Review comment:
   Is there a way to test this without Thread.sleep, e.g. with some virtual 
time or by explicitly triggering expiration? 
   Using sleeps can slow down the test suite, and also make it flakey. For 
example, if the tests are running on overloaded Tracis CI machine, the cache 
timer that normally runs every second, can run every 3rd second, and the test 
will randomly fail.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to