Skip to content

Commit

Permalink
Propagates correct error status from test.loop procedure
Browse files Browse the repository at this point in the history
Reduces chance of race in flaky test
  • Loading branch information
alexaverbuch committed Aug 23, 2017
1 parent c4f26ef commit ae4bd5c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Expand Up @@ -699,7 +699,9 @@ public void shouldTerminateLongRunningProcedureThatChecksTheGuardRegularlyIfKill

String loopQuery = "CALL test.loop";

new Thread( () -> assertFail( readSubject, loopQuery, "Explicitly terminated by the user." ) ).start();
Thread loopQueryThread =
new Thread( () -> assertFail( readSubject, loopQuery, "Explicitly terminated by the user." ) );
loopQueryThread.start();
latch.startAndWaitForAllToStart();

try
Expand All @@ -725,6 +727,9 @@ public void shouldTerminateLongRunningProcedureThatChecksTheGuardRegularlyIfKill
latch.finishAndWaitForAllToFinish();
}

// there is a race with "test.loop" procedure - after decrementing latch it may take time to actually exit
loopQueryThread.join( 10_000 );

assertEmpty(
adminSubject,
"CALL dbms.listQueries() YIELD query WITH * WHERE NOT query CONTAINS 'listQueries' RETURN *" );
Expand Down
Expand Up @@ -59,7 +59,6 @@
import org.neo4j.kernel.api.bolt.BoltConnectionTracker;
import org.neo4j.kernel.api.bolt.ManagedBoltStateMachine;
import org.neo4j.kernel.api.exceptions.InvalidArgumentsException;
import org.neo4j.kernel.api.exceptions.Status;
import org.neo4j.kernel.enterprise.builtinprocs.EnterpriseBuiltInDbmsProcedures;
import org.neo4j.kernel.impl.proc.Procedures;
import org.neo4j.logging.Log;
Expand Down Expand Up @@ -679,9 +678,16 @@ public void loop()
guard.check();
}
}
catch (TransactionTerminatedException | TransactionGuardException e)
catch ( TransactionTerminatedException | TransactionGuardException e )
{
throw new TransactionGuardException( TransactionTimedOut, PROCEDURE_TIMEOUT_ERROR, e );
if ( e.status().equals( TransactionTimedOut ) )
{
throw new TransactionGuardException( TransactionTimedOut, PROCEDURE_TIMEOUT_ERROR, e );
}
else
{
throw e;
}
}
finally
{
Expand Down

0 comments on commit ae4bd5c

Please sign in to comment.