|
26 | 26 | import java.net.URL; |
27 | 27 | import java.util.Arrays; |
28 | 28 | import java.util.List; |
29 | | -import java.util.Map; |
30 | 29 | import java.util.Random; |
31 | 30 | import java.util.regex.Pattern; |
32 | 31 |
|
33 | 32 | import org.apache.hadoop.fs.azurebfs.AbfsCountersImpl; |
34 | | -import org.apache.hadoop.fs.azurebfs.utils.Base64; |
35 | | -import org.apache.hadoop.fs.azurebfs.utils.MetricFormat; |
36 | 33 | import org.assertj.core.api.Assertions; |
37 | 34 | import org.junit.Assume; |
38 | 35 | import org.junit.Test; |
|
93 | 90 | import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.SINGLE_WHITE_SPACE; |
94 | 91 | import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_CLUSTER_NAME; |
95 | 92 | import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_CLUSTER_TYPE; |
96 | | -import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_FORMAT; |
97 | | -import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_ACCOUNT_NAME; |
98 | | -import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_METRIC_ACCOUNT_KEY; |
99 | 93 | import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.TEST_CONFIGURATION_FILE_NAME; |
100 | 94 |
|
101 | 95 | /** |
|
106 | 100 | public final class ITestAbfsClient extends AbstractAbfsIntegrationTest { |
107 | 101 |
|
108 | 102 | private static final String ACCOUNT_NAME = "bogusAccountName.dfs.core.windows.net"; |
109 | | - private static final String ACCOUNT_KEY = "testKey"; |
110 | 103 | private static final String FS_AZURE_USER_AGENT_PREFIX = "Partner Service"; |
111 | 104 | private static final String HUNDRED_CONTINUE_USER_AGENT = SINGLE_WHITE_SPACE + HUNDRED_CONTINUE + SEMICOLON; |
112 | 105 | private static final String TEST_PATH = "/testfile"; |
@@ -692,81 +685,4 @@ public void testExpectHundredContinue() throws Exception { |
692 | 685 | .describedAs("The expect header is not false") |
693 | 686 | .isFalse(); |
694 | 687 | } |
695 | | - |
696 | | - @Test |
697 | | - public void testTimerNotInitialize() throws Exception { |
698 | | - // Create an AzureBlobFileSystem instance. |
699 | | - final Configuration configuration = getRawConfiguration(); |
700 | | - AbfsConfiguration abfsConfiguration = new AbfsConfiguration(configuration, ACCOUNT_NAME); |
701 | | - |
702 | | - AbfsCounters abfsCounters = Mockito.spy(new AbfsCountersImpl(new URI("abcd"))); |
703 | | - AbfsClientContext abfsClientContext = new AbfsClientContextBuilder().withAbfsCounters(abfsCounters).build(); |
704 | | - |
705 | | - // Get an instance of AbfsClient. |
706 | | - AbfsClient client = new AbfsDfsClient(new URL("https://azure.com"), |
707 | | - null, |
708 | | - abfsConfiguration, |
709 | | - (AccessTokenProvider) null, |
710 | | - null, |
711 | | - abfsClientContext); |
712 | | - |
713 | | - Assertions.assertThat(client.getTimer()) |
714 | | - .describedAs("Timer should not be initialized") |
715 | | - .isNull(); |
716 | | - |
717 | | - // Check if a thread with the name "abfs-timer-client" exists |
718 | | - Assertions.assertThat(isThreadRunning("abfs-timer-client")) |
719 | | - .describedAs("Expected thread 'abfs-timer-client' not found") |
720 | | - .isEqualTo(false); |
721 | | - client.close(); |
722 | | - } |
723 | | - |
724 | | - @Test |
725 | | - public void testTimerInitialize() throws Exception { |
726 | | - // Create an AzureBlobFileSystem instance. |
727 | | - final Configuration configuration = getRawConfiguration(); |
728 | | - configuration.set(FS_AZURE_METRIC_FORMAT, String.valueOf(MetricFormat.INTERNAL_BACKOFF_METRIC_FORMAT)); |
729 | | - configuration.set(FS_AZURE_METRIC_ACCOUNT_NAME, ACCOUNT_NAME); |
730 | | - configuration.set(FS_AZURE_METRIC_ACCOUNT_KEY, Base64.encode(ACCOUNT_KEY.getBytes())); |
731 | | - AbfsConfiguration abfsConfiguration = new AbfsConfiguration(configuration, ACCOUNT_NAME); |
732 | | - |
733 | | - AbfsCounters abfsCounters = Mockito.spy(new AbfsCountersImpl(new URI("abcd"))); |
734 | | - AbfsClientContext abfsClientContext = new AbfsClientContextBuilder().withAbfsCounters(abfsCounters).build(); |
735 | | - |
736 | | - // Get an instance of AbfsClient. |
737 | | - AbfsClient client = new AbfsDfsClient(new URL("https://azure.com"), |
738 | | - null, |
739 | | - abfsConfiguration, |
740 | | - (AccessTokenProvider) null, |
741 | | - null, |
742 | | - abfsClientContext); |
743 | | - |
744 | | - Assertions.assertThat(client.getTimer()) |
745 | | - .describedAs("Timer should be initialized") |
746 | | - .isNotNull(); |
747 | | - |
748 | | - // Check if a thread with the name "abfs-timer-client" exists |
749 | | - Assertions.assertThat(isThreadRunning("abfs-timer-client")) |
750 | | - .describedAs("Expected thread 'abfs-timer-client' not found") |
751 | | - .isEqualTo(true); |
752 | | - client.close(); |
753 | | - |
754 | | - // Check if the thread is removed after closing the client |
755 | | - Assertions.assertThat(isThreadRunning("abfs-timer-client")) |
756 | | - .describedAs("Unexpected thread 'abfs-timer-client' found") |
757 | | - .isEqualTo(false); |
758 | | - } |
759 | | - |
760 | | - private boolean isThreadRunning(String threadName) { |
761 | | - // Get all threads and their stack traces |
762 | | - Map<Thread, StackTraceElement[]> allThreads = Thread.getAllStackTraces(); |
763 | | - |
764 | | - // Check if any thread has the specified name |
765 | | - for (Thread thread : allThreads.keySet()) { |
766 | | - if (thread.getName().equals(threadName)) { |
767 | | - return true; |
768 | | - } |
769 | | - } |
770 | | - return false; |
771 | | - } |
772 | 688 | } |
0 commit comments