- @Test
- public void testSnapshotAfterStartupWithMigratedServerConfigPayloadAndPersistenceEnabled() {
- TEST_LOG.info("testSnapshotAfterStartupWithMigratedServerConfigPayloadAndPersistenceEnabled starting");
- doTestSnapshotAfterStartupWithMigratedServerConfigPayload(true);
- TEST_LOG.info("testSnapshotAfterStartupWithMigratedServerConfigPayloadAndPersistenceEnabled ending");
- }
-
- @Test
- public void testSnapshotAfterStartupWithMigratedServerConfigPayloadAndPersistenceDisabled() {
- TEST_LOG.info("testSnapshotAfterStartupWithMigratedServerConfigPayloadAndPersistenceDisabled starting");
-
- TestActorRef<MockRaftActor> actor = doTestSnapshotAfterStartupWithMigratedServerConfigPayload(false);
- MockRaftActor mockRaftActor = actor.underlyingActor();
- String id = mockRaftActor.persistenceId();
- ConfigParams config = mockRaftActor.getRaftActorContext().getConfigParams();
-
- factory.killActor(actor, new JavaTestKit(getSystem()));
-
- actor = factory.createTestActor(MockRaftActor.builder().id(id).config(config)
- .persistent(Optional.of(false)).props().withDispatcher(Dispatchers.DefaultDispatcherId()), id);
- mockRaftActor = actor.underlyingActor();
- mockRaftActor.waitForRecoveryComplete();
-
- assertEquals("electionTerm", 1,
- mockRaftActor.getRaftActorContext().getTermInformation().getCurrentTerm());
- assertEquals("votedFor", id,
- mockRaftActor.getRaftActorContext().getTermInformation().getVotedFor());
-
- TEST_LOG.info("testSnapshotAfterStartupWithMigratedServerConfigPayloadAndPersistenceDisabled ending");
- }
-
- @Test
- public void testSnapshotAfterStartupWithMigratedUpdateElectionTermAndPersistenceEnabled() {
- TEST_LOG.info("testSnapshotAfterStartupWithMigratedUpdateElectionTermAndPersistenceEnabled starting");
-
- String persistenceId = factory.generateActorId("test-actor-");
-
- org.opendaylight.controller.cluster.raft.base.messages.UpdateElectionTerm updateElectionTerm =
- new org.opendaylight.controller.cluster.raft.base.messages.UpdateElectionTerm(5, persistenceId);
-
- InMemoryJournal.addEntry(persistenceId, 1, updateElectionTerm);
-
- doTestSnapshotAfterStartupWithMigratedMessage(persistenceId, true, snapshot -> {
- assertEquals("getElectionVotedFor", persistenceId, snapshot.getElectionVotedFor());
- assertEquals("getElectionTerm", 5, snapshot.getElectionTerm());
- }, ByteState.empty());
-
- TEST_LOG.info("testSnapshotAfterStartupWithMigratedUpdateElectionTermAndPersistenceEnabled ending");
- }
-
- @Test
- public void testSnapshotAfterStartupWithMigratedUpdateElectionTermAndPersistenceDisabled() {
- TEST_LOG.info("testSnapshotAfterStartupWithMigratedUpdateElectionTermAndPersistenceDisabled starting");
-
- String persistenceId = factory.generateActorId("test-actor-");
-
- org.opendaylight.controller.cluster.raft.base.messages.UpdateElectionTerm updateElectionTerm =
- new org.opendaylight.controller.cluster.raft.base.messages.UpdateElectionTerm(5, persistenceId);
-
- InMemoryJournal.addEntry(persistenceId, 1, updateElectionTerm);
-
- doTestSnapshotAfterStartupWithMigratedMessage(persistenceId, false, snapshot -> {
- assertEquals("getElectionVotedFor", persistenceId, snapshot.getElectionVotedFor());
- assertEquals("getElectionTerm", 5, snapshot.getElectionTerm());
- }, ByteState.empty());
-
- TEST_LOG.info("testSnapshotAfterStartupWithMigratedUpdateElectionTermAndPersistenceDisabled ending");
- }
-
- @Test
- public void testSnapshotAfterStartupWithMigratedApplyJournalEntries() {
- TEST_LOG.info("testSnapshotAfterStartupWithMigratedApplyJournalEntries starting");
-
- String persistenceId = factory.generateActorId("test-actor-");
-
- InMemoryJournal.addEntry(persistenceId, 1, new UpdateElectionTerm(1, persistenceId));
- InMemoryJournal.addEntry(persistenceId, 2, new SimpleReplicatedLogEntry(0, 1,
- new MockRaftActorContext.MockPayload("A")));
- InMemoryJournal.addEntry(persistenceId, 3,
- new org.opendaylight.controller.cluster.raft.base.messages.ApplyJournalEntries(0));
-
-
- doTestSnapshotAfterStartupWithMigratedMessage(persistenceId, true, snapshot -> {
- assertEquals("getLastAppliedIndex", 0, snapshot.getLastAppliedIndex());
- assertEquals("getLastAppliedTerm", 1, snapshot.getLastAppliedTerm());
- assertEquals("getLastIndex", 0, snapshot.getLastIndex());
- assertEquals("getLastTerm", 1, snapshot.getLastTerm());
- }, ByteState.empty());
-
- TEST_LOG.info("testSnapshotAfterStartupWithMigratedApplyJournalEntries ending");
- }
-