Skip to content

Commit

Permalink
Merge pull request #9935 from klaren/3.3-await-index-online-timeout
Browse files Browse the repository at this point in the history
Increase timeout for AwaitIndexProcedureTest
  • Loading branch information
klaren committed Aug 30, 2017
2 parents 71a216b + 3fb159c commit 5f075d5
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
package org.neo4j.kernel.builtinprocs;

import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -57,8 +55,8 @@

public class AwaitIndexProcedureTest
{
private static final int timeout = 40;
private static final TimeUnit timeoutUnits = TimeUnit.MILLISECONDS;
private static final int TIMEOUT = 40;
private static final TimeUnit TIME_UNIT = TimeUnit.MILLISECONDS;
private final ReadOperations operations = mock( ReadOperations.class );
private final IndexProcedures procedure = new IndexProcedures( new StubKernelTransaction( operations ), null );
private final LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel( 123, 456 );
Expand All @@ -72,7 +70,7 @@ public void shouldThrowAnExceptionIfTheLabelDoesntExist() throws ProcedureExcept

try
{
procedure.awaitIndex( ":NonExistentLabel(prop)", timeout, timeoutUnits );
procedure.awaitIndex( ":NonExistentLabel(prop)", TIMEOUT, TIME_UNIT );
fail( "Expected an exception" );
}
catch ( ProcedureException e )
Expand All @@ -88,7 +86,7 @@ public void shouldThrowAnExceptionIfThePropertyKeyDoesntExist() throws Procedure

try
{
procedure.awaitIndex( ":Label(nonExistentProperty)", timeout, timeoutUnits );
procedure.awaitIndex( ":Label(nonExistentProperty)", TIMEOUT, TIME_UNIT );
fail( "Expected an exception" );
}
catch ( ProcedureException e )
Expand All @@ -106,7 +104,7 @@ public void shouldLookUpTheIndexByLabelIdAndPropertyKeyId()
when( operations.indexGetForSchema( anyObject() ) ).thenReturn( anyIndex );
when( operations.indexGetState( any( IndexDescriptor.class ) ) ).thenReturn( ONLINE );

procedure.awaitIndex( ":Person(name)", timeout, timeoutUnits );
procedure.awaitIndex( ":Person(name)", TIMEOUT, TIME_UNIT );

verify( operations ).indexGetForSchema( descriptor );
}
Expand All @@ -123,7 +121,7 @@ public void shouldThrowAnExceptionIfTheIndexHasFailed()

try
{
procedure.awaitIndex( ":Person(name)", timeout, timeoutUnits );
procedure.awaitIndex( ":Person(name)", TIMEOUT, TIME_UNIT );
fail( "Expected an exception" );
}
catch ( ProcedureException e )
Expand All @@ -144,7 +142,7 @@ public void shouldThrowAnExceptionIfTheIndexDoesNotExist()

try
{
procedure.awaitIndex( ":Person(name)", timeout, timeoutUnits );
procedure.awaitIndex( ":Person(name)", TIMEOUT, TIME_UNIT );
fail( "Expected an exception" );
}
catch ( ProcedureException e )
Expand All @@ -169,7 +167,7 @@ public void shouldBlockUntilTheIndexIsOnline() throws SchemaRuleNotFoundExceptio
{
try
{
procedure.awaitIndex( ":Person(name)", timeout, timeoutUnits );
procedure.awaitIndex( ":Person(name)", TIMEOUT, TIME_UNIT );
}
catch ( ProcedureException e )
{
Expand All @@ -182,7 +180,7 @@ public void shouldBlockUntilTheIndexIsOnline() throws SchemaRuleNotFoundExceptio

state.set( ONLINE );
assertEventually( "Procedure did not return after index was online",
done::get, is( true ), 10, TimeUnit.SECONDS );
done::get, is( true ), TIMEOUT, TimeUnit.SECONDS );
}

@Test
Expand All @@ -199,15 +197,15 @@ public void shouldTimeoutIfTheIndexTakesTooLongToComeOnline()
{
try
{
procedure.awaitIndex( ":Person(name)", timeout, timeoutUnits );
procedure.awaitIndex( ":Person(name)", TIMEOUT, TIME_UNIT );
}
catch ( ProcedureException e )
{
exception.set( e );
}
} ).start();

assertEventually( "Procedure did not time out", exception::get, not( nullValue() ), 10, TimeUnit.SECONDS );
assertEventually( "Procedure did not time out", exception::get, not( nullValue() ), TIMEOUT, TimeUnit.SECONDS );
//noinspection ThrowableResultOfMethodCallIgnored
assertThat( exception.get().status(), is( Status.Procedure.ProcedureTimedOut ) );
}
Expand Down

0 comments on commit 5f075d5

Please sign in to comment.