Skip to content

Commit 3e37e24

Browse files
Update test expectations to match smart retry implementation
All retry requests now start from offset 0 for structured message validation since the decoder must parse complete messages from the beginning. Co-authored-by: gunjansingh-msft <[email protected]>
1 parent 5038e4e commit 3e37e24

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

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

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -272,19 +272,14 @@ public void downloadStreamWithResponseContentValidationSmartRetry() throws IOExc
272272
List<String> rangeHeaders = mockPolicy.getRangeHeaders();
273273
assertTrue(rangeHeaders.size() > 0, "Expected range headers for retries");
274274

275-
// With structured message validation and smart retry, retries should resume from the encoded
276-
// offset where the interruption occurred. The first request starts at 0, and subsequent
277-
// retry requests should start from progressively higher offsets.
278-
assertTrue(rangeHeaders.get(0).startsWith("bytes=0-"), "First request should start from offset 0");
279-
280-
// Subsequent requests should start from higher offsets (smart retry resuming from where it left off)
281-
for (int i = 1; i < rangeHeaders.size(); i++) {
275+
// With structured message validation and smart retry, all requests (initial and retries)
276+
// must start from offset 0 because the structured message format requires sequential
277+
// parsing from the beginning. The decoder cannot resume mid-stream.
278+
// The policy skips already-emitted decoded bytes to avoid duplication.
279+
for (int i = 0; i < rangeHeaders.size(); i++) {
282280
String rangeHeader = rangeHeaders.get(i);
283-
// Each retry should start from a higher offset than the previous
284-
// Note: We can't assert exact offset values as they depend on how much data was received
285-
// before the interruption, but we can verify it's a valid range header
286-
assertTrue(rangeHeader.startsWith("bytes="),
287-
"Retry request " + i + " should have a range header: " + rangeHeader);
281+
assertTrue(rangeHeader.startsWith("bytes=0-"),
282+
"Request " + i + " should start from offset 0 for structured message validation: " + rangeHeader);
288283
}
289284
}
290285

@@ -334,18 +329,18 @@ public void downloadStreamWithResponseContentValidationSmartRetryMultipleSegment
334329
assertTrue(rangeHeaders.size() >= 4,
335330
"Expected at least 4 range headers for retries, got: " + rangeHeaders.size());
336331

337-
// With smart retry, each request should have a valid range header
332+
// With smart retry and structured message validation, all requests must start from offset 0
338333
for (int i = 0; i < rangeHeaders.size(); i++) {
339334
String rangeHeader = rangeHeaders.get(i);
340-
assertTrue(rangeHeader.startsWith("bytes="),
341-
"Request " + i + " should have a valid range header, but was: " + rangeHeader);
335+
assertTrue(rangeHeader.startsWith("bytes=0-"), "Request " + i
336+
+ " should start from offset 0 for structured message validation, but was: " + rangeHeader);
342337
}
343338
}
344339

345340
@Test
346341
public void downloadStreamWithResponseContentValidationSmartRetryLargeBlob() throws IOException {
347-
// Test smart retry with a larger blob to ensure retries resume from the
348-
// interrupted offset and successfully validate all data
342+
// Test smart retry with a larger blob to ensure retries restart from the beginning
343+
// and successfully validate all data after skipping already-emitted decoded bytes
349344

350345
byte[] randomData = getRandomByteArray(5 * Constants.KB);
351346
StructuredMessageEncoder encoder
@@ -383,12 +378,12 @@ public void downloadStreamWithResponseContentValidationSmartRetryLargeBlob() thr
383378
// Verify that retries occurred
384379
assertEquals(0, mockPolicy.getTriesRemaining());
385380

386-
// Verify that smart retry is working with valid range headers
381+
// Verify that all requests start from offset 0 for structured message validation
387382
List<String> rangeHeaders = mockPolicy.getRangeHeaders();
388383
for (int i = 0; i < rangeHeaders.size(); i++) {
389384
String rangeHeader = rangeHeaders.get(i);
390-
assertTrue(rangeHeader.startsWith("bytes="),
391-
"Request " + i + " should have a valid range header, but was: " + rangeHeader);
385+
assertTrue(rangeHeader.startsWith("bytes=0-"), "Request " + i
386+
+ " should start from offset 0 for structured message validation, but was: " + rangeHeader);
392387
}
393388
}
394389
}

0 commit comments

Comments
 (0)