Skip to content

Commit

Permalink
Improve tests by awaiting new master before continuing
Browse files Browse the repository at this point in the history
  • Loading branch information
spacecowboy committed Feb 1, 2016
1 parent bfdb7ee commit 7db0802
Showing 1 changed file with 8 additions and 11 deletions.
Expand Up @@ -104,12 +104,13 @@ public void startTxAsSlaveAndFinishItAfterHavingSwitchedToMasterShouldNotSucceed
}
finally
{
cluster.shutdown( cluster.getMaster() );
HighlyAvailableGraphDatabase oldMaster = cluster.getMaster();
cluster.shutdown( oldMaster );
// Wait for new master
cluster.await( masterAvailable( oldMaster ) );
assertFinishGetsTransactionFailure( tx );
}

cluster.await( masterAvailable() );

// THEN
assertEquals( db, cluster.getMaster() );
// to prevent a deadlock scenario which occurs if this test exists (and @After starts)
Expand All @@ -122,7 +123,7 @@ public void startTxAsSlaveAndFinishItAfterAnotherMasterBeingAvailableShouldNotSu
{
// GIVEN
HighlyAvailableGraphDatabase db = getSlaveOnlySlave();
HighlyAvailableGraphDatabase oldMaster = cluster.getMaster();
HighlyAvailableGraphDatabase oldMaster;

// WHEN
Transaction tx = db.beginTx();
Expand All @@ -133,18 +134,14 @@ public void startTxAsSlaveAndFinishItAfterAnotherMasterBeingAvailableShouldNotSu
}
finally
{
oldMaster = cluster.getMaster();
cluster.shutdown( oldMaster );
// Wait for new master
cluster.await( masterAvailable( oldMaster ) );
// THEN
assertFinishGetsTransactionFailure( tx );
}

try
{
cluster.await( ClusterManager.masterAvailable() );
} catch (Exception e) {
throw e;
}

assertFalse( db.isMaster() );
assertFalse( oldMaster.isMaster() );
// to prevent a deadlock scenario which occurs if this test exists (and @After starts)
Expand Down

0 comments on commit 7db0802

Please sign in to comment.