Skip to content

Commit 7fa1fc2

Browse files
authored
Service and Lease Api Async Tests (Azure#37057)
* service and lease tests * service and lease tests * more lease tests * lease consistency * rest of the lease tests * recordings, extra tests, and line length * style
1 parent 4a2e1dc commit 7fa1fc2

File tree

5 files changed

+1405
-10
lines changed

5 files changed

+1405
-10
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_8f2462b720"
5+
"Tag": "java/storage/azure-storage-file-datalake_b9cf22c9e8"
66
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ protected DataLakeServiceAsyncClient getServiceAsyncClient(TestAccount account)
263263
return getServiceClientBuilder(account.getCredential(), account.getDataLakeEndpoint()).buildAsyncClient();
264264
}
265265

266+
protected DataLakeServiceAsyncClient getServiceAsyncClient(StorageSharedKeyCredential credential, String endpoint) {
267+
return getServiceClientBuilder(credential, endpoint).buildAsyncClient();
268+
}
269+
266270
/**
267271
* Some tests require extra configuration for retries when writing.
268272
* <p>
@@ -553,7 +557,7 @@ protected String setupFileSystemLeaseCondition(DataLakeFileSystemClient fsc, Str
553557
return Objects.equals(RECEIVED_LEASE_ID, leaseID) ? createLeaseClient(fsc).acquireLease(-1) : leaseID;
554558
}
555559

556-
protected String setupFileSystemLeaseCondition(DataLakeFileSystemAsyncClient fsc, String leaseID) {
560+
protected String setupFileSystemLeaseAsyncCondition(DataLakeFileSystemAsyncClient fsc, String leaseID) {
557561
return Objects.equals(RECEIVED_LEASE_ID, leaseID) ? createLeaseAsyncClient(fsc).acquireLease(-1).block() : leaseID;
558562
}
559563

@@ -930,4 +934,6 @@ private static boolean olderThan20201002ServiceVersion() {
930934
private static boolean olderThan20210410ServiceVersion() {
931935
return olderThan(DataLakeServiceVersion.V2021_04_10);
932936
}
937+
938+
933939
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public void getPropertiesMin() {
288288

289289
@Test
290290
public void getPropertiesLease() {
291-
String leaseID = setupFileSystemLeaseCondition(dataLakeFileSystemAsyncClient, RECEIVED_LEASE_ID);
291+
String leaseID = setupFileSystemLeaseAsyncCondition(dataLakeFileSystemAsyncClient, RECEIVED_LEASE_ID);
292292

293293
assertAsyncResponseStatusCode(dataLakeFileSystemAsyncClient.getPropertiesWithResponse(leaseID), 200);
294294
}
@@ -376,7 +376,7 @@ public void setMetadataMetadata(String key1, String value1, String key2, String
376376
@ParameterizedTest
377377
@MethodSource("setMetadataACSupplier")
378378
public void setMetadataAC(OffsetDateTime modified, String leaseID) {
379-
leaseID = setupFileSystemLeaseCondition(dataLakeFileSystemAsyncClient, leaseID);
379+
leaseID = setupFileSystemLeaseAsyncCondition(dataLakeFileSystemAsyncClient, leaseID);
380380
DataLakeRequestConditions drc = new DataLakeRequestConditions().setLeaseId(leaseID).setIfModifiedSince(modified);
381381

382382
assertAsyncResponseStatusCode(dataLakeFileSystemAsyncClient.setMetadataWithResponse(null, drc), 200);
@@ -465,7 +465,7 @@ public void deleteMin() {
465465
@MethodSource("modifiedAndLeaseIdSupplier")
466466
public void deleteAC(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) {
467467
DataLakeRequestConditions drc = new DataLakeRequestConditions()
468-
.setLeaseId(setupFileSystemLeaseCondition(dataLakeFileSystemAsyncClient, leaseID))
468+
.setLeaseId(setupFileSystemLeaseAsyncCondition(dataLakeFileSystemAsyncClient, leaseID))
469469
.setIfModifiedSince(modified)
470470
.setIfUnmodifiedSince(unmodified);
471471

@@ -581,7 +581,7 @@ public void deleteIfExistsOnFileSystemThatDoesNotExist() {
581581
@MethodSource("modifiedAndLeaseIdSupplier")
582582
public void deleteIfExistsAC(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) {
583583
DataLakeRequestConditions drc = new DataLakeRequestConditions()
584-
.setLeaseId(setupFileSystemLeaseCondition(dataLakeFileSystemAsyncClient, leaseID))
584+
.setLeaseId(setupFileSystemLeaseAsyncCondition(dataLakeFileSystemAsyncClient, leaseID))
585585
.setIfModifiedSince(modified)
586586
.setIfUnmodifiedSince(unmodified);
587587

@@ -945,7 +945,7 @@ public void createFileOptionsWithTimeToExpireRelativeToNow() {
945945
@Test
946946
public void createIfNotExistsFileMin() {
947947
StepVerifier.create(dataLakeFileSystemAsyncClient.createFileIfNotExists(generatePathName())
948-
.flatMap(r -> r.exists()))
948+
.flatMap(DataLakePathAsyncClient::exists))
949949
.expectNext(true)
950950
.verifyComplete();
951951
}
@@ -1580,7 +1580,7 @@ public void createDirOptionsWithTimeToExpire() {
15801580
@Test
15811581
public void createIfNotExistsDirMin() {
15821582
StepVerifier.create(dataLakeFileSystemAsyncClient.createDirectoryIfNotExists(generatePathName())
1583-
.flatMap(r -> r.exists()))
1583+
.flatMap(DataLakePathAsyncClient::exists))
15841584
.expectNext(true)
15851585
.verifyComplete();
15861586
}
@@ -2212,7 +2212,7 @@ public void setAccessPolicyIds() {
22122212
@MethodSource("modifiedAndLeaseIdSupplier")
22132213
public void setAccessPolicyAC(OffsetDateTime modified, OffsetDateTime unmodified, String leaseID) {
22142214
DataLakeRequestConditions cac = new DataLakeRequestConditions()
2215-
.setLeaseId(setupFileSystemLeaseCondition(dataLakeFileSystemAsyncClient, leaseID))
2215+
.setLeaseId(setupFileSystemLeaseAsyncCondition(dataLakeFileSystemAsyncClient, leaseID))
22162216
.setIfModifiedSince(modified)
22172217
.setIfUnmodifiedSince(unmodified);
22182218

@@ -2275,7 +2275,7 @@ public void getAccessPolicy() {
22752275

22762276
@Test
22772277
public void getAccessPolicyLease() {
2278-
String leaseID = setupFileSystemLeaseCondition(dataLakeFileSystemAsyncClient, RECEIVED_LEASE_ID);
2278+
String leaseID = setupFileSystemLeaseAsyncCondition(dataLakeFileSystemAsyncClient, RECEIVED_LEASE_ID);
22792279

22802280
assertAsyncResponseStatusCode(dataLakeFileSystemAsyncClient.getAccessPolicyWithResponse(leaseID), 200);
22812281
}

0 commit comments

Comments
 (0)