Skip to content

Commit 8e13f7b

Browse files
committed
Test cases fixes
1 parent 179a18e commit 8e13f7b

3 files changed

Lines changed: 14 additions & 45 deletions

File tree

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException;
3434
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AzureBlobFileSystemException;
3535
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.InvalidConfigurationValueException;
36-
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.TrileanConversionException;
3736
import org.apache.hadoop.fs.azurebfs.enums.Trilean;
3837
import org.apache.hadoop.fs.azurebfs.services.AbfsClient;
3938
import org.apache.hadoop.fs.azurebfs.services.AbfsRestOperation;
@@ -83,10 +82,6 @@ public void testGetAclCallOnHnsConfigAbsence() throws Exception {
8382
AzureBlobFileSystemStore store = Mockito.spy(fs.getAbfsStore());
8483
AbfsClient client = Mockito.spy(fs.getAbfsStore().getClient(AbfsServiceType.DFS));
8584
Mockito.doReturn(client).when(store).getClient(AbfsServiceType.DFS);
86-
87-
Mockito.doThrow(TrileanConversionException.class)
88-
.when(store)
89-
.isNamespaceEnabled();
9085
store.setNamespaceEnabled(Trilean.UNKNOWN);
9186

9287
TracingContext tracingContext = getSampleTracingContext(fs, true);

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

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
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;
3332
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException;
3433
import org.apache.hadoop.fs.azurebfs.services.AbfsClient;
3534
import org.apache.hadoop.fs.azurebfs.services.AbfsDfsClient;
@@ -283,6 +282,9 @@ private void ensureGetAclDetermineHnsStatusAccuratelyInternal(int statusCode,
283282
boolean isHnsEnabled = store.getIsNamespaceEnabled(
284283
getTestTracingContext(getFileSystem(), false));
285284
Assertions.assertThat(isHnsEnabled).isEqualTo(expectedValue);
285+
Assertions.assertThat(store.getClient().getIsNamespaceEnabled())
286+
.describedAs("ABFS Client should return same isNameSpace value as store")
287+
.isEqualTo(expectedValue);
286288

287289
// GetAcl() should be called only once to determine the HNS status.
288290
Mockito.verify(mockClient, times(1))
@@ -344,57 +346,33 @@ public void testAccountSpecificConfig() throws Exception {
344346

345347
/**
346348
* Tests the behavior of AbfsConfiguration when the namespace-enabled
347-
* configuration is not explicitly set (i.e., set to an empty string).
349+
* configuration set based on config provided.
348350
*
349-
* Expects the namespace value to be set as UNKNOWN.
351+
* Expects the namespace value based on config provided.
350352
*
351353
* @throws Exception if any error occurs during configuration setup or evaluation
352354
*/
353355
@Test
354-
public void testNameSpaceConfigNotSet() throws Exception {
356+
public void testNameSpaceConfig() throws Exception {
355357
Configuration configuration = new Configuration();
356-
configuration.set(ConfigurationKeys.FS_AZURE_ACCOUNT_IS_HNS_ENABLED, "");
358+
configuration.unset(FS_AZURE_ACCOUNT_IS_HNS_ENABLED);
357359
AbfsConfiguration abfsConfig = new AbfsConfiguration(configuration, "bogusAccountName");
358360

359-
// Test that the namespace enabled config is set correctly
361+
// Test that the namespace value when config is not set
360362
Assertions.assertThat(abfsConfig.getIsNamespaceEnabledAccount())
361363
.describedAs("Namespace enabled should be unknown in case config is not set")
362364
.isEqualTo(Trilean.UNKNOWN);
363-
}
364365

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");
366+
configuration.set(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, TRUE_STR);
367+
abfsConfig = new AbfsConfiguration(configuration, "bogusAccountName");
378368

379369
// Test that the namespace enabled config is set correctly
380370
Assertions.assertThat(abfsConfig.getIsNamespaceEnabledAccount())
381371
.describedAs("Namespace enabled should be true in case config is set to true")
382372
.isEqualTo(Trilean.TRUE);
383-
}
384373

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");
374+
configuration.set(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, FALSE_STR);
375+
abfsConfig = new AbfsConfiguration(configuration, "bogusAccountName");
398376

399377
// Test that the namespace enabled config is set correctly
400378
Assertions.assertThat(abfsConfig.getIsNamespaceEnabledAccount())

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore;
4141
import org.apache.hadoop.fs.azurebfs.commit.ResilientCommitByRename;
4242
import org.apache.hadoop.fs.azurebfs.constants.HttpHeaderConfigurations;
43-
import org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys;
4443
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException;
4544
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AzureBlobFileSystemException;
4645
import org.apache.hadoop.fs.azurebfs.contracts.services.AzureServiceErrorCode;
@@ -76,11 +75,8 @@ public class TestAbfsRenameRetryRecovery extends AbstractAbfsIntegrationTest {
7675
private static final Logger LOG =
7776
LoggerFactory.getLogger(TestAbfsRenameRetryRecovery.class);
7877

79-
private boolean isNamespaceEnabled;
80-
8178
public TestAbfsRenameRetryRecovery() throws Exception {
82-
isNamespaceEnabled = getConfiguration()
83-
.getBoolean(TestConfigurationKeys.FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT, false);
79+
// do nothing
8480
}
8581

8682
/**
@@ -461,11 +457,11 @@ public void testExistingPathCorrectlyRejected() throws Exception {
461457
*/
462458
@Test
463459
public void testRenameRecoveryUnsupportedForFlatNamespace() throws Exception {
464-
Assume.assumeTrue(!isNamespaceEnabled);
465460
// In DFS endpoint, renamePath is O(1) API call and idempotency issue can happen.
466461
// For blob endpoint, client orchestrates the rename operation.
467462
assumeDfsServiceType();
468463
AzureBlobFileSystem fs = getFileSystem();
464+
Assume.assumeTrue(!getIsNamespaceEnabled(fs));
469465
AzureBlobFileSystemStore abfsStore = fs.getAbfsStore();
470466
TracingContext testTracingContext = getTestTracingContext(fs, false);
471467

0 commit comments

Comments
 (0)