Skip to content

Commit

Permalink
Sync cluster before asserting
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegrohmann committed Sep 5, 2016
1 parent b9689b4 commit b0ef390
Showing 1 changed file with 11 additions and 12 deletions.
Expand Up @@ -42,8 +42,7 @@ public class TestBasicHaOperations
@ClassRule @ClassRule
public static LoggerRule logger = new LoggerRule( Level.OFF ); public static LoggerRule logger = new LoggerRule( Level.OFF );
@Rule @Rule
public ClusterRule clusterRule = new ClusterRule( getClass() ) public ClusterRule clusterRule = new ClusterRule( getClass() ).withSharedSetting( HaSettings.tx_push_factor, "2" );
.withSharedSetting( HaSettings.tx_push_factor, "2" );


@Test @Test
public void testBasicFailover() throws Throwable public void testBasicFailover() throws Throwable
Expand Down Expand Up @@ -134,21 +133,21 @@ public void testBasicPropagationFromMasterToSlave() throws Throwable
tx.success(); tx.success();
} }


cluster.sync();

// No need to wait, the push factor is 2 // No need to wait, the push factor is 2
HighlyAvailableGraphDatabase slave1 = cluster.getAnySlave(); HighlyAvailableGraphDatabase slave1 = cluster.getAnySlave();
String value; checkNodeOnSlave( nodeId, slave1 );
try ( Transaction tx = slave1.beginTx() )
{
value = slave1.getNodeById( nodeId ).getProperty( "Hello" ).toString();
logger.getLogger().info( "Hello=" + value );
assertEquals( "World", value );
tx.success();
}


HighlyAvailableGraphDatabase slave2 = cluster.getAnySlave(slave1); HighlyAvailableGraphDatabase slave2 = cluster.getAnySlave( slave1 );
checkNodeOnSlave( nodeId, slave2 );
}

private void checkNodeOnSlave( long nodeId, HighlyAvailableGraphDatabase slave2 )
{
try ( Transaction tx = slave2.beginTx() ) try ( Transaction tx = slave2.beginTx() )
{ {
value = slave2.getNodeById( nodeId ).getProperty( "Hello" ).toString(); String value = slave2.getNodeById( nodeId ).getProperty( "Hello" ).toString();
logger.getLogger().info( "Hello=" + value ); logger.getLogger().info( "Hello=" + value );
assertEquals( "World", value ); assertEquals( "World", value );
tx.success(); tx.success();
Expand Down

0 comments on commit b0ef390

Please sign in to comment.