use of org.neo4j.cluster.protocol.election.Election in project neo4j by neo4j.
the class HighAvailabilityModeSwitcherTest method shouldPerformForcedElections.
@Test
public void shouldPerformForcedElections() {
// Given
ClusterMemberAvailability memberAvailability = mock(ClusterMemberAvailability.class);
Election election = mock(Election.class);
HighAvailabilityModeSwitcher modeSwitcher = new HighAvailabilityModeSwitcher(mock(SwitchToSlaveCopyThenBranch.class), mock(SwitchToMaster.class), election, memberAvailability, mock(ClusterClient.class), storeSupplierMock(), mock(InstanceId.class), new ComponentSwitcherContainer(), neoStoreDataSourceSupplierMock(), NullLogService.getInstance());
// When
modeSwitcher.forceElections();
// Then
InOrder inOrder = inOrder(memberAvailability, election);
inOrder.verify(memberAvailability).memberIsUnavailable(HighAvailabilityModeSwitcher.SLAVE);
inOrder.verify(election).performRoleElections();
inOrder.verifyNoMoreInteractions();
}
use of org.neo4j.cluster.protocol.election.Election in project neo4j by neo4j.
the class HighAvailabilityModeSwitcherTest method shouldPerformForcedElectionsOnlyOnce.
@Test
public void shouldPerformForcedElectionsOnlyOnce() {
// Given: HAMS
ClusterMemberAvailability memberAvailability = mock(ClusterMemberAvailability.class);
Election election = mock(Election.class);
HighAvailabilityModeSwitcher modeSwitcher = new HighAvailabilityModeSwitcher(mock(SwitchToSlaveCopyThenBranch.class), mock(SwitchToMaster.class), election, memberAvailability, mock(ClusterClient.class), storeSupplierMock(), mock(InstanceId.class), new ComponentSwitcherContainer(), neoStoreDataSourceSupplierMock(), NullLogService.getInstance());
// When: reelections are forced multiple times
modeSwitcher.forceElections();
modeSwitcher.forceElections();
modeSwitcher.forceElections();
// Then: instance sens out memberIsUnavailable and asks for elections and does this only once
InOrder inOrder = inOrder(memberAvailability, election);
inOrder.verify(memberAvailability).memberIsUnavailable(HighAvailabilityModeSwitcher.SLAVE);
inOrder.verify(election).performRoleElections();
inOrder.verifyNoMoreInteractions();
}
Aggregations