@@ -146,21 +146,26 @@ def assert_exception_is_present_on_retry_context(**kwargs):
146146 async def test_retry_on_socket_timeout_async (self , storage_account_name , storage_account_key ):
147147 # Arrange
148148 container_name = self .get_resource_name ('utcontainer' )
149- retry = LinearRetry (backoff = 1 )
149+ blob_name = self .get_resource_name ('blob' )
150+ # Upload a blob that can be downloaded to test read timeout
151+ service = self ._create_storage_service (BlobServiceClient , storage_account_name , storage_account_key )
152+ container = await service .create_container (container_name )
153+ await container .upload_blob (blob_name , b'a' * 5 * 1025 , overwrite = True )
154+
155+ retry = LinearRetry (backoff = 1 , random_jitter_range = 1 )
150156 retry_transport = AiohttpRetryTestTransport (connection_timeout = 11 , read_timeout = 0.000000000001 )
151157 # make the connect timeout reasonable, but packet timeout truly small, to make sure the request always times out
152158 service = self ._create_storage_service (
153159 BlobServiceClient , storage_account_name , storage_account_key , retry_policy = retry , transport = retry_transport )
160+ blob = service .get_blob_client (container_name , blob_name )
154161
155162 assert service ._client ._client ._pipeline ._transport .connection_config .timeout == 11
156163 assert service ._client ._client ._pipeline ._transport .connection_config .read_timeout == 0.000000000001
157164
158165 # Act
159166 try :
160167 with self .assertRaises (AzureError ) as error :
161- await service .create_container (container_name )
162-
163-
168+ await blob .download_blob ()
164169 # Assert
165170 # 3 retries + 1 original == 4
166171 assert retry_transport .count == 4
@@ -172,10 +177,7 @@ async def test_retry_on_socket_timeout_async(self, storage_account_name, storage
172177
173178 finally :
174179 # we must make the timeout normal again to let the delete operation succeed
175- try :
176- await service .delete_container (container_name , connection_timeout = 11 )
177- except :
178- pass
180+ await service .delete_container (container_name , connection_timeout = 11 , read_timeout = 11 )
179181
180182 @BlobPreparer ()
181183 @AsyncStorageTestCase .await_prepared_test
0 commit comments