18
18
use YdbPlatform \Ydb \Exceptions \Grpc \UnavailableException ;
19
19
use YdbPlatform \Ydb \Exceptions \Grpc \UnimplementedException ;
20
20
use YdbPlatform \Ydb \Exceptions \Grpc \UnknownException ;
21
- use YdbPlatform \Ydb \Exceptions \RetryableException ;
22
21
use YdbPlatform \Ydb \Exceptions \Ydb \BadRequestException ;
23
22
use YdbPlatform \Ydb \Exceptions \Ydb \InternalErrorException ;
24
23
use YdbPlatform \Ydb \Exceptions \Ydb \StatusCodeUnspecified ;
25
24
use YdbPlatform \Ydb \Exceptions \Ydb \UnauthorizedException ;
25
+ use YdbPlatform \Ydb \Logger \SimpleStdLogger ;
26
26
use YdbPlatform \Ydb \Retry \Backoff ;
27
27
use YdbPlatform \Ydb \Retry \RetryParams ;
28
- use YdbPlatform \Ydb \Session ;
29
28
use YdbPlatform \Ydb \Table ;
30
29
use YdbPlatform \Ydb \Ydb ;
31
30
use YdbPlatform \Ydb \Retry \Retry ;
@@ -48,7 +47,7 @@ public function deleteSession(string $exception): bool
48
47
}
49
48
}
50
49
51
- class RetryTest2 extends \PHPUnit \Framework \TestCase
50
+ class RetryParamsTest extends \PHPUnit \Framework \TestCase
52
51
{
53
52
protected const FAST = 5 ;
54
53
protected const SLOW = 20 ;
@@ -370,22 +369,25 @@ public function test(){
370
369
$ retryParams = new RetryParams (1000 , new Backoff (6 ,self ::FAST ),
371
370
new Backoff (6 ,self ::SLOW ));
372
371
373
- $ retry = (new RetrySubclass ())->withParams ($ retryParams );
374
- $ table = new TableSubclass (new Ydb (["credentials " =>new AnonymousAuthentication ()]), null , $ retry );
372
+ $ logger = new SimpleStdLogger (7 );
373
+ $ retry = (new RetrySubclass ($ logger ))->withParams ($ retryParams );
374
+ $ table = new TableSubclass (new Ydb (["credentials " =>new AnonymousAuthentication ()]), $ logger , $ retry );
375
375
376
376
foreach ($ this ->errsToCheck as $ error ) {
377
377
378
+ $ exception = new $ error ["class " ]();
379
+
378
380
$ resultDeleteSession = $ table ->deleteSession ($ error ["class " ]) ? "true " : "false " ;
379
381
$ wantDeleteSession = $ error ["deleteSession " ] ? "true " : "false " ;
380
382
self ::assertEquals ($ wantDeleteSession , $ resultDeleteSession ,
381
383
"{$ error ["class " ]}: unexpected delete session status: $ resultDeleteSession, want: $ wantDeleteSession " );
382
384
383
- $ resultRetryIdempotent = $ retry ->canRetry (new $ error [ " class " ]() , true ) ? "true " : "false " ;
385
+ $ resultRetryIdempotent = $ retry ->canRetry ($ exception , true ) ? "true " : "false " ;
384
386
$ wantRetryIdempotent = $ error ["retry " ]["idempotent " ] ? "true " : "false " ;
385
387
self ::assertEquals ($ wantRetryIdempotent , $ resultRetryIdempotent ,
386
388
"{$ error ["class " ]}: unexpected must retry idempotent operation status: $ resultRetryIdempotent, want: $ wantRetryIdempotent " );
387
389
388
- $ resultRetryNonIdempotent = $ retry ->canRetry (new $ error [ " class " ]() , false ) ? "true " : "false " ;
390
+ $ resultRetryNonIdempotent = $ retry ->canRetry ($ exception , false ) ? "true " : "false " ;
389
391
$ wantRetryNonIdempotent = $ error ["retry " ]["nonIdempotent " ] ? "true " : "false " ;
390
392
self ::assertEquals ($ wantRetryNonIdempotent , $ resultRetryNonIdempotent ,
391
393
"{$ error ["class " ]}: unexpected must retry non-idempotent operation status: $ resultDeleteSession, want: $ wantDeleteSession " );
0 commit comments