Skip to content

Commit

Permalink
File System Api Async Tests (#37037)
Browse files Browse the repository at this point in the history
* starting tests

* more tests

* all tests but one

* lease testbase consistency

* service versions and recordings

* style and version adding

* more style
  • Loading branch information
ibrandes authored Oct 5, 2023
1 parent 7d97d0b commit d0cfcce
Show file tree
Hide file tree
Showing 12 changed files with 2,600 additions and 341 deletions.
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-file-datalake/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/storage/azure-storage-file-datalake",
"Tag": "java/storage/azure-storage-file-datalake_7647723dc8"
"Tag": "java/storage/azure-storage-file-datalake_8f2462b720"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1079,12 +1079,11 @@ public Mono<DataLakeFileAsyncClient> createFileIfNotExists(String fileName) {
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<DataLakeFileAsyncClient>> createFileIfNotExistsWithResponse(String fileName,
DataLakePathCreateOptions options) {
DataLakeRequestConditions requestConditions = new DataLakeRequestConditions()
.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD);
options = options == null ? new DataLakePathCreateOptions() : options;
options.setRequestConditions(new DataLakeRequestConditions()
.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD));
try {
return createFileWithResponse(fileName, options.getPermissions(), options.getUmask(),
options.getPathHttpHeaders(), options.getMetadata(), requestConditions)
return createFileWithResponse(fileName, options)
.onErrorResume(t -> t instanceof DataLakeStorageException && ((DataLakeStorageException) t)
.getStatusCode() == 409,
t -> {
Expand Down Expand Up @@ -1444,11 +1443,11 @@ public Mono<DataLakeDirectoryAsyncClient> createDirectoryIfNotExists(String dire
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<DataLakeDirectoryAsyncClient>> createDirectoryIfNotExistsWithResponse(String directoryName,
DataLakePathCreateOptions options) {
options = options == null ? new DataLakePathCreateOptions() : options;
options.setRequestConditions(new DataLakeRequestConditions()
.setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD));
try {
options = options == null ? new DataLakePathCreateOptions() : options;
return createDirectoryWithResponse(directoryName, options.getPermissions(), options.getUmask(),
options.getPathHttpHeaders(), options.getMetadata(),
new DataLakeRequestConditions().setIfNoneMatch(Constants.HeaderConstants.ETAG_WILDCARD))
return createDirectoryWithResponse(directoryName, options)
.onErrorResume(t -> t instanceof DataLakeStorageException && ((DataLakeStorageException) t)
.getStatusCode() == 409,
t -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,10 @@ protected String setupFileSystemLeaseCondition(DataLakeFileSystemClient fsc, Str
return Objects.equals(RECEIVED_LEASE_ID, leaseID) ? createLeaseClient(fsc).acquireLease(-1) : leaseID;
}

protected String setupFileSystemLeaseCondition(DataLakeFileSystemAsyncClient fsc, String leaseID) {
return Objects.equals(RECEIVED_LEASE_ID, leaseID) ? createLeaseAsyncClient(fsc).acquireLease(-1).block() : leaseID;
}

/**
* This will retrieve the etag to be used in testing match conditions. The result will typically be assigned to
* the ifMatch condition when testing success and the ifNoneMatch condition when testing failure.
Expand Down Expand Up @@ -593,15 +597,14 @@ protected String setupPathLeaseCondition(DataLakePathClient pc, String leaseID)
return Objects.equals(RECEIVED_LEASE_ID, leaseID) ? responseLeaseId : leaseID;
}

protected String setupPathLeaseCondition(DataLakePathAsyncClient pc, String leaseID) {
protected String setupPathLeaseCondition(DataLakePathAsyncClient pac, String leaseID) {
String responseLeaseId = null;

if (Objects.equals(RECEIVED_LEASE_ID, leaseID) || Objects.equals(GARBAGE_LEASE_ID, leaseID)) {
responseLeaseId = (pc instanceof DataLakeFileAsyncClient)
? createLeaseAsyncClient((DataLakeFileAsyncClient) pc).acquireLease(-1).block()
: createLeaseAsyncClient((DataLakeDirectoryAsyncClient) pc).acquireLease(-1).block();
responseLeaseId = (pac instanceof DataLakeFileAsyncClient)
? createLeaseAsyncClient((DataLakeFileAsyncClient) pac).acquireLease(-1).block()
: createLeaseAsyncClient((DataLakeDirectoryAsyncClient) pac).acquireLease(-1).block();
}

return Objects.equals(RECEIVED_LEASE_ID, leaseID) ? responseLeaseId : leaseID;
}

Expand Down Expand Up @@ -891,4 +894,40 @@ public static void waitUntilPredicate(long delayMillis, int numberOfDelays, Supp
public static boolean isLiveMode() {
return ENVIRONMENT.getTestMode() == TestMode.LIVE;
}

private static boolean olderThan20200210ServiceVersion() {
return olderThan(DataLakeServiceVersion.V2020_02_10);
}

private static boolean olderThan20201206ServiceVersion() {
return olderThan(DataLakeServiceVersion.V2020_12_06);
}

private static boolean olderThan20200612ServiceVersion() {
return olderThan(DataLakeServiceVersion.V2020_06_12);
}

private static boolean olderThan20210608ServiceVersion() {
return olderThan(DataLakeServiceVersion.V2021_06_08);
}

private static boolean olderThan20230803ServiceVersion() {
return olderThan(DataLakeServiceVersion.V2023_08_03);
}

private static boolean olderThan20200804ServiceVersion() {
return olderThan(DataLakeServiceVersion.V2020_08_04);
}

private static boolean olderThan20191212ServiceVersion() {
return olderThan(DataLakeServiceVersion.V2019_12_12);
}

private static boolean olderThan20201002ServiceVersion() {
return olderThan(DataLakeServiceVersion.V2020_10_02);
}

private static boolean olderThan20210410ServiceVersion() {
return olderThan(DataLakeServiceVersion.V2021_04_10);
}
}
Loading

0 comments on commit d0cfcce

Please sign in to comment.