steveloughran commented on code in PR #5780:
URL: https://github.com/apache/hadoop/pull/5780#discussion_r1250955453


##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/ITestAbfsOutputStream.java:
##########
@@ -90,36 +93,51 @@ public void testMaxRequestsAndQueueCapacity() throws 
Exception {
 
   /**
    * Verify the passing of AzureBlobFileSystem reference to AbfsOutputStream
-   * to make sure that the FS instance is not eligible for GC.
-   *
+   * to make sure that the FS instance is not eligible for GC while writing.
    */
-  @Test
+  @Test(timeout = TEST_EXECUTION_TIMEOUT)
   public void testAzureBlobFileSystemBackReferenceInOutputStream()
       throws Exception {
-    AzureBlobFileSystem fs1 = new AzureBlobFileSystem();
-    fs1.initialize(new URI(getTestUrl()), getRawConfiguration());
-    Path pathFs1 = path(getMethodName() + "1");
 
-    AzureBlobFileSystem fs2 = new AzureBlobFileSystem();
-    fs2.initialize(new URI(getTestUrl()), getRawConfiguration());
-    Path pathFs2 = path(getMethodName() + "2");
-
-    try(AbfsOutputStream out1 = createAbfsOutputStreamWithFlushEnabled(fs1,
-        pathFs1)) {
-      Assert.assertFalse("BackReference in output stream should not be null",
-          out1.getFsBackRef().isNull());
-      Assert.assertEquals("Mismatch in Filesystem reference this outputStream"
-              + " should have",
-          fs1, out1.getFsBackRef().getReference());
+    byte[] testBytes = new byte[5 * 1024];
+    // Creating an output stream using a FS in a separate method to make the
+    // FS instance used eligible for GC. Since when a method is popped from
+    // the stack frame, it's variables become anonymous, this creates higher
+    // chance of getting Garbage collected.
+    try (AbfsOutputStream out = getStream()) {
+
+      // Every 5KB block written is flushed and a GC is hinted, if the
+      // executor service is shut down in between, the test should fail
+      // indicating premature shutdown while writing.
+      for (int i = 0; i < 5; i++) {
+        out.write(testBytes);
+        out.flush();
+        System.gc();
+        Assertions.assertThat(

Review Comment:
   having them in the loop makes the test fail faster if there are problems;  i 
don't see any harm in leaving them there



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