Skip to content

Commit 179a18e

Browse files
committed
Moved Testcase to namespace test class
1 parent 37d6a1e commit 179a18e

File tree

5 files changed

+67
-65
lines changed

5 files changed

+67
-65
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AbfsConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ void setMaxBackoffIntervalMilliseconds(int maxBackoffInterval) {
15301530

15311531
@VisibleForTesting
15321532
public void setIsNamespaceEnabledAccount(Trilean isNamespaceEnabledAccount) {
1533-
isNamespaceEnabled = isNamespaceEnabledAccount;
1533+
this.isNamespaceEnabled = isNamespaceEnabledAccount;
15341534
}
15351535

15361536
/**

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,13 +1716,14 @@ protected String getUserAgent() {
17161716
* Checks if the namespace is enabled.
17171717
*
17181718
* @return True if the namespace is enabled, false otherwise.
1719+
* @throws AbfsDriverException if the conversion fails.
17191720
*/
1720-
public boolean getIsNamespaceEnabled() throws TrileanConversionException {
1721+
public boolean getIsNamespaceEnabled() throws AbfsDriverException {
17211722
try {
17221723
return abfsConfiguration.getIsNamespaceEnabledAccount().toBoolean();
17231724
} catch (TrileanConversionException ex) {
17241725
LOG.error("Failed to convert namespace enabled account property to boolean", ex);
1725-
throw ex;
1726+
throw new AbfsDriverException("Failed to determine if namespace is enabled", ex);
17261727
}
17271728
}
17281729

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsDfsClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,10 +1563,11 @@ private Hashtable<String, String> parseCommaSeparatedXmsProperties(String xMsPro
15631563
* @param requestHeaders list of headers to be sent with the request
15641564
*
15651565
* @return client transaction id
1566+
* @throws AzureBlobFileSystemException if an error occurs while generating the client transaction id
15661567
*/
15671568
@VisibleForTesting
15681569
public String addClientTransactionIdToHeader(List<AbfsHttpHeader> requestHeaders)
1569-
throws AzureBlobFileSystemException{
1570+
throws AzureBlobFileSystemException {
15701571
String clientTransactionId = null;
15711572
// Set client transaction ID if the namespace and client transaction ID config are enabled.
15721573
if (getIsNamespaceEnabled() && getAbfsConfiguration().getIsClientTransactionIdEnabled()) {

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
3030
import org.apache.hadoop.fs.FileSystem;
3131
import org.apache.hadoop.fs.azurebfs.constants.AbfsServiceType;
32+
import org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys;
3233
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException;
3334
import org.apache.hadoop.fs.azurebfs.services.AbfsClient;
3435
import org.apache.hadoop.fs.azurebfs.services.AbfsDfsClient;
@@ -341,6 +342,66 @@ public void testAccountSpecificConfig() throws Exception {
341342
}
342343
}
343344

345+
/**
346+
* Tests the behavior of AbfsConfiguration when the namespace-enabled
347+
* configuration is not explicitly set (i.e., set to an empty string).
348+
*
349+
* Expects the namespace value to be set as UNKNOWN.
350+
*
351+
* @throws Exception if any error occurs during configuration setup or evaluation
352+
*/
353+
@Test
354+
public void testNameSpaceConfigNotSet() throws Exception {
355+
Configuration configuration = new Configuration();
356+
configuration.set(ConfigurationKeys.FS_AZURE_ACCOUNT_IS_HNS_ENABLED, "");
357+
AbfsConfiguration abfsConfig = new AbfsConfiguration(configuration, "bogusAccountName");
358+
359+
// Test that the namespace enabled config is set correctly
360+
Assertions.assertThat(abfsConfig.getIsNamespaceEnabledAccount())
361+
.describedAs("Namespace enabled should be unknown in case config is not set")
362+
.isEqualTo(Trilean.UNKNOWN);
363+
}
364+
365+
/**
366+
* Tests the behavior of AbfsConfiguration when the namespace-enabled
367+
* configuration is explicitly set to "true".
368+
*
369+
* Expects the namespace value to be set as TRUE.
370+
*
371+
* @throws Exception if any error occurs during configuration setup or evaluation
372+
*/
373+
@Test
374+
public void testNameSpaceConfigSetToTrue() throws Exception {
375+
Configuration configuration = new Configuration();
376+
configuration.set(ConfigurationKeys.FS_AZURE_ACCOUNT_IS_HNS_ENABLED, "true");
377+
AbfsConfiguration abfsConfig = new AbfsConfiguration(configuration, "bogusAccountName");
378+
379+
// Test that the namespace enabled config is set correctly
380+
Assertions.assertThat(abfsConfig.getIsNamespaceEnabledAccount())
381+
.describedAs("Namespace enabled should be true in case config is set to true")
382+
.isEqualTo(Trilean.TRUE);
383+
}
384+
385+
/**
386+
* Tests the behavior of AbfsConfiguration when the namespace-enabled
387+
* configuration is explicitly set to "false".
388+
*
389+
* Expects the namespace value to be set as FALSE.
390+
*
391+
* @throws Exception if any error occurs during configuration setup or evaluation
392+
*/
393+
@Test
394+
public void testNameSpaceConfigSetToFalse() throws Exception {
395+
Configuration configuration = new Configuration();
396+
configuration.set(ConfigurationKeys.FS_AZURE_ACCOUNT_IS_HNS_ENABLED, "false");
397+
AbfsConfiguration abfsConfig = new AbfsConfiguration(configuration, "bogusAccountName");
398+
399+
// Test that the namespace enabled config is set correctly
400+
Assertions.assertThat(abfsConfig.getIsNamespaceEnabledAccount())
401+
.describedAs("Namespace enabled should be false in case config is set to false")
402+
.isEqualTo(Trilean.FALSE);
403+
}
404+
344405
private void assertFileSystemInitWithExpectedHNSSettings(
345406
Configuration configuration, boolean expectedIsHnsEnabledValue) throws IOException {
346407
try (AzureBlobFileSystem fs = (AzureBlobFileSystem) FileSystem.newInstance(configuration)) {

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

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.apache.hadoop.fs.azurebfs.contracts.annotations.ConfigurationValidationAnnotations.LongConfigurationValidatorAnnotation;
3232
import org.apache.hadoop.fs.azurebfs.contracts.annotations.ConfigurationValidationAnnotations.Base64StringConfigurationValidatorAnnotation;
3333
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.KeyProviderException;
34-
import org.apache.hadoop.fs.azurebfs.enums.Trilean;
3534
import org.apache.hadoop.fs.azurebfs.utils.Base64;
3635

3736
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_SSL_CHANNEL_MODE_KEY;
@@ -211,66 +210,6 @@ public void testSSLSocketFactoryConfiguration()
211210
.isEqualTo(DelegatingSSLSocketFactory.SSLChannelMode.OpenSSL);
212211
}
213212

214-
/**
215-
* Tests the behavior of AbfsConfiguration when the namespace-enabled
216-
* configuration is not explicitly set (i.e., set to an empty string).
217-
*
218-
* Expects the namespace value to be set as UNKNOWN.
219-
*
220-
* @throws Exception if any error occurs during configuration setup or evaluation
221-
*/
222-
@Test
223-
public void testNameSpaceConfigNotSet() throws Exception {
224-
Configuration configuration = new Configuration();
225-
configuration.set(ConfigurationKeys.FS_AZURE_ACCOUNT_IS_HNS_ENABLED, "");
226-
AbfsConfiguration abfsConfig = new AbfsConfiguration(configuration, "bogusAccountName");
227-
228-
// Test that the namespace enabled config is set correctly
229-
Assertions.assertThat(abfsConfig.getIsNamespaceEnabledAccount())
230-
.describedAs("Namespace enabled should be unknown in case config is not set")
231-
.isEqualTo(Trilean.UNKNOWN);
232-
}
233-
234-
/**
235-
* Tests the behavior of AbfsConfiguration when the namespace-enabled
236-
* configuration is explicitly set to "true".
237-
*
238-
* Expects the namespace value to be set as TRUE.
239-
*
240-
* @throws Exception if any error occurs during configuration setup or evaluation
241-
*/
242-
@Test
243-
public void testNameSpaceConfigSetToTrue() throws Exception {
244-
Configuration configuration = new Configuration();
245-
configuration.set(ConfigurationKeys.FS_AZURE_ACCOUNT_IS_HNS_ENABLED, "true");
246-
AbfsConfiguration abfsConfig = new AbfsConfiguration(configuration, "bogusAccountName");
247-
248-
// Test that the namespace enabled config is set correctly
249-
Assertions.assertThat(abfsConfig.getIsNamespaceEnabledAccount())
250-
.describedAs("Namespace enabled should be true in case config is set to true")
251-
.isEqualTo(Trilean.TRUE);
252-
}
253-
254-
/**
255-
* Tests the behavior of AbfsConfiguration when the namespace-enabled
256-
* configuration is explicitly set to "false".
257-
*
258-
* Expects the namespace value to be set as FALSE.
259-
*
260-
* @throws Exception if any error occurs during configuration setup or evaluation
261-
*/
262-
@Test
263-
public void testNameSpaceConfigSetToFalse() throws Exception {
264-
Configuration configuration = new Configuration();
265-
configuration.set(ConfigurationKeys.FS_AZURE_ACCOUNT_IS_HNS_ENABLED, "false");
266-
AbfsConfiguration abfsConfig = new AbfsConfiguration(configuration, "bogusAccountName");
267-
268-
// Test that the namespace enabled config is set correctly
269-
Assertions.assertThat(abfsConfig.getIsNamespaceEnabledAccount())
270-
.describedAs("Namespace enabled should be false in case config is set to false")
271-
.isEqualTo(Trilean.FALSE);
272-
}
273-
274213
public static AbfsConfiguration updateRetryConfigs(AbfsConfiguration abfsConfig,
275214
int retryCount,
276215
int backoffTime) {

0 commit comments

Comments
 (0)