Skip to content

Commit 134c561

Browse files
PR commnets
1 parent d599fa2 commit 134c561

1 file changed

Lines changed: 26 additions & 16 deletions

File tree

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

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public ITestCustomerProvidedKey() throws Exception {
112112
@Test
113113
public void testReadWithCPK() throws Exception {
114114
final AzureBlobFileSystem fs = getAbfs(true);
115-
String fileName = "/" + methodName.getMethodName() + UUID.randomUUID();
115+
String fileName = path("/" + methodName.getMethodName()).toUri().getPath();
116116
createFileAndGetContent(fs, fileName, FILE_SIZE);
117117

118118
AbfsClient abfsClient = fs.getAbfsClient();
@@ -162,7 +162,7 @@ public void testReadWithCPK() throws Exception {
162162
@Test
163163
public void testReadWithoutCPK() throws Exception {
164164
final AzureBlobFileSystem fs = getAbfs(false);
165-
String fileName = "/" + methodName.getMethodName() + UUID.randomUUID();
165+
String fileName = path("/" + methodName.getMethodName()).toUri().getPath();
166166
createFileAndGetContent(fs, fileName, FILE_SIZE);
167167

168168
AbfsClient abfsClient = fs.getAbfsClient();
@@ -201,7 +201,7 @@ public void testReadWithoutCPK() throws Exception {
201201
@Test
202202
public void testAppendWithCPK() throws Exception {
203203
final AzureBlobFileSystem fs = getAbfs(true);
204-
final String fileName = "/" + methodName.getMethodName() + UUID.randomUUID();
204+
final String fileName = path("/" + methodName.getMethodName()).toUri().getPath();
205205
createFileAndGetContent(fs, fileName, FILE_SIZE);
206206

207207
// Trying to append with correct CPK headers
@@ -246,7 +246,7 @@ public void testAppendWithCPK() throws Exception {
246246
@Test
247247
public void testAppendWithoutCPK() throws Exception {
248248
final AzureBlobFileSystem fs = getAbfs(false);
249-
final String fileName = "/" + methodName.getMethodName() + UUID.randomUUID();
249+
final String fileName = path("/" + methodName.getMethodName()).toUri().getPath();
250250
createFileAndGetContent(fs, fileName, FILE_SIZE);
251251

252252
// Trying to append without CPK headers
@@ -282,7 +282,7 @@ public void testAppendWithoutCPK() throws Exception {
282282
@Test
283283
public void testSetGetXAttr() throws Exception {
284284
final AzureBlobFileSystem fs = getAbfs(true);
285-
final String fileName = "/" + methodName.getMethodName() + UUID.randomUUID();
285+
final String fileName = path(methodName.getMethodName()).toUri().getPath();
286286
createFileAndGetContent(fs, fileName, FILE_SIZE);
287287

288288
String valSent = "testValue";
@@ -416,7 +416,7 @@ public void testListPathWithoutCPK() throws Exception {
416416
private void testListPath(final boolean isWithCPK) throws Exception {
417417
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
418418
final Path testPath = path("/" + methodName.getMethodName());
419-
String testDirName = testPath.toString().substring(testPath.toString().lastIndexOf("/"));
419+
String testDirName = testPath.toUri().getPath();
420420
fs.mkdirs(testPath);
421421
createFileAndGetContent(fs, testDirName + "/aaa", FILE_SIZE);
422422
createFileAndGetContent(fs, testDirName + "/bbb", FILE_SIZE);
@@ -475,7 +475,8 @@ public void testCreatePathWithoutCPK() throws Exception {
475475

476476
private void testCreatePath(final boolean isWithCPK) throws Exception {
477477
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
478-
final String testFileName = "/" + methodName.getMethodName() + UUID.randomUUID() + UUID.randomUUID();
478+
final String testFileName = path("/" + methodName.getMethodName())
479+
.toUri().getPath();
479480
createFileAndGetContent(fs, testFileName, FILE_SIZE);
480481

481482
AbfsClient abfsClient = fs.getAbfsClient();
@@ -518,7 +519,8 @@ public void testRenamePathWithoutCPK() throws Exception {
518519

519520
private void testRenamePath(final boolean isWithCPK) throws Exception {
520521
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
521-
final String testFileName = "/" + methodName.getMethodName() + UUID.randomUUID();
522+
final String testFileName = path("/" + methodName.getMethodName())
523+
.toUri().getPath();
522524
createFileAndGetContent(fs, testFileName, FILE_SIZE);
523525

524526
FileStatus fileStatusBeforeRename = fs
@@ -554,7 +556,8 @@ public void testFlushWithoutCPK() throws Exception {
554556

555557
private void testFlush(final boolean isWithCPK) throws Exception {
556558
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
557-
final String testFileName = "/" + methodName.getMethodName() + UUID.randomUUID();
559+
final String testFileName = path("/" + methodName.getMethodName())
560+
.toUri().getPath();
558561
fs.create(new Path(testFileName)).close();
559562
AbfsClient abfsClient = fs.getAbfsClient();
560563
String expectedCPKSha = getCPKSha(fs);
@@ -614,7 +617,8 @@ public void testSetPathPropertiesWithoutCPK() throws Exception {
614617

615618
private void testSetPathProperties(final boolean isWithCPK) throws Exception {
616619
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
617-
final String testFileName = "/" + methodName.getMethodName() + UUID.randomUUID();
620+
final String testFileName = path("/" + methodName.getMethodName())
621+
.toUri().getPath();
618622
createFileAndGetContent(fs, testFileName, FILE_SIZE);
619623

620624
AbfsClient abfsClient = fs.getAbfsClient();
@@ -644,7 +648,8 @@ public void testGetPathStatusFileWithoutCPK() throws Exception {
644648

645649
private void testGetPathStatusFile(final boolean isWithCPK) throws Exception {
646650
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
647-
final String testFileName = "/" + methodName.getMethodName() + UUID.randomUUID();
651+
final String testFileName = path("/" + methodName.getMethodName())
652+
.toUri().getPath();
648653
createFileAndGetContent(fs, testFileName, FILE_SIZE);
649654

650655
AbfsClient abfsClient = fs.getAbfsClient();
@@ -681,7 +686,8 @@ public void testDeletePathWithoutCPK() throws Exception {
681686

682687
private void testDeletePath(final boolean isWithCPK) throws Exception {
683688
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
684-
final String testFileName = "/" + methodName.getMethodName() + UUID.randomUUID();
689+
final String testFileName = path("/" + methodName.getMethodName())
690+
.toUri().getPath();
685691
createFileAndGetContent(fs, testFileName, FILE_SIZE);
686692

687693
FileStatus[] listStatuses = fs.listStatus(new Path(testFileName));
@@ -711,7 +717,8 @@ public void testSetPermissionWithoutCPK() throws Exception {
711717

712718
private void testSetPermission(final boolean isWithCPK) throws Exception {
713719
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
714-
final String testFileName = "/" + methodName.getMethodName() + UUID.randomUUID();
720+
final String testFileName = path("/" + methodName.getMethodName())
721+
.toUri().getPath();
715722
Assume.assumeTrue(fs.getIsNamespaceEnabled(getTestTracingContext(fs, false)));
716723
createFileAndGetContent(fs, testFileName, FILE_SIZE);
717724
AbfsClient abfsClient = fs.getAbfsClient();
@@ -736,7 +743,8 @@ public void testSetAclWithoutCPK() throws Exception {
736743

737744
private void testSetAcl(final boolean isWithCPK) throws Exception {
738745
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
739-
final String testFileName = "/" + methodName.getMethodName() + UUID.randomUUID();
746+
final String testFileName = path("/" + methodName.getMethodName())
747+
.toUri().getPath();
740748
TracingContext tracingContext = getTestTracingContext(fs, false);
741749
Assume.assumeTrue(fs.getIsNamespaceEnabled(tracingContext));
742750
createFileAndGetContent(fs, testFileName, FILE_SIZE);
@@ -765,7 +773,8 @@ public void testGetAclWithoutCPK() throws Exception {
765773

766774
private void testGetAcl(final boolean isWithCPK) throws Exception {
767775
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
768-
final String testFileName = "/" + methodName.getMethodName() + UUID.randomUUID();
776+
final String testFileName = path("/" + methodName.getMethodName())
777+
.toUri().getPath();
769778
TracingContext tracingContext = getTestTracingContext(fs, false);
770779
Assume.assumeTrue(fs.getIsNamespaceEnabled(tracingContext));
771780
createFileAndGetContent(fs, testFileName, FILE_SIZE);
@@ -795,7 +804,8 @@ private void testCheckAccess(final boolean isWithCPK) throws Exception {
795804
getAuthType() == AuthType.OAuth);
796805

797806
final AzureBlobFileSystem fs = getAbfs(isWithCPK);
798-
final String testFileName = "/" + methodName.getMethodName() + UUID.randomUUID();
807+
final String testFileName = path("/" + methodName.getMethodName())
808+
.toUri().getPath();
799809
fs.create(new Path(testFileName)).close();
800810
AbfsClient abfsClient = fs.getAbfsClient();
801811
AbfsRestOperation abfsRestOperation = abfsClient

0 commit comments

Comments
 (0)