Skip to content

Commit

Permalink
Fixed version tests after forward merge
Browse files Browse the repository at this point in the history
  • Loading branch information
craigtaverner committed Jan 10, 2018
1 parent 0d5c7ec commit c3d6152
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
22 changes: 22 additions & 0 deletions Cypher.cyper
@@ -0,0 +1,22 @@
MATCH (n:User) WHERE exists(n.id) RETURN n.id ORDER BY n.id ASC

MATCH (n:User) WHERE exists(n.id) RETURN n.id ORDER BY n.id DESC

MATCH (n:User)--(other) WHERE exists(n.id) RETURN n.id ORDER BY n.id DESC

WITH point({latitude: 55.612149, longitude: 12.995090}) AS poi
MATCH (l:Location)<-[:AT]-(b:Business)-[:OF]->(c:Category)
WHERE c.name = "coffee"
AND distance(l.location, poi) < 10000
RETURN distance(l.location, poi) as distance, b.name as coffee_shop
ORDER BY distance DESC

CREATE INDEX ON :User(location);

CREATE (u:User) SET u.location = 'Malmö';

CREATE (u:User) SET u.location = 42;

CREATE (u:User) SET u.location = point({latitude: 55.612149, longitude: 12.995090});


Expand Up @@ -29,7 +29,6 @@
import java.util.Map;

import org.neo4j.graphdb.ExecutionPlanDescription;
import org.neo4j.graphdb.QueryStatistics;
import org.neo4j.graphdb.Result;
import org.neo4j.graphdb.Transaction;
import org.neo4j.helpers.collection.Iterators;
Expand Down Expand Up @@ -289,7 +288,7 @@ public void shouldReturnCorrectArrayType()
@Test
public void shouldContainCompletePlanFromFromLegacyVersions()
{
for ( String version : new String[]{"2.3", "3.1", "3.2", "3.3"} )
for ( String version : new String[]{"2.3", "3.1", "3.3", "3.4"} )
{
// Given
Result result = db.execute( String.format( "EXPLAIN CYPHER %s MATCH (n) RETURN n", version ) );
Expand All @@ -314,7 +313,7 @@ public void shouldContainCompleteProfileFromFromLegacyVersions()
tx.success();
}

for ( String version : new String[]{"2.3", "3.1", "3.2"} )
for ( String version : new String[]{"2.3", "3.1", "3.3", "3.4"} )
{
// When
Result result = db.execute( String.format( "PROFILE CYPHER %s MATCH (n) RETURN n", version ) );
Expand All @@ -325,13 +324,29 @@ public void shouldContainCompleteProfileFromFromLegacyVersions()
.getProfilerStatistics();

// Then
assertThat( stats.getDbHits(), equalTo( 2L ) );
assertThat( stats.getRows(), equalTo( 1L ) );
assertThat( "Mismatching db-hits for version " + version, stats.getDbHits(), equalTo( 2L ) );
assertThat( "Mismatching rows for version " + version, stats.getRows(), equalTo( 1L ) );

long expectedPageCacheHits = 2;
long expectedPageCacheMisses = 0;
double expectedPageCacheRatio = 1.0;

//These stats are not available in older versions
assertThat( stats.getPageCacheHits(), equalTo( 0L ) );
assertThat( stats.getPageCacheMisses(), equalTo( 0L ) );
assertThat( stats.getPageCacheHitRatio(), equalTo( 0.0 ) );
int verAsInt = Integer.parseInt( version.replace( ".", "" ) );
if ( verAsInt < 33 )
{
expectedPageCacheHits = 0;
expectedPageCacheMisses = 0;
expectedPageCacheRatio = 0.0;
}
else if ( verAsInt == 33 )
{
expectedPageCacheHits = 1;
}

assertThat( "Mismatching page cache hits for version " + version, stats.getPageCacheHits(), equalTo( expectedPageCacheHits ) );
assertThat( "Mismatching page cache misses for version " + version, stats.getPageCacheMisses(), equalTo( expectedPageCacheMisses ) );
assertThat( "Mismatching page cache hit ratio for version " + version, stats.getPageCacheHitRatio(), equalTo( expectedPageCacheRatio ) );
}
}

Expand Down
Expand Up @@ -32,7 +32,6 @@
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.GraphDatabase;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.summary.Plan;
import org.neo4j.graphdb.factory.GraphDatabaseBuilder;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.helpers.HostnamePort;
Expand Down

0 comments on commit c3d6152

Please sign in to comment.