import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.controller.cluster.datastore.modification.ModificationPayload;
-import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification;
-import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
+import org.opendaylight.controller.cluster.datastore.persisted.CommitTransactionPayload;
import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
-import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationByteStringPayload;
-import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationPayload;
import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel;
import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.slf4j.LoggerFactory;
-public class ShardRecoveryCoordinatorTest {
+public class ShardRecoveryCoordinatorTest extends AbstractTest {
private ShardDataTree peopleDataTree;
private SchemaContext peopleSchemaContext;
peopleSchemaContext = SchemaContextHelper.select(SchemaContextHelper.PEOPLE_YANG);
carsSchemaContext = SchemaContextHelper.select(SchemaContextHelper.CARS_YANG);
- peopleDataTree = new ShardDataTree(peopleSchemaContext);
+ peopleDataTree = new ShardDataTree(peopleSchemaContext, TreeType.OPERATIONAL);
}
+ @Deprecated
@Test
public void testAppendRecoveredLogEntryDataTreeCandidatePayload(){
final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
}
@Test
- public void testAppendRecoveredLogEntryModificationPayload() throws IOException {
+ public void testAppendRecoveredLogEntryCommitTransactionPayload() throws IOException {
final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
coordinator.startLogRecoveryBatch(10);
try {
- final MutableCompositeModification modification = new MutableCompositeModification((short) 1);
- modification.addModification(new WriteModification(CarsModel.BASE_PATH, CarsModel.create()));
- coordinator.appendRecoveredLogEntry(new ModificationPayload(modification));
- } catch(final SchemaValidationFailedException e){
- fail("SchemaValidationFailedException should not happen if pruning is done");
- }
- }
-
- @Test
- public void testAppendRecoveredLogEntryCompositeModificationPayload() throws IOException {
- final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
- peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
- coordinator.startLogRecoveryBatch(10);
- try {
- final MutableCompositeModification modification = new MutableCompositeModification((short) 1);
- modification.addModification(new WriteModification(CarsModel.BASE_PATH, CarsModel.create()));
- coordinator.appendRecoveredLogEntry(new CompositeModificationPayload(modification.toSerializable()));
- } catch(final SchemaValidationFailedException e){
- fail("SchemaValidationFailedException should not happen if pruning is done");
- }
- }
-
- @Test
- public void testAppendRecoveredLogEntryCompositeModificationByteStringPayload() throws IOException {
- final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
- peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
- coordinator.startLogRecoveryBatch(10);
- try {
- final MutableCompositeModification modification = new MutableCompositeModification((short) 1);
- modification.addModification(new WriteModification(CarsModel.BASE_PATH, CarsModel.create()));
- coordinator.appendRecoveredLogEntry(new CompositeModificationByteStringPayload(modification.toSerializable()));
+ coordinator.appendRecoveredLogEntry(CommitTransactionPayload.create(nextTransactionId(), createCar()));
} catch(final SchemaValidationFailedException e){
fail("SchemaValidationFailedException should not happen if pruning is done");
}
- assertEquals(false, readCars(peopleDataTree).isPresent());
+ coordinator.applyCurrentLogRecoveryBatch();
}
@Test
final byte[] bytes = SerializationUtils.serializeNormalizedNode(optional.get());
return bytes;
-
-
}
}
\ No newline at end of file