Skip to content

Commit adb46e2

Browse files
authored
Resolving Misc Pipeline Test Failures (#45352)
* removing management plane interaction and replacing with data plane interaction so it doesnt explode with 429s * making root tests playback only * misc timeout adjustments * removing unused test * marking httpfaultinjectingtests as isolated and removing redundant helper class * spotless
1 parent 85ada50 commit adb46e2

File tree

7 files changed

+40
-198
lines changed

7 files changed

+40
-198
lines changed

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobTestBase.java

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import com.azure.identity.ChainedTokenCredentialBuilder;
3838
import com.azure.identity.DefaultAzureCredentialBuilder;
3939
import com.azure.identity.EnvironmentCredentialBuilder;
40-
import com.azure.json.JsonProviders;
4140
import com.azure.json.JsonSerializable;
4241
import com.azure.json.JsonWriter;
4342
import com.azure.storage.blob.models.BlobContainerItem;
@@ -68,7 +67,6 @@
6867
import reactor.core.publisher.Mono;
6968
import reactor.test.StepVerifier;
7069

71-
import java.io.ByteArrayOutputStream;
7270
import java.io.File;
7371
import java.io.IOException;
7472
import java.io.InputStream;
@@ -165,6 +163,10 @@ public class BlobTestBase extends TestProxyTestBase {
165163

166164
protected String prefix;
167165

166+
// used to support cross package tests without taking a dependency on the package
167+
protected HttpPipeline dataPlanePipeline;
168+
protected HttpHeaders genericHeaders;
169+
168170
// used to build pipeline to management plane
169171
protected static final String RESOURCE_GROUP_NAME = ENVIRONMENT.getResourceGroupName();
170172
protected static final String SUBSCRIPTION_ID = ENVIRONMENT.getSubscriptionId();
@@ -875,22 +877,15 @@ protected Mono<?> setAccessPolicySleepAsync(BlobContainerAsyncClient cc, PublicA
875877
return setPolicyMono;
876878
}
877879

878-
protected String generateShareName() {
879-
return generateResourceName(entityNo++);
880-
}
881-
882880
protected String createFileAndDirectoryWithoutFileShareDependency(byte[] data, String shareName)
883881
throws IOException {
884882
String accountName = ENVIRONMENT.getPrimaryAccount().getName();
885883
//authenticate
886884
BearerTokenAuthenticationPolicy credentialPolicyDataPlane = new BearerTokenAuthenticationPolicy(
887885
getTokenCredential(ENVIRONMENT.getTestMode()), Constants.STORAGE_SCOPE);
888886

889-
//create share through management plane
890-
createFileShareWithoutDependency(shareName);
891-
892887
//setup headers that will be used in every request
893-
HttpHeaders genericHeaders = new HttpHeaders().set(X_MS_VERSION, "2025-07-05")
888+
genericHeaders = new HttpHeaders().set(X_MS_VERSION, "2025-07-05")
894889
.set(HttpHeaderName.ACCEPT, "application/xml")
895890
.set(HttpHeaderName.HOST, accountName + ".file.core.windows.net")
896891
.set(HttpHeaderName.CONTENT_LENGTH, "0")
@@ -904,8 +899,15 @@ protected String createFileAndDirectoryWithoutFileShareDependency(byte[] data, S
904899
policies.add(new RequestIdPolicy());
905900

906901
// create data plane pipeline
907-
HttpPipeline dataPlanePipeline
908-
= new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])).build();
902+
dataPlanePipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])).build();
903+
904+
// create share through data plane pipeline
905+
String shareUrl = String.format("https://%s.file.core.windows.net/%s?restype=share", accountName, shareName);
906+
907+
HttpResponse shareCreateResponse
908+
= dataPlanePipeline.send(new HttpRequest(HttpMethod.PUT, new URL(shareUrl), genericHeaders)).block();
909+
assertNotNull(shareCreateResponse);
910+
assertEquals(201, shareCreateResponse.getStatusCode());
909911

910912
// create directory
911913
String directoryName = generateBlobName();
@@ -945,48 +947,14 @@ protected String createFileAndDirectoryWithoutFileShareDependency(byte[] data, S
945947
return fileUrl;
946948
}
947949

948-
protected void createFileShareWithoutDependency(String shareName) throws IOException {
949-
String shareID = getFileShareID(shareName);
950-
Body shareBody = new Body();
951-
shareBody.setId(shareID);
952-
shareBody.setName(shareName);
953-
shareBody.setType("Microsoft.Storage/storageAccounts/fileServices/shares");
954-
955-
ByteArrayOutputStream shareJson = new ByteArrayOutputStream();
956-
try (JsonWriter jsonWriter = JsonProviders.createWriter(shareJson)) {
957-
shareBody.toJson(jsonWriter);
958-
}
959-
HttpResponse response
960-
= getManagementPlanePipeline().send(new HttpRequest(HttpMethod.PUT, new URL(getFileShareUri(shareID)),
961-
new HttpHeaders(), Flux.just(ByteBuffer.wrap(shareJson.toByteArray())))).block();
962-
assertNotNull(response);
963-
assertEquals(201, response.getStatusCode());
964-
}
965-
966950
protected void deleteFileShareWithoutDependency(String shareName) throws IOException {
967-
String shareID = getFileShareID(shareName);
968-
HttpResponse response = getManagementPlanePipeline()
969-
.send(new HttpRequest(HttpMethod.DELETE, new URL(getFileShareUri(shareID)), new HttpHeaders()))
970-
.block();
971-
assertNotNull(response);
972-
assertEquals(200, response.getStatusCode());
973-
}
974-
975-
protected HttpPipeline getManagementPlanePipeline() {
976-
BearerTokenAuthenticationPolicy credentialPolicyManagementPlane = new BearerTokenAuthenticationPolicy(
977-
getTokenCredential(ENVIRONMENT.getTestMode()), "https://management.azure.com/.default");
978-
return new HttpPipelineBuilder().policies(credentialPolicyManagementPlane).build();
979-
}
951+
String shareUrl = String.format("https://%s.file.core.windows.net/%s?restype=share",
952+
ENVIRONMENT.getPrimaryAccount().getName(), shareName);
980953

981-
protected String getFileShareID(String shareName) {
982-
return String.format(
983-
"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/"
984-
+ "%s/fileServices/default/shares/%s",
985-
SUBSCRIPTION_ID, RESOURCE_GROUP_NAME, ENVIRONMENT.getPrimaryAccount().getName(), shareName);
986-
}
987-
988-
protected String getFileShareUri(String fileShareID) {
989-
return "https://management.azure.com" + fileShareID + "?api-version=2024-01-01";
954+
HttpResponse shareDeleteResponse
955+
= dataPlanePipeline.send(new HttpRequest(HttpMethod.DELETE, new URL(shareUrl), genericHeaders)).block();
956+
assertNotNull(shareDeleteResponse);
957+
assertEquals(202, shareDeleteResponse.getStatusCode());
990958
}
991959

992960
public static final class Body implements JsonSerializable<Body> {
@@ -1058,10 +1026,6 @@ public static final class ImmutableStorageWithVersioning
10581026
implements JsonSerializable<ImmutableStorageWithVersioning> {
10591027
private boolean enabled;
10601028

1061-
public boolean isEnabled() {
1062-
return enabled;
1063-
}
1064-
10651029
public void setEnabled(boolean enabled) {
10661030
this.enabled = enabled;
10671031
}
@@ -1073,7 +1037,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
10731037
}
10741038
}
10751039

1076-
//todo: change the copy of this method in StorageCommonTestUtils to take in TestMode instead of interception manager
1040+
//todo isbr: change the copy of this method in StorageCommonTestUtils to take in TestMode instead of interception manager
10771041
protected static TokenCredential getTokenCredential(TestMode testMode) {
10781042
if (testMode == TestMode.RECORD) {
10791043
return new DefaultAzureCredentialBuilder().build();

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerApiTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,7 @@ public void createURLSpecialCharsDecoded(String name) {
17601760
}
17611761

17621762
@Test
1763+
@PlaybackOnly
17631764
public void rootExplicit() {
17641765
cc = primaryBlobServiceClient.getBlobContainerClient(BlobContainerClient.ROOT_CONTAINER_NAME);
17651766
// create root container if not exist.
@@ -1771,6 +1772,7 @@ public void rootExplicit() {
17711772
}
17721773

17731774
@Test
1775+
@PlaybackOnly
17741776
public void rootExplicitInEndpoint() {
17751777
cc = primaryBlobServiceClient.getBlobContainerClient(BlobContainerClient.ROOT_CONTAINER_NAME);
17761778
// create root container if not exist.
@@ -1788,6 +1790,7 @@ public void rootExplicitInEndpoint() {
17881790
}
17891791

17901792
@Test
1793+
@PlaybackOnly
17911794
public void blobClientBuilderRootImplicit() {
17921795
cc = primaryBlobServiceClient.getBlobContainerClient(BlobContainerClient.ROOT_CONTAINER_NAME);
17931796
// createroot container if not exist.
@@ -1810,6 +1813,7 @@ public void blobClientBuilderRootImplicit() {
18101813
}
18111814

18121815
@Test
1816+
@PlaybackOnly
18131817
public void containerClientBuilderRootImplicit() {
18141818
cc = primaryBlobServiceClient.getBlobContainerClient(BlobContainerClient.ROOT_CONTAINER_NAME);
18151819
// create root container if not exist.

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ContainerAsyncApiTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,6 +1859,7 @@ public void createURLSpecialCharsEncoded(String name) {
18591859
}
18601860

18611861
@Test
1862+
@PlaybackOnly
18621863
public void rootExplicit() {
18631864
ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(BlobContainerClient.ROOT_CONTAINER_NAME);
18641865
// create root container if not exist.
@@ -1874,6 +1875,7 @@ public void rootExplicit() {
18741875
}
18751876

18761877
@Test
1878+
@PlaybackOnly
18771879
public void rootExplicitInEndpoint() {
18781880
ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(BlobContainerClient.ROOT_CONTAINER_NAME);
18791881
// create root container if not exist.
@@ -1893,6 +1895,7 @@ public void rootExplicitInEndpoint() {
18931895
}
18941896

18951897
@Test
1898+
@PlaybackOnly
18961899
public void blobClientBuilderRootImplicit() {
18971900
ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(BlobContainerClient.ROOT_CONTAINER_NAME);
18981901
// createroot container if not exist.
@@ -1917,6 +1920,7 @@ public void blobClientBuilderRootImplicit() {
19171920
}
19181921

19191922
@Test
1923+
@PlaybackOnly
19201924
public void containerClientBuilderRootImplicit() {
19211925
ccAsync = primaryBlobServiceAsyncClient.getBlobContainerAsyncClient(BlobContainerClient.ROOT_CONTAINER_NAME);
19221926
// create root container if not exist.

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceApiTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,8 @@ public void restoreContainerWithResponse() {
10211021
sleepIfRunningAgainstService(30000);
10221022

10231023
Response<BlobContainerClient> response = primaryBlobServiceClient.undeleteBlobContainerWithResponse(
1024-
new UndeleteBlobContainerOptions(blobContainerItem.getName(), blobContainerItem.getVersion()),
1025-
Duration.ofMinutes(1), Context.NONE);
1024+
new UndeleteBlobContainerOptions(blobContainerItem.getName(), blobContainerItem.getVersion()), null,
1025+
Context.NONE);
10261026
BlobContainerClient restoredContainerClient = response.getValue();
10271027

10281028
assertNotNull(response);

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobApiTests.java

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,42 +1306,6 @@ private static Stream<Arguments> bufferedUploadSyncHandlePathingWithTransientFai
13061306
return Stream.of(Arguments.of(11110, 0), Arguments.of(2 * Constants.MB + 11, 2));
13071307
}
13081308

1309-
/*
1310-
def "Upload NRF progress"() {
1311-
setup:
1312-
def data = getRandomData(BlockBlobURL.MAX_UPLOAD_BLOB_BYTES + 1)
1313-
def numBlocks = data.remaining() / BlockBlobURL.MAX_STAGE_BLOCK_BYTES
1314-
long prevCount = 0
1315-
def mockReceiver = Mock(IProgressReceiver)
1316-
1317-
1318-
when:
1319-
TransferManager.uploadFromNonReplayableFlowable(Flowable.just(data), bu, BlockBlobURL.MAX_STAGE_BLOCK_BYTES, 10,
1320-
new TransferManagerUploadToBlockBlobOptions(mockReceiver, null, null, null, 20)).blockingGet()
1321-
data.position(0)
1322-
1323-
then:
1324-
// We should receive exactly one notification of the completed progress.
1325-
1 * mockReceiver.reportProgress(data.remaining()) */
1326-
1327-
/*
1328-
We should receive at least one notification reporting an intermediary value per block, but possibly more
1329-
notifications will be received depending on the implementation. We specify numBlocks - 1 because the last block
1330-
will be the total size as above. Finally, we assert that the number reported monotonically increases.
1331-
*/
1332-
/*(numBlocks - 1.._) * mockReceiver.reportProgress(!data.remaining()) >> { long bytesTransferred ->
1333-
if (!(bytesTransferred > prevCount)) {
1334-
throw new IllegalArgumentException("Reported progress should monotonically increase")
1335-
} else {
1336-
prevCount = bytesTransferred
1337-
}
1338-
}
1339-
1340-
// We should receive no notifications that report more progress than the size of the file.
1341-
0 * mockReceiver.reportProgress({ it > data.remaining() })
1342-
notThrown(IllegalArgumentException)
1343-
}*/
1344-
13451309
@LiveOnly
13461310
@Test
13471311
public void bufferedUploadOverwrite() throws IOException {
@@ -1581,7 +1545,7 @@ public void uploadFromUrlSourceRequestConditions(BlobRequestConditions requestCo
15811545
private static Stream<Arguments> uploadFromUrlSourceRequestConditionsSupplier() {
15821546
return Stream.of(
15831547
Arguments.of(new BlobRequestConditions().setIfMatch("dummy"), BlobErrorCode.SOURCE_CONDITION_NOT_MET),
1584-
Arguments.of(new BlobRequestConditions().setIfModifiedSince(OffsetDateTime.now().plusSeconds(20)),
1548+
Arguments.of(new BlobRequestConditions().setIfModifiedSince(OffsetDateTime.now().plusDays(10)),
15851549
BlobErrorCode.CANNOT_VERIFY_COPY_SOURCE),
15861550
Arguments.of(new BlobRequestConditions().setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1)),
15871551
BlobErrorCode.CANNOT_VERIFY_COPY_SOURCE));

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlockBlobAsyncApiTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2546,7 +2546,7 @@ public void uploadFromUrlSourceRequestConditions(BlobRequestConditions requestCo
25462546
private static Stream<Arguments> uploadFromUrlSourceRequestConditionsSupplier() {
25472547
return Stream.of(
25482548
Arguments.of(new BlobRequestConditions().setIfMatch("dummy"), BlobErrorCode.SOURCE_CONDITION_NOT_MET),
2549-
Arguments.of(new BlobRequestConditions().setIfModifiedSince(OffsetDateTime.now().plusSeconds(10)),
2549+
Arguments.of(new BlobRequestConditions().setIfModifiedSince(OffsetDateTime.now().plusDays(10)),
25502550
BlobErrorCode.CANNOT_VERIFY_COPY_SOURCE),
25512551
Arguments.of(new BlobRequestConditions().setIfUnmodifiedSince(OffsetDateTime.now().minusDays(1)),
25522552
BlobErrorCode.CANNOT_VERIFY_COPY_SOURCE));

0 commit comments

Comments
 (0)