Skip to content

Commit 495a5c3

Browse files
committed
moved bigger tests to performance folder
1 parent 8806403 commit 495a5c3

File tree

6 files changed

+116
-90
lines changed

6 files changed

+116
-90
lines changed

.github/workflows/full-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
tests:
1111
runs-on: ubuntu-latest
12-
name: "Create Test Coverage Report"
12+
name: "Running full tests"
1313
env:
1414
NEO4J_CONNECTIONS: ${{ secrets.NEO4J_CONNECTIONS }}
1515

docker-compose.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ services:
4949
neo4j:
5050
networks:
5151
- neo4j
52-
image: neo4j:3.5-enterprise
52+
image: neo4j:4.3-enterprise
5353
healthcheck:
5454
test: "wget http://localhost:7474 || exit 1"
5555
interval: 30s
@@ -66,7 +66,7 @@ services:
6666
volumes:
6767
- ./tests/resources:/import
6868
core1:
69-
image: neo4j:3.5-enterprise
69+
image: neo4j:4.3-enterprise
7070
healthcheck:
7171
test: "wget http://localhost:7474 || exit 1"
7272
interval: 30s
@@ -94,7 +94,7 @@ services:
9494
NEO4J_dbms_connector_bolt_advertised__address: core1:7687
9595

9696
core2:
97-
image: neo4j:3.5-enterprise
97+
image: neo4j:4.3-enterprise
9898
healthcheck:
9999
test: "wget http://localhost:7474 || exit 1"
100100
interval: 30s
@@ -119,7 +119,7 @@ services:
119119
- ./tests/resources:/import
120120

121121
core3:
122-
image: neo4j:3.5-enterprise
122+
image: neo4j:4.3-enterprise
123123
healthcheck:
124124
test: "wget http://localhost:7474 || exit 1"
125125
interval: 30s
@@ -144,7 +144,7 @@ services:
144144
- ./tests/resources:/import
145145

146146
readreplica1:
147-
image: neo4j:3.5-enterprise
147+
image: neo4j:4.3-enterprise
148148
healthcheck:
149149
test: "wget http://localhost:7474 || exit 1"
150150
interval: 30s

tests/Integration/ClientIntegrationTest.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,30 +75,6 @@ public function testAvailabilityFullImplementation(string $alias): void
7575
self::assertEquals(1, $results);
7676
}
7777

78-
/**
79-
* @dataProvider connectionAliases
80-
*/
81-
public function testBigRandomData(string $alias): void
82-
{
83-
$tsx = $this->client->getDriver($alias)
84-
->createSession()
85-
->beginTransaction();
86-
87-
$params = [
88-
'id' => 'xyz',
89-
];
90-
91-
for ($i = 0; $i < 100000; ++$i) {
92-
$params[base64_encode(random_bytes(32))] = base64_encode(random_bytes(128));
93-
}
94-
95-
$tsx->run('MATCH (a :label {id:$id}) RETURN a', $params);
96-
97-
$tsx->rollback();
98-
99-
self::assertTrue(true);
100-
}
101-
10278
/**
10379
* @dataProvider connectionAliases
10480
*/

tests/Integration/ConsistencyTest.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,35 +67,4 @@ public function testConsistencyTransaction(string $alias): void
6767
self::assertEquals(['name' => 'bbb'], $results->get(1)->get('n'));
6868
self::assertEquals(['name' => 'ccc'], $results->last()->get('n'));
6969
}
70-
71-
public function testConsistencyMultiple(): void
72-
{
73-
$aliases = $this->connectionAliases();
74-
$tsxs = [];
75-
for ($i = 0; $i < 200; ++$i) {
76-
$alias = $aliases[$i % count($aliases)][0];
77-
if ($i % 2 === 0) {
78-
$tsx = $this->client->beginTransaction(null, $alias);
79-
$x = $tsx->run('RETURN 1 AS x')->first()->get('x');
80-
$tsxs[] = $tsx;
81-
} else {
82-
$x = $this->client->run('RETURN 1 AS x', [], $alias)->first()->get('x');
83-
}
84-
85-
self::assertEquals(1, $x);
86-
if ($i % 20 === 19) {
87-
self::assertEquals(1, $x);
88-
for ($j = 0; $j < 9; ++$j) {
89-
$tsx = array_pop($tsxs);
90-
$x = $tsx->run('RETURN 1 AS x')->first()->get('x');
91-
92-
self::assertEquals(1, $x);
93-
94-
if ($j % 2 === 0) {
95-
$tsx->commit();
96-
}
97-
}
98-
}
99-
}
100-
}
10170
}

tests/Integration/TransactionIntegrationTest.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,6 @@ protected function formatter(): FormatterInterface
3030
return new BasicFormatter();
3131
}
3232

33-
/**
34-
* @dataProvider connectionAliases
35-
*/
36-
public function testMultipleTransactions(string $alias): void
37-
{
38-
$this->client->run('MATCH (x) DETACH DELETE (x)', [], $alias);
39-
40-
for ($i = 0; $i < 2; ++$i) {
41-
$tsxs = [];
42-
for ($j = 0; $j < 100; ++$j) {
43-
$tsxs[] = $this->client->beginTransaction(null, $alias);
44-
}
45-
46-
foreach ($tsxs as $tsx) {
47-
$tsx->run('CREATE (:X {y: "z"})');
48-
}
49-
50-
self::assertEquals(0 + $i * 100, $this->client->run('MATCH (x) RETURN count(x) AS x', [], $alias)->first()->get('x'));
51-
52-
foreach ($tsxs as $j => $tsx) {
53-
$tsx->commit();
54-
55-
self::assertEquals($j + 1 + $i * 100, $this->client->run('MATCH (x) RETURN count(x) AS x', [], $alias)->first()->get('x'));
56-
}
57-
58-
self::assertEquals(($i + 1) * 100, $this->client->run('MATCH (x) RETURN count(x) AS x', [], $alias)->first()->get('x'));
59-
}
60-
}
61-
6233
/**
6334
* @dataProvider connectionAliases
6435
*/
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
3+
namespace Laudis\Neo4j\Tests\Performance;
4+
5+
use Laudis\Neo4j\Contracts\FormatterInterface;
6+
use Laudis\Neo4j\Formatter\BasicFormatter;
7+
use Laudis\Neo4j\Tests\Integration\EnvironmentAwareIntegrationTest;
8+
use function array_pop;
9+
use function base64_encode;
10+
use function count;
11+
use function random_bytes;
12+
13+
/**
14+
* @psalm-import-type BasicResults from \Laudis\Neo4j\Formatter\BasicFormatter
15+
*
16+
* @extends EnvironmentAwareIntegrationTest<BasicResults>
17+
*/
18+
final class PerfomanceTest extends EnvironmentAwareIntegrationTest
19+
{
20+
21+
protected function formatter(): FormatterInterface
22+
{
23+
/** @psalm-suppress InvalidReturnStatement */
24+
return BasicFormatter::create();
25+
}
26+
27+
/**
28+
* @dataProvider connectionAliases
29+
*/
30+
public function testBigRandomData(string $alias): void
31+
{
32+
$tsx = $this->client->getDriver($alias)
33+
->createSession()
34+
->beginTransaction();
35+
36+
$params = [
37+
'id' => 'xyz',
38+
];
39+
40+
for ($i = 0; $i < 100000; ++$i) {
41+
$params[base64_encode(random_bytes(32))] = base64_encode(random_bytes(128));
42+
}
43+
44+
$tsx->run('MATCH (a :label {id:$id}) RETURN a', $params);
45+
46+
$tsx->rollback();
47+
48+
self::assertTrue(true);
49+
}
50+
51+
public function testMultipleTransactions(): void
52+
{
53+
$aliases = $this->connectionAliases();
54+
$tsxs = [];
55+
for ($i = 0; $i < 1000; ++$i) {
56+
$alias = $aliases[$i % count($aliases)][0];
57+
if ($i % 2 === 0) {
58+
$tsx = $this->client->beginTransaction(null, $alias);
59+
$x = $tsx->run('RETURN 1 AS x')->first()->get('x');
60+
$tsxs[] = $tsx;
61+
} else {
62+
$x = $this->client->run('RETURN 1 AS x', [], $alias)->first()->get('x');
63+
}
64+
65+
self::assertEquals(1, $x);
66+
if ($i % 200 === 49) {
67+
self::assertEquals(1, $x);
68+
for ($j = 0; $j < 19; ++$j) {
69+
$tsx = array_pop($tsxs);
70+
$x = $tsx->run('RETURN 1 AS x')->first()->get('x');
71+
72+
self::assertEquals(1, $x);
73+
74+
if ($j % 2 === 0) {
75+
$tsx->commit();
76+
}
77+
}
78+
}
79+
}
80+
}
81+
82+
/**
83+
* @dataProvider connectionAliases
84+
*/
85+
public function testMultipleTransactionsCorrectness(string $alias): void
86+
{
87+
$this->client->run('MATCH (x) DETACH DELETE (x)', [], $alias);
88+
89+
for ($i = 0; $i < 2; ++$i) {
90+
$tsxs = [];
91+
for ($j = 0; $j < 100; ++$j) {
92+
$tsxs[] = $this->client->beginTransaction(null, $alias);
93+
}
94+
95+
foreach ($tsxs as $tsx) {
96+
$tsx->run('CREATE (:X {y: "z"})');
97+
}
98+
99+
self::assertEquals(0 + $i * 100, $this->client->run('MATCH (x) RETURN count(x) AS x', [], $alias)->first()->get('x'));
100+
101+
foreach ($tsxs as $j => $tsx) {
102+
$tsx->commit();
103+
104+
self::assertEquals($j + 1 + $i * 100, $this->client->run('MATCH (x) RETURN count(x) AS x', [], $alias)->first()->get('x'));
105+
}
106+
107+
self::assertEquals(($i + 1) * 100, $this->client->run('MATCH (x) RETURN count(x) AS x', [], $alias)->first()->get('x'));
108+
}
109+
}
110+
}

0 commit comments

Comments
 (0)