1313import ydb .tests .fq .s3 .s3_helpers as s3_helpers
1414from ydb .tests .tools .fq_runner .kikimr_utils import yq_v1 , yq_all
1515
16+ from moto import __version__ as moto_version
17+ from packaging .version import Version
18+
1619
1720class TestS3 (object ):
1821 def create_bucket_and_upload_file (self , filename , s3 , kikimr ):
@@ -435,7 +438,8 @@ def test_error(self, kikimr, s3, client, format, unique_prefix):
435438 )
436439
437440 bucket = resource .Bucket ("error_bucket" )
438- bucket .create (ACL = '' )
441+ acl = '' if Version (moto_version ) < Version ("4.0.5" ) else 'public-write'
442+ bucket .create (ACL = acl )
439443 bucket .objects .all ().delete ()
440444
441445 kikimr .control_plane .wait_bootstrap (1 )
@@ -462,18 +466,26 @@ def test_error(self, kikimr, s3, client, format, unique_prefix):
462466 )
463467
464468 query_id = client .create_query ("simple" , sql , type = fq .QueryContent .QueryType .ANALYTICS ).result .query_id
465- start_at = time .time ()
466- while True :
467- result = client .describe_query (query_id ).result
468- assert result .query .meta .status in [
469- fq .QueryMeta .STARTING ,
470- fq .QueryMeta .RUNNING ,
471- ], "Query is not RUNNING anymore"
472- issues = result .query .transient_issue
473- if "500 Internal Server Error" in str (issues ):
474- break
475- assert time .time () - start_at < 20 , "Timeout waiting for transient issue in " + str (issues )
476- time .sleep (0.5 )
469+ if Version (moto_version ) < Version ("4.0.5" ):
470+ start_at = time .time ()
471+ while True :
472+ result = client .describe_query (query_id ).result
473+ assert result .query .meta .status in [
474+ fq .QueryMeta .STARTING ,
475+ fq .QueryMeta .RUNNING ,
476+ ], "Query is not RUNNING anymore"
477+ issues = result .query .transient_issue
478+ if "500 Internal Server Error" in str (issues ):
479+ break
480+ assert time .time () - start_at < 20 , "Timeout waiting for transient issue in " + str (issues )
481+ time .sleep (0.5 )
482+ else :
483+ # Available since moto version 4.0.5+
484+ client .wait_query_status (query_id , fq .QueryMeta .FAILED )
485+ msg = client .describe_query (query_id ).result .query .issue
486+ assert 'HTTP error code: 403' in str (msg )
487+ assert 'Query failed with code EXTERNAL_ERROR' in str (msg )
488+
477489 client .abort_query (query_id )
478490 client .wait_query (query_id )
479491
0 commit comments