Search in sources :

Example 1 with RaftLogCommitIndexMonitor

use of org.neo4j.causalclustering.core.consensus.log.monitoring.RaftLogCommitIndexMonitor in project neo4j by neo4j.

the class CommandApplicationProcessTest method shouldApplyCommittedCommand.

@Test
public void shouldApplyCommittedCommand() throws Throwable {
    // given
    RaftLogCommitIndexMonitor listener = mock(RaftLogCommitIndexMonitor.class);
    monitors.addMonitorListener(listener);
    applicationProcess.start();
    InOrder inOrder = inOrder(coreStateMachines, commandDispatcher);
    // when
    raftLog.append(new RaftLogEntry(0, operation(nullTx)));
    raftLog.append(new RaftLogEntry(0, operation(nullTx)));
    raftLog.append(new RaftLogEntry(0, operation(nullTx)));
    applicationProcess.notifyCommitted(2);
    applier.sync(false);
    // then
    inOrder.verify(coreStateMachines).commandDispatcher();
    inOrder.verify(commandDispatcher).dispatch(eq(nullTx), eq(0L), anyCallback());
    inOrder.verify(commandDispatcher).dispatch(eq(nullTx), eq(1L), anyCallback());
    inOrder.verify(commandDispatcher).dispatch(eq(nullTx), eq(2L), anyCallback());
    inOrder.verify(commandDispatcher).close();
    verify(listener).commitIndex(2);
}
Also used : RaftLogCommitIndexMonitor(org.neo4j.causalclustering.core.consensus.log.monitoring.RaftLogCommitIndexMonitor) InOrder(org.mockito.InOrder) RaftLogEntry(org.neo4j.causalclustering.core.consensus.log.RaftLogEntry) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 InOrder (org.mockito.InOrder)1 RaftLogEntry (org.neo4j.causalclustering.core.consensus.log.RaftLogEntry)1 RaftLogCommitIndexMonitor (org.neo4j.causalclustering.core.consensus.log.monitoring.RaftLogCommitIndexMonitor)1