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 authored and davidegrohmann committed Jul 1, 2016
1 parent 2f427e4 commit 36a5fb5
Showing 1 changed file with 8 additions and 11 deletions.
Expand Up @@ -109,12 +109,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 @@ -127,7 +128,7 @@ public void startTxAsSlaveAndFinishItAfterAnotherMasterBeingAvailableShouldNotSu
{
// GIVEN
HighlyAvailableGraphDatabase db = getSlaveOnlySlave();
HighlyAvailableGraphDatabase oldMaster = cluster.getMaster();
HighlyAvailableGraphDatabase oldMaster;

// WHEN
Transaction tx = db.beginTx();
Expand All @@ -138,18 +139,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 36a5fb5

Please sign in to comment.