Skip to content

Commit afc6a13

Browse files
committed
Improve stress testing
Split `CausalClusteringStressIT` into two separate tests - one for single instance and one for CC. Added testing of async API. Extracted all infra classes to top level.
1 parent 0e429bc commit afc6a13

20 files changed

+1510
-709
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2002-2017 "Neo Technology,"
3+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.driver.v1.stress;
20+
21+
import org.neo4j.driver.v1.AccessMode;
22+
import org.neo4j.driver.v1.Driver;
23+
import org.neo4j.driver.v1.Session;
24+
25+
public abstract class AbstractAsyncQuery<C extends AbstractContext> implements AsyncCommand<C>
26+
{
27+
protected final Driver driver;
28+
protected final boolean useBookmark;
29+
30+
public AbstractAsyncQuery( Driver driver, boolean useBookmark )
31+
{
32+
this.driver = driver;
33+
this.useBookmark = useBookmark;
34+
}
35+
36+
public Session newSession( AccessMode mode, C context )
37+
{
38+
if ( useBookmark )
39+
{
40+
return driver.session( mode, context.getBookmark() );
41+
}
42+
return driver.session( mode );
43+
}
44+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (c) 2002-2017 "Neo Technology,"
3+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.driver.v1.stress;
20+
21+
import org.neo4j.driver.v1.AccessMode;
22+
import org.neo4j.driver.v1.Driver;
23+
import org.neo4j.driver.v1.Session;
24+
import org.neo4j.driver.v1.Transaction;
25+
import org.neo4j.driver.v1.exceptions.TransientException;
26+
27+
public abstract class AbstractBlockingQuery<C extends AbstractContext> implements BlockingCommand<C>
28+
{
29+
protected final Driver driver;
30+
protected final boolean useBookmark;
31+
32+
public AbstractBlockingQuery( Driver driver, boolean useBookmark )
33+
{
34+
this.driver = driver;
35+
this.useBookmark = useBookmark;
36+
}
37+
38+
public Session newSession( AccessMode mode, C context )
39+
{
40+
if ( useBookmark )
41+
{
42+
return driver.session( mode, context.getBookmark() );
43+
}
44+
return driver.session( mode );
45+
}
46+
47+
public Transaction beginTransaction( Session session, C context )
48+
{
49+
if ( useBookmark )
50+
{
51+
while ( true )
52+
{
53+
try
54+
{
55+
return session.beginTransaction();
56+
}
57+
catch ( TransientException e )
58+
{
59+
context.bookmarkFailed();
60+
}
61+
}
62+
}
63+
64+
return session.beginTransaction();
65+
}
66+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright (c) 2002-2017 "Neo Technology,"
3+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.driver.v1.stress;
20+
21+
import java.util.concurrent.atomic.AtomicInteger;
22+
import java.util.concurrent.atomic.AtomicLong;
23+
24+
import org.neo4j.driver.v1.summary.ResultSummary;
25+
26+
public abstract class AbstractContext
27+
{
28+
private volatile boolean stopped;
29+
private volatile String bookmark;
30+
private final AtomicLong readNodesCount = new AtomicLong();
31+
private final AtomicLong createdNodesCount = new AtomicLong();
32+
private final AtomicInteger bookmarkFailures = new AtomicInteger();
33+
34+
public final boolean isStopped()
35+
{
36+
return stopped;
37+
}
38+
39+
public final void stop()
40+
{
41+
this.stopped = true;
42+
}
43+
44+
public final String getBookmark()
45+
{
46+
return bookmark;
47+
}
48+
49+
public final void setBookmark( String bookmark )
50+
{
51+
this.bookmark = bookmark;
52+
}
53+
54+
public final void nodeCreated()
55+
{
56+
createdNodesCount.incrementAndGet();
57+
}
58+
59+
public final long getCreatedNodesCount()
60+
{
61+
return createdNodesCount.get();
62+
}
63+
64+
public final void readCompleted( ResultSummary summary )
65+
{
66+
readNodesCount.incrementAndGet();
67+
processSummary( summary );
68+
}
69+
70+
public abstract void processSummary( ResultSummary summary );
71+
72+
public long getReadNodesCount()
73+
{
74+
return readNodesCount.get();
75+
}
76+
77+
public final void bookmarkFailed()
78+
{
79+
bookmarkFailures.incrementAndGet();
80+
}
81+
82+
public final int getBookmarkFailures()
83+
{
84+
return bookmarkFailures.get();
85+
}
86+
}

0 commit comments

Comments
 (0)