Skip to content

Commit

Permalink
HADOOP-18861. ABFS: Fix failing tests for CPK (#5979)
Browse files Browse the repository at this point in the history
Contributed by Anmol Asrani
  • Loading branch information
anmolanmol1234 authored Oct 9, 2023
1 parent 666af58 commit 9c621fc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,14 @@ public ITestCustomerProvidedKey() throws Exception {
.getBoolean(FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT, false);
}

private String getFileName() throws IOException {
return path("/" + methodName.getMethodName()).toUri().getPath();
}

@Test
public void testReadWithCPK() throws Exception {
final AzureBlobFileSystem fs = getAbfs(true);
String fileName = path("/" + methodName.getMethodName()).toString();
String fileName = getFileName();
createFileAndGetContent(fs, fileName, FILE_SIZE);

AbfsClient abfsClient = fs.getAbfsClient();
Expand Down Expand Up @@ -162,7 +166,7 @@ public void testReadWithCPK() throws Exception {
@Test
public void testReadWithoutCPK() throws Exception {
final AzureBlobFileSystem fs = getAbfs(false);
String fileName = path("/" + methodName.getMethodName()).toString();
String fileName = getFileName();
createFileAndGetContent(fs, fileName, FILE_SIZE);

AbfsClient abfsClient = fs.getAbfsClient();
Expand Down Expand Up @@ -201,7 +205,7 @@ public void testReadWithoutCPK() throws Exception {
@Test
public void testAppendWithCPK() throws Exception {
final AzureBlobFileSystem fs = getAbfs(true);
final String fileName = path("/" + methodName.getMethodName()).toString();
final String fileName = getFileName();
createFileAndGetContent(fs, fileName, FILE_SIZE);

// Trying to append with correct CPK headers
Expand Down Expand Up @@ -246,7 +250,7 @@ public void testAppendWithCPK() throws Exception {
@Test
public void testAppendWithoutCPK() throws Exception {
final AzureBlobFileSystem fs = getAbfs(false);
final String fileName = path("/" + methodName.getMethodName()).toString();
final String fileName = getFileName();
createFileAndGetContent(fs, fileName, FILE_SIZE);

// Trying to append without CPK headers
Expand Down Expand Up @@ -282,7 +286,7 @@ public void testAppendWithoutCPK() throws Exception {
@Test
public void testSetGetXAttr() throws Exception {
final AzureBlobFileSystem fs = getAbfs(true);
final String fileName = path(methodName.getMethodName()).toString();
final String fileName = getFileName();
createFileAndGetContent(fs, fileName, FILE_SIZE);

String valSent = "testValue";
Expand Down Expand Up @@ -416,7 +420,7 @@ public void testListPathWithoutCPK() throws Exception {
private void testListPath(final boolean isWithCPK) throws Exception {
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
final Path testPath = path("/" + methodName.getMethodName());
String testDirName = testPath.toString();
String testDirName = testPath.toUri().getPath();
fs.mkdirs(testPath);
createFileAndGetContent(fs, testDirName + "/aaa", FILE_SIZE);
createFileAndGetContent(fs, testDirName + "/bbb", FILE_SIZE);
Expand Down Expand Up @@ -475,8 +479,7 @@ public void testCreatePathWithoutCPK() throws Exception {

private void testCreatePath(final boolean isWithCPK) throws Exception {
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
final String testFileName = path("/" + methodName.getMethodName())
.toString();
final String testFileName = getFileName();
createFileAndGetContent(fs, testFileName, FILE_SIZE);

AbfsClient abfsClient = fs.getAbfsClient();
Expand Down Expand Up @@ -519,8 +522,7 @@ public void testRenamePathWithoutCPK() throws Exception {

private void testRenamePath(final boolean isWithCPK) throws Exception {
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
final String testFileName = path("/" + methodName.getMethodName())
.toString();
final String testFileName = getFileName();
createFileAndGetContent(fs, testFileName, FILE_SIZE);

FileStatus fileStatusBeforeRename = fs
Expand Down Expand Up @@ -556,8 +558,7 @@ public void testFlushWithoutCPK() throws Exception {

private void testFlush(final boolean isWithCPK) throws Exception {
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
final String testFileName = path("/" + methodName.getMethodName())
.toString();
final String testFileName = getFileName();
fs.create(new Path(testFileName)).close();
AbfsClient abfsClient = fs.getAbfsClient();
String expectedCPKSha = getCPKSha(fs);
Expand Down Expand Up @@ -617,8 +618,7 @@ public void testSetPathPropertiesWithoutCPK() throws Exception {

private void testSetPathProperties(final boolean isWithCPK) throws Exception {
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
final String testFileName = path("/" + methodName.getMethodName())
.toString();
final String testFileName = getFileName();
createFileAndGetContent(fs, testFileName, FILE_SIZE);

AbfsClient abfsClient = fs.getAbfsClient();
Expand Down Expand Up @@ -648,8 +648,7 @@ public void testGetPathStatusFileWithoutCPK() throws Exception {

private void testGetPathStatusFile(final boolean isWithCPK) throws Exception {
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
final String testFileName = path("/" + methodName.getMethodName())
.toString();
final String testFileName = getFileName();
createFileAndGetContent(fs, testFileName, FILE_SIZE);

AbfsClient abfsClient = fs.getAbfsClient();
Expand Down Expand Up @@ -686,8 +685,7 @@ public void testDeletePathWithoutCPK() throws Exception {

private void testDeletePath(final boolean isWithCPK) throws Exception {
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
final String testFileName = path("/" + methodName.getMethodName())
.toString();
final String testFileName = getFileName();
createFileAndGetContent(fs, testFileName, FILE_SIZE);

FileStatus[] listStatuses = fs.listStatus(new Path(testFileName));
Expand Down Expand Up @@ -717,8 +715,7 @@ public void testSetPermissionWithoutCPK() throws Exception {

private void testSetPermission(final boolean isWithCPK) throws Exception {
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
final String testFileName = path("/" + methodName.getMethodName())
.toString();
final String testFileName = getFileName();
Assume.assumeTrue(fs.getIsNamespaceEnabled(getTestTracingContext(fs, false)));
createFileAndGetContent(fs, testFileName, FILE_SIZE);
AbfsClient abfsClient = fs.getAbfsClient();
Expand All @@ -743,8 +740,7 @@ public void testSetAclWithoutCPK() throws Exception {

private void testSetAcl(final boolean isWithCPK) throws Exception {
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
final String testFileName = path("/" + methodName.getMethodName())
.toString();
final String testFileName = getFileName();
TracingContext tracingContext = getTestTracingContext(fs, false);
Assume.assumeTrue(fs.getIsNamespaceEnabled(tracingContext));
createFileAndGetContent(fs, testFileName, FILE_SIZE);
Expand Down Expand Up @@ -773,8 +769,7 @@ public void testGetAclWithoutCPK() throws Exception {

private void testGetAcl(final boolean isWithCPK) throws Exception {
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
final String testFileName = path("/" + methodName.getMethodName())
.toString();
final String testFileName = getFileName();
TracingContext tracingContext = getTestTracingContext(fs, false);
Assume.assumeTrue(fs.getIsNamespaceEnabled(tracingContext));
createFileAndGetContent(fs, testFileName, FILE_SIZE);
Expand Down Expand Up @@ -804,8 +799,7 @@ private void testCheckAccess(final boolean isWithCPK) throws Exception {
getAuthType() == AuthType.OAuth);

final AzureBlobFileSystem fs = getAbfs(isWithCPK);
final String testFileName = path("/" + methodName.getMethodName())
.toString();
final String testFileName = getFileName();
fs.create(new Path(testFileName)).close();
AbfsClient abfsClient = fs.getAbfsClient();
AbfsRestOperation abfsRestOperation = abfsClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ public void testConfigPropNotFound() throws Throwable {

for (String key : CONFIG_KEYS) {
setAuthConfig(abfsConf, true, AuthType.OAuth);
abfsConf.unset(key);
abfsConf.unset(key + "." + accountName);
testMissingConfigKey(abfsConf, key);
}
Expand Down

0 comments on commit 9c621fc

Please sign in to comment.