Skip to content

Commit

Permalink
Changed method to mode=READ
Browse files Browse the repository at this point in the history
It is important that a read-only user can use the index for reading.
  • Loading branch information
pontusmelke committed Jun 15, 2017
1 parent 7ca2954 commit c84aa68
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 106 deletions.
Expand Up @@ -111,7 +111,7 @@ public void shouldNotNotifyWhenUsingTheRulePlannerWhenCypherVersionIsNot3_2() th
assertThat( arguments.get( "version" ), equalTo( version ) ); assertThat( arguments.get( "version" ), equalTo( version ) );
assertThat( arguments.get( "planner" ), equalTo( "RULE" ) ); assertThat( arguments.get( "planner" ), equalTo( "RULE" ) );
result.close(); result.close();
}); } );
} }


@Test @Test
Expand All @@ -122,7 +122,8 @@ public void shouldNotifyWhenUsingCreateUniqueWhenCypherVersionIsDefault() throws
InputPosition position = new InputPosition( 25, 1, 26 ); InputPosition position = new InputPosition( 25, 1, 26 );


// then // then
assertThat( result.getNotifications(), contains( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) ); assertThat( result.getNotifications(),
contains( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) );
Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments(); Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments();
assertThat( arguments.get( "version" ), equalTo( "CYPHER 3.1" ) ); assertThat( arguments.get( "version" ), equalTo( "CYPHER 3.1" ) );
result.close(); result.close();
Expand All @@ -136,7 +137,8 @@ public void shouldNotifyWhenUsingCreateUniqueWhenCypherVersionIs3_3() throws Exc
InputPosition position = new InputPosition( 36, 1, 37 ); InputPosition position = new InputPosition( 36, 1, 37 );


// then // then
assertThat( result.getNotifications(), contains( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) ); assertThat( result.getNotifications(),
contains( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) );
Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments(); Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments();
assertThat( arguments.get( "version" ), equalTo( "CYPHER 3.1" ) ); assertThat( arguments.get( "version" ), equalTo( "CYPHER 3.1" ) );
result.close(); result.close();
Expand All @@ -150,7 +152,8 @@ public void shouldNotifyWhenUsingCreateUniqueWhenCypherVersionIs3_2() throws Exc
InputPosition position = new InputPosition( 36, 1, 37 ); InputPosition position = new InputPosition( 36, 1, 37 );


// then // then
assertThat( result.getNotifications(), contains( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) ); assertThat( result.getNotifications(),
contains( CREATE_UNIQUE_UNAVAILABLE_FALLBACK.notification( position ) ) );
Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments(); Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments();
assertThat( arguments.get( "version" ), equalTo( "CYPHER 3.1" ) ); assertThat( arguments.get( "version" ), equalTo( "CYPHER 3.1" ) );
result.close(); result.close();
Expand All @@ -169,31 +172,31 @@ public void shouldNotNotifyWhenUsingCreateUniqueWhenCypherVersionIsNot3_2() thro
Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments(); Map<String,Object> arguments = result.getExecutionPlanDescription().getArguments();
assertThat( arguments.get( "version" ), equalTo( version ) ); assertThat( arguments.get( "version" ), equalTo( version ) );
result.close(); result.close();
}); } );
} }


@Test @Test
public void shouldWarnOnFutureAmbiguousRelTypeSeparator() throws Exception public void shouldWarnOnFutureAmbiguousRelTypeSeparator() throws Exception
{ {
for ( String pattern : Arrays.asList("[:A|:B|:C {foo:'bar'}]", "[:A|:B|:C*]", "[x:A|:B|:C]") ) for ( String pattern : Arrays.asList( "[:A|:B|:C {foo:'bar'}]", "[:A|:B|:C*]", "[x:A|:B|:C]" ) )
{ {
assertNotifications("CYPHER 3.3 explain MATCH (a)-" + pattern + "-(b) RETURN a,b", assertNotifications( "CYPHER 3.3 explain MATCH (a)-" + pattern + "-(b) RETURN a,b",
containsItem(notification( containsItem( notification(
"Neo.ClientNotification.Statement.FeatureDeprecationWarning", "Neo.ClientNotification.Statement.FeatureDeprecationWarning",
containsString( containsString(
"The semantics of using colon in the separation of alternative relationship " + "The semantics of using colon in the separation of alternative relationship " +
"types in conjunction with the use of variable binding, inlined property " + "types in conjunction with the use of variable binding, inlined property " +
"predicates, or variable length will change in a future version." "predicates, or variable length will change in a future version."
), ),
any(InputPosition.class), any( InputPosition.class ),
SeverityLevel.WARNING))); SeverityLevel.WARNING ) ) );
} }
} }


@Test @Test
public void shouldWarnOnBindingVariableLengthRelationship() throws Exception public void shouldWarnOnBindingVariableLengthRelationship() throws Exception
{ {
assertNotifications("CYPHER 3.3 explain MATCH ()-[rs*]-() RETURN rs", containsItem( notification( assertNotifications( "CYPHER 3.3 explain MATCH ()-[rs*]-() RETURN rs", containsItem( notification(
"Neo.ClientNotification.Statement.FeatureDeprecationWarning", "Neo.ClientNotification.Statement.FeatureDeprecationWarning",
containsString( "Binding relationships to a list in a variable length pattern is deprecated." ), containsString( "Binding relationships to a list in a variable length pattern is deprecated." ),
any( InputPosition.class ), any( InputPosition.class ),
Expand All @@ -203,7 +206,7 @@ public void shouldWarnOnBindingVariableLengthRelationship() throws Exception
@Test @Test
public void shouldWarnOnMissingLabel() throws Exception public void shouldWarnOnMissingLabel() throws Exception
{ {
assertNotifications("EXPLAIN MATCH (a:NO_SUCH_THING) RETURN a", containsItem( notification( assertNotifications( "EXPLAIN MATCH (a:NO_SUCH_THING) RETURN a", containsItem( notification(
"Neo.ClientNotification.Statement.UnknownLabelWarning", "Neo.ClientNotification.Statement.UnknownLabelWarning",
containsString( "the missing label name is: NO_SUCH_THING)" ), containsString( "the missing label name is: NO_SUCH_THING)" ),
any( InputPosition.class ), any( InputPosition.class ),
Expand All @@ -213,7 +216,7 @@ public void shouldWarnOnMissingLabel() throws Exception
@Test @Test
public void shouldWarnOnMissingRelationshipType() throws Exception public void shouldWarnOnMissingRelationshipType() throws Exception
{ {
assertNotifications("EXPLAIN MATCH ()-[a:NO_SUCH_THING]->() RETURN a", containsItem( notification( assertNotifications( "EXPLAIN MATCH ()-[a:NO_SUCH_THING]->() RETURN a", containsItem( notification(
"Neo.ClientNotification.Statement.UnknownRelationshipTypeWarning", "Neo.ClientNotification.Statement.UnknownRelationshipTypeWarning",
containsString( "the missing relationship type is: NO_SUCH_THING)" ), containsString( "the missing relationship type is: NO_SUCH_THING)" ),
any( InputPosition.class ), any( InputPosition.class ),
Expand All @@ -223,7 +226,7 @@ public void shouldWarnOnMissingRelationshipType() throws Exception
@Test @Test
public void shouldWarnOnMissingProperty() throws Exception public void shouldWarnOnMissingProperty() throws Exception
{ {
assertNotifications("EXPLAIN MATCH (a {NO_SUCH_THING: 1337}) RETURN a", containsItem( notification( assertNotifications( "EXPLAIN MATCH (a {NO_SUCH_THING: 1337}) RETURN a", containsItem( notification(
"Neo.ClientNotification.Statement.UnknownPropertyKeyWarning", "Neo.ClientNotification.Statement.UnknownPropertyKeyWarning",
containsString( "the missing property name is: NO_SUCH_THING)" ), containsString( "the missing property name is: NO_SUCH_THING)" ),
any( InputPosition.class ), any( InputPosition.class ),
Expand All @@ -233,136 +236,149 @@ public void shouldWarnOnMissingProperty() throws Exception
@Test @Test
public void shouldWarnThatStartIsDeprecatedForAllNodeScan() public void shouldWarnThatStartIsDeprecatedForAllNodeScan()
{ {
assertNotifications("EXPLAIN START n=node(*) RETURN n", assertNotifications( "EXPLAIN START n=node(*) RETURN n",
containsItem( notification( containsItem( notification(
"Neo.ClientNotification.Statement.FeatureDeprecationWarning", "Neo.ClientNotification.Statement.FeatureDeprecationWarning",
containsString( "START has been deprecated and will be removed in a future version. (START is deprecated, use: `MATCH (n)`" ), containsString(
any( InputPosition.class ), "START has been deprecated and will be removed in a future version. (START is " +
SeverityLevel.WARNING ) ) ); "deprecated, use: `MATCH (n)`" ),
any( InputPosition.class ),
SeverityLevel.WARNING ) ) );
} }


@Test @Test
public void shouldWarnThatStartIsDeprecatedForNodeById() public void shouldWarnThatStartIsDeprecatedForNodeById()
{ {
assertNotifications("EXPLAIN START n=node(1337) RETURN n", assertNotifications( "EXPLAIN START n=node(1337) RETURN n",
containsItem( notification( containsItem( notification(
"Neo.ClientNotification.Statement.FeatureDeprecationWarning", "Neo.ClientNotification.Statement.FeatureDeprecationWarning",
containsString( "START has been deprecated and will be removed in a future version. (START is deprecated, use: `MATCH (n) WHERE id(n) = 1337`" ), containsString(
"START has been deprecated and will be removed in a future version. (START is " +
"deprecated, use: `MATCH (n) WHERE id(n) = 1337`" ),
any( InputPosition.class ), any( InputPosition.class ),
SeverityLevel.WARNING ) ) ); SeverityLevel.WARNING ) ) );
} }


@Test @Test
public void shouldWarnThatStartIsDeprecatedForNodeByIds() public void shouldWarnThatStartIsDeprecatedForNodeByIds()
{ {
assertNotifications("EXPLAIN START n=node(42,1337) RETURN n", assertNotifications( "EXPLAIN START n=node(42,1337) RETURN n",
containsItem( notification( containsItem( notification(
"Neo.ClientNotification.Statement.FeatureDeprecationWarning", "Neo.ClientNotification.Statement.FeatureDeprecationWarning",
containsString( "START has been deprecated and will be removed in a future version. (START is deprecated, use: `MATCH (n) WHERE id(n) IN [42, 1337]`" ), containsString(
"START has been deprecated and will be removed in a future version. (START is " +
"deprecated, use: `MATCH (n) WHERE id(n) IN [42, 1337]`" ),
any( InputPosition.class ), any( InputPosition.class ),
SeverityLevel.WARNING ) ) ); SeverityLevel.WARNING ) ) );
} }


@Test @Test
public void shouldWarnThatStartIsDeprecatedForNodeIndexSeek() public void shouldWarnThatStartIsDeprecatedForNodeIndexSeek()
{ {
try (Transaction ignore = db().beginTx()) try ( Transaction ignore = db().beginTx() )
{ {
db().index().forNodes( "index" ); db().index().forNodes( "index" );
} }
assertNotifications("EXPLAIN START n=node:index(key = 'value') RETURN n", assertNotifications( "EXPLAIN START n=node:index(key = 'value') RETURN n",
containsItem( notification( containsItem( notification(
"Neo.ClientNotification.Statement.FeatureDeprecationWarning", "Neo.ClientNotification.Statement.FeatureDeprecationWarning",
containsString( "START has been deprecated and will be removed in a future version. " + containsString( "START has been deprecated and will be removed in a future version. " +
"(START is deprecated, use: " + "(START is deprecated, use: " +
"`CALL db.nodeLegacyIndexSeek('index', 'key', 'value') YIELD node AS n` instead." ), "`CALL db.nodeLegacyIndexSeek('index', 'key', 'value') YIELD node AS n` " +
"instead." ),
any( InputPosition.class ), any( InputPosition.class ),
SeverityLevel.WARNING ) ) ); SeverityLevel.WARNING ) ) );
} }


@Test @Test
public void shouldWarnThatStartIsDeprecatedForNodeIndexSearch() public void shouldWarnThatStartIsDeprecatedForNodeIndexSearch()
{ {
try (Transaction ignore = db().beginTx()) try ( Transaction ignore = db().beginTx() )
{ {
db().index().forNodes( "index" ); db().index().forNodes( "index" );
} }
assertNotifications("EXPLAIN START n=node:index('key:value*') RETURN n", assertNotifications( "EXPLAIN START n=node:index('key:value*') RETURN n",
containsItem( notification( containsItem( notification(
"Neo.ClientNotification.Statement.FeatureDeprecationWarning", "Neo.ClientNotification.Statement.FeatureDeprecationWarning",
containsString( "START has been deprecated and will be removed in a future version. " + containsString( "START has been deprecated and will be removed in a future version. " +
"(START is deprecated, use: " + "(START is deprecated, use: " +
"`CALL db.nodeLegacyIndexSearch('index', 'key:value*') YIELD node AS n` instead." ), "`CALL db.nodeLegacyIndexSearch('index', 'key:value*') YIELD node AS n` " +
"instead." ),
any( InputPosition.class ), any( InputPosition.class ),
SeverityLevel.WARNING ) ) ); SeverityLevel.WARNING ) ) );
} }





@Test @Test
public void shouldWarnThatStartIsDeprecatedForAllRelScan() public void shouldWarnThatStartIsDeprecatedForAllRelScan()
{ {
assertNotifications("EXPLAIN START r=relationship(*) RETURN r", assertNotifications( "EXPLAIN START r=relationship(*) RETURN r",
containsItem( notification( containsItem( notification(
"Neo.ClientNotification.Statement.FeatureDeprecationWarning", "Neo.ClientNotification.Statement.FeatureDeprecationWarning",
containsString( "START has been deprecated and will be removed in a future version. (START is deprecated, use: `MATCH ()-[r]->()`" ), containsString(
"START has been deprecated and will be removed in a future version. (START is " +
"deprecated, use: `MATCH ()-[r]->()`" ),
any( InputPosition.class ), any( InputPosition.class ),
SeverityLevel.WARNING ) ) ); SeverityLevel.WARNING ) ) );
} }


@Test @Test
public void shouldWarnThatStartIsDeprecatedForRelById() public void shouldWarnThatStartIsDeprecatedForRelById()
{ {
assertNotifications("EXPLAIN START r=relationship(1337) RETURN r", assertNotifications( "EXPLAIN START r=relationship(1337) RETURN r",
containsItem( notification( containsItem( notification(
"Neo.ClientNotification.Statement.FeatureDeprecationWarning", "Neo.ClientNotification.Statement.FeatureDeprecationWarning",
containsString( "START has been deprecated and will be removed in a future version. (START is deprecated, use: `MATCH ()-[r]->() WHERE id(r) = 1337`" ), containsString(
"START has been deprecated and will be removed in a future version. (START is " +
"deprecated, use: `MATCH ()-[r]->() WHERE id(r) = 1337`" ),
any( InputPosition.class ), any( InputPosition.class ),
SeverityLevel.WARNING ) ) ); SeverityLevel.WARNING ) ) );
} }


@Test @Test
public void shouldWarnThatStartIsDeprecatedForRelByIds() public void shouldWarnThatStartIsDeprecatedForRelByIds()
{ {
assertNotifications("EXPLAIN START r=relationship(42,1337) RETURN r", assertNotifications( "EXPLAIN START r=relationship(42,1337) RETURN r",
containsItem( notification( containsItem( notification(
"Neo.ClientNotification.Statement.FeatureDeprecationWarning", "Neo.ClientNotification.Statement.FeatureDeprecationWarning",
containsString( "START has been deprecated and will be removed in a future version. (START is deprecated, use: `MATCH ()-[r]->() WHERE id(r) IN [42, 1337]`" ), containsString(
"START has been deprecated and will be removed in a future version. (START is " +
"deprecated, use: `MATCH ()-[r]->() WHERE id(r) IN [42, 1337]`" ),
any( InputPosition.class ), any( InputPosition.class ),
SeverityLevel.WARNING ) ) ); SeverityLevel.WARNING ) ) );
} }


@Test @Test
public void shouldWarnThatStartIsDeprecatedForRelIndexSeek() public void shouldWarnThatStartIsDeprecatedForRelIndexSeek()
{ {
try (Transaction ignore = db().beginTx()) try ( Transaction ignore = db().beginTx() )
{ {
db().index().forRelationships( "index" ); db().index().forRelationships( "index" );
} }
assertNotifications("EXPLAIN START r=relationship:index(key = 'value') RETURN r", assertNotifications( "EXPLAIN START r=relationship:index(key = 'value') RETURN r",
containsItem( notification( containsItem( notification(
"Neo.ClientNotification.Statement.FeatureDeprecationWarning", "Neo.ClientNotification.Statement.FeatureDeprecationWarning",
containsString( "START has been deprecated and will be removed in a future version. " + containsString( "START has been deprecated and will be removed in a future version. " +
"(START is deprecated, use: " + "(START is deprecated, use: " +
"`CALL db.relationshipLegacyIndexSeek('index', 'key', 'value') YIELD relationship AS r` instead." ), "`CALL db.relationshipLegacyIndexSeek('index', 'key', 'value') YIELD " +
"relationship AS r` instead." ),
any( InputPosition.class ), any( InputPosition.class ),
SeverityLevel.WARNING ) ) ); SeverityLevel.WARNING ) ) );
} }


@Test @Test
public void shouldWarnThatStartIsDeprecatedForRelIndexSearch() public void shouldWarnThatStartIsDeprecatedForRelIndexSearch()
{ {
try (Transaction ignore = db().beginTx()) try ( Transaction ignore = db().beginTx() )
{ {
db().index().forRelationships( "index" ); db().index().forRelationships( "index" );
} }
assertNotifications("EXPLAIN START r=relationship:index('key:value*') RETURN r", assertNotifications( "EXPLAIN START r=relationship:index('key:value*') RETURN r",
containsItem( notification( containsItem( notification(
"Neo.ClientNotification.Statement.FeatureDeprecationWarning", "Neo.ClientNotification.Statement.FeatureDeprecationWarning",
containsString( "START has been deprecated and will be removed in a future version. " + containsString( "START has been deprecated and will be removed in a future version. " +
"(START is deprecated, use: " + "(START is deprecated, use: " +
"`CALL db.relationshipLegacyIndexSearch('index', 'key:value*') YIELD relationship AS r` instead." ), "`CALL db.relationshipLegacyIndexSearch('index', 'key:value*') YIELD " +
"relationship AS r` instead." ),
any( InputPosition.class ), any( InputPosition.class ),
SeverityLevel.WARNING ) ) ); SeverityLevel.WARNING ) ) );
} }
Expand All @@ -387,9 +403,9 @@ private Matcher<Notification> notification(
protected boolean matchesSafely( Notification item ) protected boolean matchesSafely( Notification item )
{ {
return code.equals( item.getCode() ) && return code.equals( item.getCode() ) &&
description.matches( item.getDescription() ) && description.matches( item.getDescription() ) &&
position.matches( item.getPosition() ) && position.matches( item.getPosition() ) &&
severity.equals( item.getSeverity() ); severity.equals( item.getSeverity() );
} }


@Override @Override
Expand Down

0 comments on commit c84aa68

Please sign in to comment.