Skip to content

Commit

Permalink
increasing timeouts to fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenag committed Jul 10, 2017
1 parent b910a88 commit 92f8d8d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 49 deletions.
Expand Up @@ -80,6 +80,7 @@ protected void configure( GraphDatabaseBuilder builder )
};
@Rule
public final ThreadingRule threads = new ThreadingRule();
private static final int THIRTY_SECONDS_TIMEOUT = 30;

@Test
public void shouldContainTheQueryItself() throws Exception
Expand Down Expand Up @@ -109,7 +110,7 @@ public void shouldNotIncludeDeprecatedFields() throws Exception
}

@Test
public void shouldProvideElapsedCpuTime() throws Exception
public void shouldProvideElapsedCpuTimePlannerConnectionDetailsPageHitsAndFaults() throws Exception
{
// given
String query = "MATCH (n) SET n.v = n.v + 1";
Expand Down Expand Up @@ -146,6 +147,26 @@ public void shouldProvideElapsedCpuTime() throws Exception
assertThat( cpuTime2, greaterThanOrEqualTo( (Long) cpuTime1 ) );
Long waitTime2 = (Long) data.get( "waitTimeMillis" );
assertThat( waitTime2, greaterThanOrEqualTo( (Long) waitTime1 ) );

// ListPlannerAndRuntimeUsed
// then
assertThat( data, hasKey( "planner" ) );
assertThat( data, hasKey( "runtime" ) );
assertThat( data.get( "planner" ), instanceOf( String.class ) );
assertThat( data.get( "runtime" ), instanceOf( String.class ) );

// SpecificConnectionDetails

// then
assertThat( data, hasKey( "protocol" ) );
assertThat( data, hasKey( "clientAddress" ) );
assertThat( data, hasKey( "requestUri" ) );

//ContainPageHitsAndPageFaults
// then
assertThat( data, hasEntry( equalTo( "pageHits" ), instanceOf( Long.class ) ) );
assertThat( data, hasEntry( equalTo( "pageFaults" ), instanceOf( Long.class ) ) );

}
}

Expand Down Expand Up @@ -184,24 +205,6 @@ public void shouldProvideAllocatedBytes() throws Exception
}
}

@Test
public void shouldListPlannerAndRuntimeUsed() throws Exception
{
// given
String QUERY = "MATCH (n) SET n.v = n.v - 1";
try ( Resource<Node> test = test( db::createNode, Transaction::acquireWriteLock, QUERY ) )
{
// when
Map<String,Object> data = getQueryListing( QUERY );

// then
assertThat( data, hasKey( "planner" ) );
assertThat( data, hasKey( "runtime" ) );
assertThat( data.get( "planner" ), instanceOf( String.class ) );
assertThat( data.get( "runtime" ), instanceOf( String.class ) );
}
}

@Test
public void shouldListActiveLocks() throws Exception
{
Expand Down Expand Up @@ -262,34 +265,6 @@ public void shouldListActiveLocks() throws Exception
}
}

@Test
public void shouldContainSpecificConnectionDetails() throws Exception
{
// when
Map<String,Object> data = getQueryListing( "CALL dbms.listQueries" );

// then
assertThat( data, hasKey( "protocol" ) );
assertThat( data, hasKey( "clientAddress" ) );
assertThat( data, hasKey( "requestUri" ) );
}

@Test
public void shouldContainPageHitsAndPageFaults() throws Exception
{
// given
String query = "MATCH (n) SET n.v = n.v + 1";
try ( Resource<Node> test = test( db::createNode, Transaction::acquireWriteLock, query ) )
{
// when
Map<String,Object> data = getQueryListing( query );

// then
assertThat( data, hasEntry( equalTo( "pageHits" ), instanceOf( Long.class ) ) );
assertThat( data, hasEntry( equalTo( "pageFaults" ), instanceOf( Long.class ) ) );
}
}

@Test
public void shouldListUsedIndexes() throws Exception
{
Expand Down Expand Up @@ -497,7 +472,7 @@ private <T> Resource<T> test( Supplier<T> setup, BiConsumer<Transaction,T> lock,
{
db.execute( query ).close();
return null;
}, null, waitingWhileIn( GraphDatabaseFacade.class, "execute" ), 5, SECONDS );
}, null, waitingWhileIn( GraphDatabaseFacade.class, "execute" ), THIRTY_SECONDS_TIMEOUT, SECONDS );

return new Resource<T>( listQueriesLatch, resource );
}
Expand Down
Expand Up @@ -50,6 +50,7 @@

public class ListQueriesProcedureInClusterIT
{
private static final int THIRTY_SECONDS_TIMEOUT = 30;
private final ClusterRule clusterRule =
new ClusterRule( getClass() ).withNumberOfCoreMembers( 3 ).withNumberOfReadReplicas( 1 );
private final VerboseTimeout timeout = VerboseTimeout.builder().withTimeout( 1000, SECONDS ).build();
Expand Down Expand Up @@ -97,7 +98,7 @@ public void listQueriesWillNotIncludeQueriesFromOtherServersInCluster() throws E
//When
threads.executeAndAwait(
executeQuery( CORE_QUERY, executedCoreQueryLatch::countDown ),/*on: */ leaderDb,
waitingWhileIn( GraphDatabaseFacade.class, "execute" ), 5, SECONDS );
waitingWhileIn( GraphDatabaseFacade.class, "execute" ), THIRTY_SECONDS_TIMEOUT, SECONDS );

//Then
Optional<Map<String,Object>> coreQueryListing1 = getQueryListing( CORE_QUERY, leaderDb );
Expand Down

0 comments on commit 92f8d8d

Please sign in to comment.