Skip to content

Commit d0cfcce

Browse files
authored
File System Api Async Tests (Azure#37037)
* starting tests * more tests * all tests but one * lease testbase consistency * service versions and recordings * style and version adding * more style
1 parent 7d97d0b commit d0cfcce

File tree

12 files changed

+2600
-341
lines changed

12 files changed

+2600
-341
lines changed

sdk/storage/azure-storage-file-datalake/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "java",
44
"TagPrefix": "java/storage/azure-storage-file-datalake",
5-
"Tag": "java/storage/azure-storage-file-datalake_7647723dc8"
5+
"Tag": "java/storage/azure-storage-file-datalake_8f2462b720"
66
}

sdk/storage/azure-storage-file-datalake/src/main/java/com/azure/storage/file/datalake/DataLakeFileSystemAsyncClient.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,12 +1079,11 @@ public Mono<DataLakeFileAsyncClient> createFileIfNotExists(String fileName) {
10791079
@ServiceMethod(returns = ReturnType.SINGLE)
10801080
public Mono<Response<DataLakeFileAsyncClient>> createFileIfNotExistsWithResponse(String fileName,
10811081
DataLakePathCreateOptions options) {
1082-
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
1083-
.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD);
10841082
options = options == null ? new DataLakePathCreateOptions() : options;
1083+
options.setRequestConditions(new DataLakeRequestConditions()
1084+
.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD));
10851085
try {
1086-
return createFileWithResponse(fileName, options.getPermissions(), options.getUmask(),
1087-
options.getPathHttpHeaders(), options.getMetadata(), requestConditions)
1086+
return createFileWithResponse(fileName, options)
10881087
.onErrorResume(t -> t instanceof DataLakeStorageException && ((DataLakeStorageException) t)
10891088
.getStatusCode() == 409,
10901089
t -> {
@@ -1444,11 +1443,11 @@ public Mono<DataLakeDirectoryAsyncClient> createDirectoryIfNotExists(String dire
14441443
@ServiceMethod(returns = ReturnType.SINGLE)
14451444
public Mono<Response<DataLakeDirectoryAsyncClient>> createDirectoryIfNotExistsWithResponse(String directoryName,
14461445
DataLakePathCreateOptions options) {
1446+
options = options == null ? new DataLakePathCreateOptions() : options;
1447+
options.setRequestConditions(new DataLakeRequestConditions()
1448+
.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD));
14471449
try {
1448-
options = options == null ? new DataLakePathCreateOptions() : options;
1449-
return createDirectoryWithResponse(directoryName, options.getPermissions(), options.getUmask(),
1450-
options.getPathHttpHeaders(), options.getMetadata(),
1451-
new DataLakeRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD))
1450+
return createDirectoryWithResponse(directoryName, options)
14521451
.onErrorResume(t -> t instanceof DataLakeStorageException && ((DataLakeStorageException) t)
14531452
.getStatusCode() == 409,
14541453
t -> {

sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/DataLakeTestBase.java

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,10 @@ protected String setupFileSystemLeaseCondition(DataLakeFileSystemClient fsc, Str
553553
return Objects.equals(RECEIVED_LEASE_ID, leaseID) ? createLeaseClient(fsc).acquireLease(-1) : leaseID;
554554
}
555555

556+
protected String setupFileSystemLeaseCondition(DataLakeFileSystemAsyncClient fsc, String leaseID) {
557+
return Objects.equals(RECEIVED_LEASE_ID, leaseID) ? createLeaseAsyncClient(fsc).acquireLease(-1).block() : leaseID;
558+
}
559+
556560
/**
557561
* This will retrieve the etag to be used in testing match conditions. The result will typically be assigned to
558562
* the ifMatch condition when testing success and the ifNoneMatch condition when testing failure.
@@ -593,15 +597,14 @@ protected String setupPathLeaseCondition(DataLakePathClient pc, String leaseID)
593597
return Objects.equals(RECEIVED_LEASE_ID, leaseID) ? responseLeaseId : leaseID;
594598
}
595599

596-
protected String setupPathLeaseCondition(DataLakePathAsyncClient pc, String leaseID) {
600+
protected String setupPathLeaseCondition(DataLakePathAsyncClient pac, String leaseID) {
597601
String responseLeaseId = null;
598602

599603
if (Objects.equals(RECEIVED_LEASE_ID, leaseID) || Objects.equals(GARBAGE_LEASE_ID, leaseID)) {
600-
responseLeaseId = (pc instanceof DataLakeFileAsyncClient)
601-
? createLeaseAsyncClient((DataLakeFileAsyncClient) pc).acquireLease(-1).block()
602-
: createLeaseAsyncClient((DataLakeDirectoryAsyncClient) pc).acquireLease(-1).block();
604+
responseLeaseId = (pac instanceof DataLakeFileAsyncClient)
605+
? createLeaseAsyncClient((DataLakeFileAsyncClient) pac).acquireLease(-1).block()
606+
: createLeaseAsyncClient((DataLakeDirectoryAsyncClient) pac).acquireLease(-1).block();
603607
}
604-
605608
return Objects.equals(RECEIVED_LEASE_ID, leaseID) ? responseLeaseId : leaseID;
606609
}
607610

@@ -891,4 +894,40 @@ public static void waitUntilPredicate(long delayMillis, int numberOfDelays, Supp
891894
public static boolean isLiveMode() {
892895
return ENVIRONMENT.getTestMode() == TestMode.LIVE;
893896
}
897+
898+
private static boolean olderThan20200210ServiceVersion() {
899+
return olderThan(DataLakeServiceVersion.V2020_02_10);
900+
}
901+
902+
private static boolean olderThan20201206ServiceVersion() {
903+
return olderThan(DataLakeServiceVersion.V2020_12_06);
904+
}
905+
906+
private static boolean olderThan20200612ServiceVersion() {
907+
return olderThan(DataLakeServiceVersion.V2020_06_12);
908+
}
909+
910+
private static boolean olderThan20210608ServiceVersion() {
911+
return olderThan(DataLakeServiceVersion.V2021_06_08);
912+
}
913+
914+
private static boolean olderThan20230803ServiceVersion() {
915+
return olderThan(DataLakeServiceVersion.V2023_08_03);
916+
}
917+
918+
private static boolean olderThan20200804ServiceVersion() {
919+
return olderThan(DataLakeServiceVersion.V2020_08_04);
920+
}
921+
922+
private static boolean olderThan20191212ServiceVersion() {
923+
return olderThan(DataLakeServiceVersion.V2019_12_12);
924+
}
925+
926+
private static boolean olderThan20201002ServiceVersion() {
927+
return olderThan(DataLakeServiceVersion.V2020_10_02);
928+
}
929+
930+
private static boolean olderThan20210410ServiceVersion() {
931+
return olderThan(DataLakeServiceVersion.V2021_04_10);
932+
}
894933
}

0 commit comments

Comments
 (0)