Skip to content

Commit 362fd7b

Browse files
authored
Merge pull request #99 from ydb-platform/fix-exception-not-foud
Refactor test
2 parents 419cd14 + 32dd3f4 commit 362fd7b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* added microseconds in Timestamp type
44

55
## 1.8.2
6+
67
* fixed discovery on exception
78
* fixed logger in EnvironCredentials
89

tests/RetryParams.php renamed to tests/RetryParamsTest.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818
use YdbPlatform\Ydb\Exceptions\Grpc\UnavailableException;
1919
use YdbPlatform\Ydb\Exceptions\Grpc\UnimplementedException;
2020
use YdbPlatform\Ydb\Exceptions\Grpc\UnknownException;
21-
use YdbPlatform\Ydb\Exceptions\RetryableException;
2221
use YdbPlatform\Ydb\Exceptions\Ydb\BadRequestException;
2322
use YdbPlatform\Ydb\Exceptions\Ydb\InternalErrorException;
2423
use YdbPlatform\Ydb\Exceptions\Ydb\StatusCodeUnspecified;
2524
use YdbPlatform\Ydb\Exceptions\Ydb\UnauthorizedException;
25+
use YdbPlatform\Ydb\Logger\SimpleStdLogger;
2626
use YdbPlatform\Ydb\Retry\Backoff;
2727
use YdbPlatform\Ydb\Retry\RetryParams;
28-
use YdbPlatform\Ydb\Session;
2928
use YdbPlatform\Ydb\Table;
3029
use YdbPlatform\Ydb\Ydb;
3130
use YdbPlatform\Ydb\Retry\Retry;
@@ -48,7 +47,7 @@ public function deleteSession(string $exception): bool
4847
}
4948
}
5049

51-
class RetryTest2 extends \PHPUnit\Framework\TestCase
50+
class RetryParamsTest extends \PHPUnit\Framework\TestCase
5251
{
5352
protected const FAST = 5;
5453
protected const SLOW = 20;
@@ -370,22 +369,25 @@ public function test(){
370369
$retryParams = new RetryParams(1000, new Backoff(6,self::FAST),
371370
new Backoff(6,self::SLOW));
372371

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);
375375

376376
foreach ($this->errsToCheck as $error) {
377377

378+
$exception = new $error["class"]();
379+
378380
$resultDeleteSession = $table->deleteSession($error["class"]) ? "true" : "false";
379381
$wantDeleteSession = $error["deleteSession"] ? "true" : "false";
380382
self::assertEquals($wantDeleteSession, $resultDeleteSession,
381383
"{$error["class"]}: unexpected delete session status: $resultDeleteSession, want: $wantDeleteSession");
382384

383-
$resultRetryIdempotent = $retry->canRetry(new $error["class"](), true) ? "true" : "false";
385+
$resultRetryIdempotent = $retry->canRetry($exception, true) ? "true" : "false";
384386
$wantRetryIdempotent = $error["retry"]["idempotent"] ? "true" : "false";
385387
self::assertEquals($wantRetryIdempotent, $resultRetryIdempotent,
386388
"{$error["class"]}: unexpected must retry idempotent operation status: $resultRetryIdempotent, want: $wantRetryIdempotent");
387389

388-
$resultRetryNonIdempotent = $retry->canRetry(new $error["class"](), false) ? "true" : "false";
390+
$resultRetryNonIdempotent = $retry->canRetry($exception, false) ? "true" : "false";
389391
$wantRetryNonIdempotent = $error["retry"]["nonIdempotent"] ? "true" : "false";
390392
self::assertEquals($wantRetryNonIdempotent, $resultRetryNonIdempotent,
391393
"{$error["class"]}: unexpected must retry non-idempotent operation status: $resultDeleteSession, want: $wantDeleteSession");

0 commit comments

Comments
 (0)