Skip to content

Commit cc0b8ab

Browse files
author
manishbhatt
committed
Comments on TestAbfsClient
1 parent 7cc5e4b commit cc0b8ab

File tree

1 file changed

+30
-9
lines changed
  • hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services

1 file changed

+30
-9
lines changed

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/TestAbfsClient.java

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,41 @@
1818

1919
package org.apache.hadoop.fs.azurebfs.services;
2020

21+
import java.net.URI;
22+
import java.net.URL;
23+
import java.util.Map;
24+
25+
import org.assertj.core.api.Assertions;
26+
import org.junit.Test;
27+
import org.mockito.Mockito;
28+
2129
import org.apache.hadoop.conf.Configuration;
2230
import org.apache.hadoop.fs.azurebfs.AbfsConfiguration;
2331
import org.apache.hadoop.fs.azurebfs.AbfsCountersImpl;
2432
import org.apache.hadoop.fs.azurebfs.oauth2.AccessTokenProvider;
2533
import org.apache.hadoop.fs.azurebfs.utils.Base64;
2634
import org.apache.hadoop.fs.azurebfs.utils.MetricFormat;
27-
import org.assertj.core.api.Assertions;
28-
import org.junit.Test;
29-
import org.mockito.Mockito;
30-
31-
import java.net.URI;
32-
import java.net.URL;
33-
import java.util.Map;
3435

3536
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_ACCOUNT_KEY;
3637
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_ACCOUNT_NAME;
3738
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_FORMAT;
3839
import static org.apache.hadoop.fs.azurebfs.services.AbfsClient.ABFS_CLIENT_TIMER_THREAD_NAME;
3940

41+
/**
42+
* Unit test cases for the AbfsClient class.
43+
*/
4044
public class TestAbfsClient {
4145
private static final String ACCOUNT_NAME = "bogusAccountName.dfs.core.windows.net";
4246
private static final String ACCOUNT_KEY = "testKey";
4347
private static final long SLEEP_DURATION_MS = 500;
4448

49+
/**
50+
* Test the initialization of the AbfsClient timer when metric collection is disabled.
51+
* In case of metric collection being disabled, the timer should not be initialized.
52+
* Asserting that the timer is null and the abfs-timer-client thread is not running.
53+
*/
4554
@Test
46-
public void testTimerNotInitialize() throws Exception {
55+
public void testTimerInitializationWithoutMetricCollection() throws Exception {
4756
final Configuration configuration = new Configuration();
4857
AbfsConfiguration abfsConfiguration = new AbfsConfiguration(configuration, ACCOUNT_NAME);
4958

@@ -69,8 +78,14 @@ public void testTimerNotInitialize() throws Exception {
6978
client.close();
7079
}
7180

81+
/**
82+
* Test the initialization of the AbfsClient timer when metric collection is enabled.
83+
* In case of metric collection being enabled, the timer should be initialized.
84+
* Asserting that the timer is not null and the abfs-timer-client thread is running.
85+
* Also, asserting that the thread is removed after closing the client.
86+
*/
7287
@Test
73-
public void testTimerInitialize() throws Exception {
88+
public void testTimerInitializationWithMetricCollection() throws Exception {
7489
final Configuration configuration = new Configuration();
7590
configuration.set(FS_AZURE_METRIC_FORMAT, String.valueOf(MetricFormat.INTERNAL_BACKOFF_METRIC_FORMAT));
7691
configuration.set(FS_AZURE_METRIC_ACCOUNT_NAME, ACCOUNT_NAME);
@@ -105,6 +120,12 @@ public void testTimerInitialize() throws Exception {
105120
.isEqualTo(false);
106121
}
107122

123+
/**
124+
* Check if a thread with the specified name is running.
125+
*
126+
* @param threadName Name of the thread to check
127+
* @return true if the thread is running, false otherwise
128+
*/
108129
private boolean isThreadRunning(String threadName) {
109130
// Get all threads and their stack traces
110131
Map<Thread, StackTraceElement[]> allThreads = Thread.getAllStackTraces();

0 commit comments

Comments
 (0)