Skip to content

Commit e974aee

Browse files
Fix byte limits in new smart retry tests for proper interruption handling
The new tests were failing with 0 bytes returned because the default MockPartialResponsePolicy byte limit (200 bytes) was too small for 4KB data with 1KB segments. Updated tests to use appropriate byte limits: - interruptWithDataIntact: 1200 bytes (ensures first 1KB segment completes) - interruptMultipleTimesWithDataIntact: 800 bytes (enables 3 interrupts with 4KB data) - interruptAndVerifyProperDecode: 1000 bytes (enables 2 interrupts with 4KB data) With 4KB data and 1KB segments, encoded size is ~4189 bytes: - Message header: 13 bytes - Each segment: 10 (header) + 1024 (data) + 8 (CRC) = 1042 bytes - Message CRC: 8 bytes - Total: 13 + (4 * 1042) + 8 = 4189 bytes These byte limits ensure segments complete before interruption, enabling proper smart retry from segment boundaries. Co-authored-by: gunjansingh-msft <[email protected]>
1 parent f5aca25 commit e974aee

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,8 @@ public void interruptWithDataIntact() throws IOException {
518518

519519
// Create a policy that will simulate 1 network interruption at a specific position
520520
// Interrupt after first segment completes to test smart retry from segment boundary
521-
MockPartialResponsePolicy mockPolicy = new MockPartialResponsePolicy(1);
521+
// Use 1200 bytes to ensure at least one 1KB segment completes
522+
MockPartialResponsePolicy mockPolicy = new MockPartialResponsePolicy(1, 1200);
522523

523524
// Upload the encoded data
524525
bc.upload(input, null, true).block();
@@ -562,7 +563,8 @@ public void interruptMultipleTimesWithDataIntact() throws IOException {
562563
Flux<ByteBuffer> input = Flux.just(encodedData);
563564

564565
// Create a policy that will simulate 3 network interruptions
565-
MockPartialResponsePolicy mockPolicy = new MockPartialResponsePolicy(3);
566+
// Use 800 bytes for subsequent interruptions to get 3 interrupts with 4KB data + 1KB segments
567+
MockPartialResponsePolicy mockPolicy = new MockPartialResponsePolicy(3, 800);
566568

567569
// Upload the encoded data
568570
bc.upload(input, null, true).block();
@@ -667,7 +669,8 @@ public void interruptAndVerifyProperDecode() throws IOException {
667669
Flux<ByteBuffer> input = Flux.just(encodedData);
668670

669671
// Create a policy with 2 interruptions to test multi-step decode after retries
670-
MockPartialResponsePolicy mockPolicy = new MockPartialResponsePolicy(2);
672+
// Use 1000 bytes to get 2 interruptions with 4KB data + 1KB segments
673+
MockPartialResponsePolicy mockPolicy = new MockPartialResponsePolicy(2, 1000);
671674

672675
// Upload the encoded data
673676
bc.upload(input, null, true).block();

0 commit comments

Comments
 (0)