anmolanmol1234 commented on code in PR #7061:
URL: https://github.com/apache/hadoop/pull/7061#discussion_r1771106538


##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/ITestAbfsClient.java:
##########
@@ -685,4 +692,69 @@ public void testExpectHundredContinue() throws Exception {
             .describedAs("The expect header is not false")
             .isFalse();
   }
+
+  @Test
+  public void testTimerNotInitialize() throws Exception {
+    // Create an AzureBlobFileSystem instance.
+    final Configuration configuration = getRawConfiguration();
+    AbfsConfiguration abfsConfiguration = new AbfsConfiguration(configuration, 
ACCOUNT_NAME);
+
+    AbfsCounters abfsCounters = Mockito.spy(new AbfsCountersImpl(new 
URI("abcd")));
+    AbfsClientContext abfsClientContext = new 
AbfsClientContextBuilder().withAbfsCounters(abfsCounters).build();
+
+    // Get an instance of AbfsClient.
+    AbfsClient client = new AbfsDfsClient(new URL("https://azure.com";),
+            null,
+            abfsConfiguration,
+            (AccessTokenProvider) null,
+            null,
+            abfsClientContext);
+
+    assertNull(client.getTimer());
+    boolean isTimerThreadPresent = isThreadRunning("abfs-timer-client");
+
+    // Check if a thread with the name "abfs-timer-client" exists
+    assertFalse("Unexpected thread 'abfs-timer-client' found", 
isTimerThreadPresent);

Review Comment:
   Use assertions.assertThat



##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/ITestAbfsClient.java:
##########
@@ -685,4 +692,69 @@ public void testExpectHundredContinue() throws Exception {
             .describedAs("The expect header is not false")
             .isFalse();
   }
+
+  @Test
+  public void testTimerNotInitialize() throws Exception {
+    // Create an AzureBlobFileSystem instance.
+    final Configuration configuration = getRawConfiguration();
+    AbfsConfiguration abfsConfiguration = new AbfsConfiguration(configuration, 
ACCOUNT_NAME);
+
+    AbfsCounters abfsCounters = Mockito.spy(new AbfsCountersImpl(new 
URI("abcd")));
+    AbfsClientContext abfsClientContext = new 
AbfsClientContextBuilder().withAbfsCounters(abfsCounters).build();
+
+    // Get an instance of AbfsClient.
+    AbfsClient client = new AbfsDfsClient(new URL("https://azure.com";),
+            null,
+            abfsConfiguration,
+            (AccessTokenProvider) null,
+            null,
+            abfsClientContext);
+
+    assertNull(client.getTimer());
+    boolean isTimerThreadPresent = isThreadRunning("abfs-timer-client");
+
+    // Check if a thread with the name "abfs-timer-client" exists
+    assertFalse("Unexpected thread 'abfs-timer-client' found", 
isTimerThreadPresent);
+    client.close();
+  }
+
+  @Test
+  public void testTimerInitialize() throws Exception {
+    // Create an AzureBlobFileSystem instance.
+    final Configuration configuration = getRawConfiguration();
+    configuration.set(FS_AZURE_METRIC_FORMAT, 
String.valueOf(MetricFormat.INTERNAL_BACKOFF_METRIC_FORMAT));
+    configuration.set(FS_AZURE_METRIC_ACCOUNT_NAME, ACCOUNT_NAME);
+    configuration.set(FS_AZURE_METRIC_ACCOUNT_KEY, 
Base64.encode(ACCOUNT_KEY.getBytes()));
+    AbfsConfiguration abfsConfiguration = new AbfsConfiguration(configuration, 
ACCOUNT_NAME);
+
+    AbfsCounters abfsCounters = Mockito.spy(new AbfsCountersImpl(new 
URI("abcd")));
+    AbfsClientContext abfsClientContext = new 
AbfsClientContextBuilder().withAbfsCounters(abfsCounters).build();
+
+    // Get an instance of AbfsClient.
+    AbfsClient client = new AbfsDfsClient(new URL("https://azure.com";),
+            null,
+            abfsConfiguration,
+            (AccessTokenProvider) null,
+            null,
+            abfsClientContext);
+
+    assertNotNull(client.getTimer());
+    // Check if a thread with the name "abfs-timer-client" exists
+    boolean isTimerThreadPresent = isThreadRunning("abfs-timer-client");
+    assertTrue("Expected thread 'abfs-timer-client' not found", 
isTimerThreadPresent);
+    client.close();

Review Comment:
   Also add assertions that after client is closed, whether the thread is still 
running 



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