@@ -4993,7 +4993,9 @@ def test_tiff_read_multi_threaded(
49934993
49944994
49954995@pytest .mark .parametrize ("use_dataset_readraster" , [True , False ])
4996- @pytest .mark .parametrize ("advise_read" , [True , False ])
4996+ @pytest .mark .parametrize (
4997+ "advise_read,test_retry" , [(True , False ), (True , True ), (False , False )]
4998+ )
49974999@pytest .mark .skipif (
49985000 platform .system () == "Darwin" or gdaltest .is_travis_branch ("mingw64" ),
49995001 reason = "fails randomly" ,
@@ -5003,7 +5005,9 @@ def test_tiff_read_multi_threaded(
50035005 not check_libtiff_internal_or_at_least (4 , 0 , 11 ),
50045006 reason = "libtiff >= 4.0.11 required" ,
50055007)
5006- def test_tiff_read_multi_threaded_vsicurl (use_dataset_readraster , advise_read ):
5008+ def test_tiff_read_multi_threaded_vsicurl (
5009+ use_dataset_readraster , advise_read , test_retry
5010+ ):
50075011
50085012 webserver_process = None
50095013 webserver_port = 0
@@ -5046,23 +5050,33 @@ def method(request):
50465050 f .seek (start , 0 )
50475051 request .wfile .write (f .read (end - start + 1 ))
50485052
5053+ def method_fail (request ):
5054+ request .protocol_version = "HTTP/1.1"
5055+ request .send_response (429 )
5056+ request .send_header ("Connection" , "close" )
5057+ request .end_headers ()
5058+
50495059 _ , blockYSize = ref_ds .GetRasterBand (1 ).GetBlockSize ()
50505060 if advise_read :
50515061 for i in range (3 ):
5062+ if test_retry :
5063+ handler .add ("GET" , "/utm.tif" , custom_method = method_fail )
50525064 handler .add ("GET" , "/utm.tif" , custom_method = method )
50535065 else :
50545066 for i in range (2 + ref_ds .RasterYSize // blockYSize ):
50555067 handler .add ("GET" , "/utm.tif" , custom_method = method )
50565068
50575069 with webserver .install_http_handler (handler ):
5058- with gdaltest .config_options (
5059- {
5060- "GDAL_NUM_THREADS" : "2" ,
5061- "CPL_VSIL_CURL_ALLOWED_EXTENSIONS" : ".tif" ,
5062- "GDAL_DISABLE_READDIR_ON_OPEN" : "EMPTY_DIR" ,
5063- "GDAL_HTTP_ENABLE_ADVISE_READ" : ("YES" if advise_read else "NO" ),
5064- }
5065- ):
5070+ options = {
5071+ "GDAL_NUM_THREADS" : "2" ,
5072+ "CPL_VSIL_CURL_ALLOWED_EXTENSIONS" : ".tif" ,
5073+ "GDAL_DISABLE_READDIR_ON_OPEN" : "EMPTY_DIR" ,
5074+ "GDAL_HTTP_ENABLE_ADVISE_READ" : ("YES" if advise_read else "NO" ),
5075+ }
5076+ if test_retry :
5077+ options ["GDAL_HTTP_MAX_RETRY" ] = "1"
5078+ options ["GDAL_HTTP_RETRY_DELAY" ] = ".1"
5079+ with gdaltest .config_options (options ):
50665080 ds = gdal .Open ("/vsicurl/http://127.0.0.1:%d/utm.tif" % webserver_port )
50675081 assert ds is not None , "could not open dataset"
50685082
0 commit comments