Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
1d62ec1
wip test_tx_run of testkit
p123-stack May 16, 2025
4e6d009
fixed testkit tests for test_tx_func_run class
p123-stack May 19, 2025
dd41be5
Fixed test_tx_func_run
p123-stack May 21, 2025
a253f56
Removed BoltFactoryTest
p123-stack May 21, 2025
1b35a06
fixed testkit tests
p123-stack May 22, 2025
5f3809f
fixed the test for stub -basic-query in testkit
p123-stack Aug 4, 2025
4e3dd50
fixed testkit test for test_Session_run
p123-stack Aug 6, 2025
7b8e061
fixed bookmarks tests
p123-stack Aug 13, 2025
412662a
work in progress
p123-stack Aug 18, 2025
28ddfe8
work in progress
p123-stack Aug 18, 2025
39484f8
fixed all thr basic-query tests and did a proper cleanup
p123-stack Aug 29, 2025
a7c29ec
Merge branch 'feat/tesktkit-basic-query' into test_tx_run
p123-stack Aug 29, 2025
80d8e2c
temp commit
p123-stack Sep 1, 2025
5fed5eb
fixed all the tx_run and did a proper cleanup
p123-stack Sep 8, 2025
238c52c
resolved merge conflicts
p123-stack Sep 8, 2025
344d28a
resolved the merge conflicts
p123-stack Sep 8, 2025
7dc5243
temp commit
p123-stack Sep 8, 2025
d784312
temp commit
p123-stack Sep 9, 2025
0635271
fixed the test_txrun
p123-stack Sep 9, 2025
23af4aa
remove the cc from the dockerfile
p123-stack Sep 9, 2025
c8dbb60
solved testkit test
p123-stack Sep 10, 2025
051a63f
cleanup code
p123-stack Sep 10, 2025
da41e20
fixed the testkit.sh file
p123-stack Sep 10, 2025
151081c
setup proper testkit configuration for docker
p123-stack Sep 11, 2025
1b69237
Merge branch 'test_tx_run' into test_tx_func_run
p123-stack Sep 11, 2025
1f5e57e
fixed the test_tx_func_run and did cleanup
p123-stack Sep 12, 2025
b8b1cf0
Merge branch 'test_tx_func_run' into feat/tesktkit-session-run
p123-stack Sep 12, 2025
5c86cb8
fixed test_session_run
p123-stack Sep 15, 2025
dad8386
fixed tests
p123-stack Sep 17, 2025
7029117
fixed tests
p123-stack Sep 17, 2025
d91dd45
fixed tests
p123-stack Sep 17, 2025
7604a7c
fixed tests
p123-stack Sep 17, 2025
d7213c2
fixed stub/session_run_tests
p123-stack Sep 17, 2025
85ced5a
removed the commented statements
p123-stack Sep 17, 2025
87af2b4
fixed bookmakrs test
p123-stack Sep 18, 2025
bc87cda
fixed bookmarks tests
p123-stack Sep 18, 2025
317b314
Merge branch 'feat/tesktkit-session-run' into feat/tesktkit-bookmarks
p123-stack Sep 18, 2025
f9bfe90
fixed bookmarks test
p123-stack Sep 18, 2025
a1ca858
added all the other fixed testkit tests
p123-stack Sep 18, 2025
b5b55e6
fixed tests
p123-stack Sep 18, 2025
96b41a6
fixed integration tests
p123-stack Sep 29, 2025
5dffed9
fixed integration tests
p123-stack Oct 7, 2025
630f12c
temp commit
p123-stack Oct 13, 2025
731fc0c
Restore and fix tests according to architectural changes
p123-stack Oct 13, 2025
4bb4176
temp commit
p123-stack Oct 13, 2025
677939c
Replace dynamic property access (->{'prop'}) with direct access (->pr…
p123-stack Oct 14, 2025
8168247
Fix UndefinedPropertyFetch and MixedAssignment psalm errors
p123-stack Oct 14, 2025
065fbdd
temp commit
p123-stack Oct 16, 2025
8a564ee
Restore getServerVersion() method to ConnectionInterface and BoltConn…
p123-stack Oct 16, 2025
bf9de59
resolved merge conflicts
p123-stack Oct 16, 2025
4d3e4d3
Fix transaction state management and bookmark chaining and fixed boo…
p123-stack Oct 20, 2025
0932f8f
Fix transaction state management and bookmark chaining and fixed boo…
p123-stack Oct 20, 2025
24e9b24
resolved conflicts
p123-stack Oct 20, 2025
2eb998c
Merge branch 'feat/tesktkit-session-run' into feat/tesktkit-bookmarks
p123-stack Oct 20, 2025
9a93741
only re-enabled bookmark tests
p123-stack Oct 20, 2025
2c44919
temp commit
p123-stack Oct 22, 2025
5a20659
Cleanup tests and fix broken regressions
transistive Oct 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@
"scripts": {
"fix-cs": "./vendor/bin/php-cs-fixer fix",
"check-cs": "./vendor/bin/php-cs-fixer fix --dry-run",
"psalm": "./vendor/bin/psalm"
"psalm": "./vendor/bin/psalm --show-info"
}
}
17 changes: 10 additions & 7 deletions src/Bolt/BoltConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function getProtocol(): ConnectionProtocol
/**
* @psalm-mutation-free
*/
public function getAccessMode(): AccessMode
public function getAccessMode(): ?AccessMode
{
return $this->config->getAccessMode();
}
Expand Down Expand Up @@ -217,7 +217,7 @@ public function begin(?string $database, ?float $timeout, BookmarkHolder $holder
{
$this->consumeResults();

$extra = $this->buildRunExtra($database, $timeout, $holder, AccessMode::WRITE(), $txMetaData);
$extra = $this->buildRunExtra($database, $timeout, $holder, null, $txMetaData);
$message = $this->messageFactory->createBeginMessage($extra);
$response = $message->send()->getResponse();
$this->assertNoFailure($response);
Expand Down Expand Up @@ -249,7 +249,7 @@ public function run(
array $parameters,
?string $database,
?float $timeout,
BookmarkHolder $holder,
?BookmarkHolder $holder,
?AccessMode $mode,
?iterable $tsxMetadata,
): array {
Expand Down Expand Up @@ -295,7 +295,6 @@ public function protocol(): V4_4|V5|V5_1|V5_2|V5_3|V5_4
public function pull(?int $qid, ?int $fetchSize): array
{
$extra = $this->buildResultExtra($fetchSize, $qid);
$this->logger?->log(LogLevel::DEBUG, 'PULL', $extra);

$tbr = [];
$message = $this->messageFactory->createPullMessage($extra);
Expand Down Expand Up @@ -331,7 +330,7 @@ public function close(): void
}
}

private function buildRunExtra(?string $database, ?float $timeout, BookmarkHolder $holder, ?AccessMode $mode, ?iterable $metadata): array
private function buildRunExtra(?string $database, ?float $timeout, ?BookmarkHolder $holder, ?AccessMode $mode, ?iterable $metadata): array
{
$extra = [];
if ($database !== null) {
Expand All @@ -341,7 +340,7 @@ private function buildRunExtra(?string $database, ?float $timeout, BookmarkHolde
$extra['tx_timeout'] = (int) ($timeout * 1000);
}

if (!$holder->getBookmark()->isEmpty()) {
if ($holder && !$holder->getBookmark()->isEmpty()) {
$extra['bookmarks'] = $holder->getBookmark()->values();
}

Expand All @@ -366,7 +365,7 @@ private function buildResultExtra(?int $fetchSize, ?int $qid): array
$extra['n'] = $fetchSize;
}

if ($qid !== null) {
if ($qid !== null && $qid >= 0) {
$extra['qid'] = $qid;
}

Expand Down Expand Up @@ -420,6 +419,10 @@ public function assertNoFailure(Response $response): void
*/
public function discardUnconsumedResults(): void
{
if (!in_array($this->protocol()->serverState, [ServerState::STREAMING, ServerState::TX_STREAMING], true)) {
return;
}

$this->logger?->log(LogLevel::DEBUG, 'Discarding unconsumed results');

$this->subscribedResults = array_values(array_filter(
Expand Down
5 changes: 3 additions & 2 deletions src/Bolt/BoltUnmanagedTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function __construct(
private readonly TransactionConfiguration $tsxConfig,
private readonly BookmarkHolder $bookmarkHolder,
private readonly BoltMessageFactory $messageFactory,
private readonly bool $isInstantTransaction,
) {
}

Expand Down Expand Up @@ -147,8 +148,8 @@ public function runStatement(Statement $statement): SummarizedResult
$parameters->toArray(),
$this->database,
$this->tsxConfig->getTimeout(),
$this->bookmarkHolder,
$this->config->getAccessMode(),
$this->isInstantTransaction ? $this->bookmarkHolder : null, // let the begin transaction pass the bookmarks if it is a managed transaction
$this->isInstantTransaction ? $this->config->getAccessMode() : null, // let the begin transaction decide if it is a managed transaction
$this->tsxConfig->getMetaData()
);
} catch (Throwable $e) {
Expand Down
2 changes: 2 additions & 0 deletions src/Bolt/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ private function beginInstantTransaction(
$tsxConfig,
$this->bookmarkHolder,
new BoltMessageFactory($connection, $this->getLogger()),
true,
);
}

Expand Down Expand Up @@ -246,6 +247,7 @@ private function startTransaction(TransactionConfiguration $config, SessionConfi
$config,
$this->bookmarkHolder,
new BoltMessageFactory($connection, $this->getLogger()),
false
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ private function startSession(?string $alias, SessionConfiguration $configuratio

public function writeTransaction(callable $tsxHandler, ?string $alias = null, ?TransactionConfiguration $config = null)
{
if ($this->defaultSessionConfiguration->getAccessMode() === AccessMode::WRITE()) {
$accessMode = $this->defaultSessionConfiguration->getAccessMode();
if ($accessMode === null || $accessMode === AccessMode::WRITE()) {
$session = $this->getSession($alias);
} else {
$sessionConfig = $this->defaultSessionConfiguration->withAccessMode(AccessMode::WRITE());
Expand Down
4 changes: 2 additions & 2 deletions src/Common/ConnectionConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
private string $serverAgent,
private readonly UriInterface $serverAddress,
private readonly ConnectionProtocol $protocol,
private readonly AccessMode $accessMode,
private readonly ?AccessMode $accessMode,
private readonly ?DatabaseInfo $databaseInfo,
private readonly string $encryptionLevel,
) {
Expand All @@ -54,7 +54,7 @@ public function getProtocol(): ConnectionProtocol
return $this->protocol;
}

public function getAccessMode(): AccessMode
public function getAccessMode(): ?AccessMode
{
return $this->accessMode;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getProtocol(): ConnectionProtocol;
*
* @psalm-mutation-free
*/
public function getAccessMode(): AccessMode;
public function getAccessMode(): ?AccessMode;

/**
* Returns the information about the database the connection reaches.
Expand Down
4 changes: 2 additions & 2 deletions src/Databags/SessionConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ public function getFetchSize(): int
*
* @psalm-suppress ImpureMethodCall
*/
public function getAccessMode(): AccessMode
public function getAccessMode(): ?AccessMode
{
return $this->accessMode ?? AccessMode::WRITE();
return $this->accessMode;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Neo4j/Neo4jConnectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ public function getLogger(): ?Neo4jLogger
/**
* @throws Exception
*/
private function getNextServer(RoutingTable $table, AccessMode $mode): Uri
private function getNextServer(RoutingTable $table, ?AccessMode $mode): Uri
{
if (AccessMode::WRITE() === $mode) {
if ($mode === null || AccessMode::WRITE() === $mode) {
$servers = $table->getWithRole(RoutingRoles::LEADER());
} else {
$servers = $table->getWithRole(RoutingRoles::FOLLOWER());
Expand Down
13 changes: 10 additions & 3 deletions testkit-backend/src/Handlers/NewSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ public function handle($request): SessionResponse
{
$driver = $this->repository->getDriver($request->driverId);

$config = SessionConfiguration::default()
->withAccessMode($request->accessMode === 'r' ? AccessMode::READ() : AccessMode::WRITE());
$config = SessionConfiguration::default();

if ($request->accessMode === 'r') {
$config = $config->withAccessMode(AccessMode::READ());
} elseif ($request->accessMode === 'w') {
$config = $config->withAccessMode(AccessMode::WRITE());
}

if ($request->bookmarks !== null) {
$config = $config->withBookmarks([new Bookmark($request->bookmarks)]);
Expand All @@ -52,7 +57,9 @@ public function handle($request): SessionResponse
$config = $config->withDatabase($request->database);
}

$config = $config->withFetchSize($request->fetchSize ?? 1);
if ($request->fetchSize !== null) {
$config = $config->withFetchSize($request->fetchSize);
}

$session = $driver->createSession($config);
$id = Uuid::v4();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Laudis\Neo4j\TestkitBackend\Requests;

use Laudis\Neo4j\Databags\TransactionConfiguration;
use Symfony\Component\Uid\Uuid;

final class SessionBeginTransactionRequest
Expand Down Expand Up @@ -49,8 +48,8 @@ public function getTxMeta(): iterable
return $this->txMeta ?? [];
}

public function getTimeout(): int
public function getTimeout(): ?int
{
return (int) ($this->timeout ?? TransactionConfiguration::DEFAULT_TIMEOUT);
return $this->timeout;
}
}
Loading
Loading