Skip to content

Commit a071368

Browse files
committed
RavenDB_15497Test::waitForIndexesAfterSaveChangesCanExitWhenThrowOnTimeoutIsFalse
1 parent 9eb4648 commit a071368

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace RavenDB\Exceptions;
4+
5+
class RavenTimeoutException extends RavenException
6+
{
7+
private bool $failImmediately = false;
8+
9+
public function isFailImmediately(): bool
10+
{
11+
return $this->failImmediately;
12+
}
13+
14+
public function setFailImmediately(bool $failImmediately): void
15+
{
16+
$this->failImmediately = $failImmediately;
17+
}
18+
19+
}

tests/Test/Client/TrackEntityTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public function testDeletingEntityThatIsNotTrackedShouldThrow(): void
2323

2424
throw new Exception('It should throw exception before reaching this code');
2525
} catch (Throwable $exception) {
26-
print_r($exception->getMessage());
2726
$this->assertInstanceOf(IllegalStateException::class, $exception);
2827
$this->assertStringEndsWith("is not associated with the session, cannot delete unknown entity instance", $exception->getMessage());
2928
}

tests/Test/Issues/RavenDB_15497Test/RavenDB_15497Test.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
namespace tests\RavenDB\Test\Issues\RavenDB_15497Test;
44

55
use Exception;
6-
use RavenDB\Documents\Indexes\IndexStats;
7-
use RavenDB\Documents\Operations\Indexes\DisableIndexOperation;
8-
use RavenDB\Documents\Operations\Indexes\GetIndexStatisticsOperation;
9-
use RavenDB\Exceptions\TimeoutException;
6+
use RavenDB\Documents\Operations\Indexes\StopIndexOperation;
7+
use RavenDB\Exceptions\RavenTimeoutException;
108
use RavenDB\Type\Duration;
119
use tests\RavenDB\Infrastructure\Entity\User;
1210
use tests\RavenDB\RemoteTestBase;
@@ -20,18 +18,12 @@ public function testWaitForIndexesAfterSaveChangesCanExitWhenThrowOnTimeoutIsFal
2018
try {
2119
$index = new Index();
2220
$index->execute($store);
23-
$store->maintenance()->send(new DisableIndexOperation($index->getIndexName()));
24-
25-
/** @var IndexStats $indexStats */
26-
$indexStats = $store->maintenance()->send(new GetIndexStatisticsOperation($index->getIndexName()));
27-
28-
$this->assertTrue($indexStats->getState()->isDisabled());
29-
$this->assertTrue($indexStats->getStatus()->isDisabled());
3021

3122
$session = $store->openSession();
3223
try {
3324
$user = new User();
3425
$user->setName("user1");
26+
$user->setCount(3);
3527

3628
$session->store($user);
3729

@@ -44,6 +36,10 @@ public function testWaitForIndexesAfterSaveChangesCanExitWhenThrowOnTimeoutIsFal
4436
$session->close();
4537
}
4638

39+
$this->waitForIndexing($store);
40+
41+
$store->maintenance()->send(new StopIndexOperation($index->getIndexName()));
42+
4743
$session = $store->openSession();
4844
try {
4945
$user = new User();
@@ -60,9 +56,9 @@ public function testWaitForIndexesAfterSaveChangesCanExitWhenThrowOnTimeoutIsFal
6056
$session->saveChanges();
6157
throw new Exception('It should throw exception before reaching this code');
6258
} catch (Throwable $exception) {
63-
$this->assertInstanceOf(TimeoutException::class, $exception);
64-
$this->assertStringContainsString("System.TimeoutException", $exception->getMessage());
65-
$this->assertStringContainsString("could not verify that 1 indexes has caught up with the changes as of etag", $exception->getMessage());
59+
$this->assertInstanceOf(RavenTimeoutException::class, $exception);
60+
$this->assertStringContainsString("RavenTimeoutException", $exception->getMessage());
61+
$this->assertStringContainsString("could not verify that", $exception->getMessage());
6662
}
6763
} finally {
6864
$session->close();

0 commit comments

Comments
 (0)