Skip to content

Commit ad210ef

Browse files
committed
Add Asserts in test case
1 parent 8e13f7b commit ad210ef

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,30 +354,64 @@ public void testAccountSpecificConfig() throws Exception {
354354
*/
355355
@Test
356356
public void testNameSpaceConfig() throws Exception {
357-
Configuration configuration = new Configuration();
357+
Configuration configuration = getRawConfiguration();
358358
configuration.unset(FS_AZURE_ACCOUNT_IS_HNS_ENABLED);
359+
configuration.unset(accountProperty(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, this.getAccountName()));
360+
AzureBlobFileSystem abfs = (AzureBlobFileSystem) FileSystem.newInstance(configuration);
359361
AbfsConfiguration abfsConfig = new AbfsConfiguration(configuration, "bogusAccountName");
360362

361363
// Test that the namespace value when config is not set
362364
Assertions.assertThat(abfsConfig.getIsNamespaceEnabledAccount())
363365
.describedAs("Namespace enabled should be unknown in case config is not set")
364366
.isEqualTo(Trilean.UNKNOWN);
365367

368+
// In case no namespace config is present, file system init calls getAcl() to determine account type.
369+
Assertions.assertThat(abfs.getIsNamespaceEnabled(getTestTracingContext(abfs, false)))
370+
.describedAs("getIsNamespaceEnabled should return account type based on getAcl() call")
371+
.isEqualTo(abfs.getAbfsClient().getIsNamespaceEnabled());
372+
373+
// In case no namespace config is present, file system init calls getAcl() to determine account type.
374+
Assertions.assertThat(abfs.getAbfsStore().getAbfsConfiguration().getIsNamespaceEnabledAccount())
375+
.describedAs("getIsNamespaceEnabled() should return updated account type based on getAcl() call")
376+
.isNotEqualTo(Trilean.UNKNOWN);
377+
366378
configuration.set(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, TRUE_STR);
379+
abfs = (AzureBlobFileSystem) FileSystem.newInstance(configuration);
367380
abfsConfig = new AbfsConfiguration(configuration, "bogusAccountName");
368381

369382
// Test that the namespace enabled config is set correctly
370383
Assertions.assertThat(abfsConfig.getIsNamespaceEnabledAccount())
371384
.describedAs("Namespace enabled should be true in case config is set to true")
372385
.isEqualTo(Trilean.TRUE);
373386

387+
// In case namespace config is present, same value will be return.
388+
Assertions.assertThat(abfs.getIsNamespaceEnabled(getTestTracingContext(abfs, false)))
389+
.describedAs("getIsNamespaceEnabled() should return true when config is set to true")
390+
.isEqualTo(true);
391+
392+
// In case namespace config is present, same value will be return.
393+
Assertions.assertThat(abfs.getAbfsClient().getIsNamespaceEnabled())
394+
.describedAs("Client's getIsNamespaceEnabled() should return true when config is set to true")
395+
.isEqualTo(true);
396+
374397
configuration.set(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, FALSE_STR);
398+
abfs = (AzureBlobFileSystem) FileSystem.newInstance(configuration);
375399
abfsConfig = new AbfsConfiguration(configuration, "bogusAccountName");
376400

377401
// Test that the namespace enabled config is set correctly
378402
Assertions.assertThat(abfsConfig.getIsNamespaceEnabledAccount())
379403
.describedAs("Namespace enabled should be false in case config is set to false")
380404
.isEqualTo(Trilean.FALSE);
405+
406+
// In case namespace config is present, same value will be return.
407+
Assertions.assertThat(abfs.getIsNamespaceEnabled(getTestTracingContext(abfs, false)))
408+
.describedAs("getIsNamespaceEnabled() should return false when config is set to false")
409+
.isEqualTo(false);
410+
411+
// In case namespace config is present, same value will be return.
412+
Assertions.assertThat(abfs.getAbfsClient().getIsNamespaceEnabled())
413+
.describedAs("Client's getIsNamespaceEnabled() should return false when config is set to false")
414+
.isEqualTo(false);
381415
}
382416

383417
private void assertFileSystemInitWithExpectedHNSSettings(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ public void testRenameRecoveryUnsupportedForFlatNamespace() throws Exception {
460460
// In DFS endpoint, renamePath is O(1) API call and idempotency issue can happen.
461461
// For blob endpoint, client orchestrates the rename operation.
462462
assumeDfsServiceType();
463+
assumeHnsDisabled();
463464
AzureBlobFileSystem fs = getFileSystem();
464-
Assume.assumeTrue(!getIsNamespaceEnabled(fs));
465465
AzureBlobFileSystemStore abfsStore = fs.getAbfsStore();
466466
TracingContext testTracingContext = getTestTracingContext(fs, false);
467467

0 commit comments

Comments
 (0)