use of com.apple.foundationdb.record.RecordMetaData in project fdb-record-layer by FoundationDB.
the class MetaDataEvolutionValidatorTest method formerIndexFromThePast.
@Test
public void formerIndexFromThePast() {
RecordMetaData metaData1 = RecordMetaData.build(TestRecords1Proto.getDescriptor());
RecordMetaData metaData2 = RecordMetaData.build(metaData1.toProto().toBuilder().setVersion(metaData1.getVersion() + 1).addFormerIndexes(RecordMetaDataProto.FormerIndex.newBuilder().setSubspaceKey(ByteString.copyFrom(Tuple.from("dummy_key").pack())).setRemovedVersion(metaData1.getVersion() - 1).build()).build());
assertInvalid("new former index has removed version that is not newer than the old meta-data version", metaData1, metaData2);
RecordMetaData metaData3 = RecordMetaData.build(metaData1.toProto().toBuilder().setVersion(metaData1.getVersion() + 1).addFormerIndexes(RecordMetaDataProto.FormerIndex.newBuilder().setSubspaceKey(ByteString.copyFrom(Tuple.from("dummy_key").pack())).setRemovedVersion(metaData1.getVersion()).build()).build());
assertInvalid("new former index has removed version that is not newer than the old meta-data version", metaData1, metaData3);
}
use of com.apple.foundationdb.record.RecordMetaData in project fdb-record-layer by FoundationDB.
the class MetaDataEvolutionValidatorTest method indexLastModifiedVersionChanged.
@Test
public void indexLastModifiedVersionChanged() {
RecordMetaData metaData1 = RecordMetaData.build(TestRecords1Proto.getDescriptor());
RecordMetaData metaData2 = replaceIndex(metaData1, "MySimpleRecord$str_value_indexed", indexProto -> indexProto.toBuilder().setLastModifiedVersion(metaData1.getVersion() + 1).build());
assertInvalid("last modified version of index changed", metaData1, metaData2);
MetaDataEvolutionValidator laxerValidator = MetaDataEvolutionValidator.newBuilder().setAllowIndexRebuilds(true).build();
laxerValidator.validate(metaData1, metaData2);
}
use of com.apple.foundationdb.record.RecordMetaData in project fdb-record-layer by FoundationDB.
the class MetaDataEvolutionValidatorTest method indexRecordTypeRemoved.
@Test
public void indexRecordTypeRemoved() {
final String indexName = "simple&other$num_value_2";
RecordMetaDataBuilder metaDataBuilder = RecordMetaData.newBuilder().setRecords(TestRecords1Proto.getDescriptor());
metaDataBuilder.addMultiTypeIndex(Arrays.asList(metaDataBuilder.getRecordType("MySimpleRecord"), metaDataBuilder.getRecordType("MyOtherRecord")), new Index(indexName, "num_value_2"));
RecordMetaData metaData1 = metaDataBuilder.getRecordMetaData();
validateIndexMutation("new index removes record type", metaData1, indexName, indexProto -> indexProto.toBuilder().clearRecordType().addRecordType("MySimpleRecord").build());
}
use of com.apple.foundationdb.record.RecordMetaData in project fdb-record-layer by FoundationDB.
the class MetaDataEvolutionValidatorTest method indexLastModifiedVersionTooOld.
@Test
public void indexLastModifiedVersionTooOld() {
RecordMetaData metaData1 = replaceIndex(RecordMetaData.build(TestRecords1Proto.getDescriptor()), "MySimpleRecord$str_value_indexed", indexProto -> indexProto.toBuilder().setLastModifiedVersion(2).build());
RecordMetaData metaData2 = replaceIndex(metaData1, "MySimpleRecord$str_value_indexed", indexProto -> indexProto.toBuilder().setLastModifiedVersion(1).build());
assertInvalid("old index has last-modified version newer than new index", metaData1, metaData2);
}
use of com.apple.foundationdb.record.RecordMetaData in project fdb-record-layer by FoundationDB.
the class MetaDataEvolutionValidatorTest method addRequiredField.
@Test
public void addRequiredField() {
FileDescriptor updatedFile = mutateFile(fileBuilder -> fileBuilder.getMessageTypeBuilderList().forEach(message -> {
if (message.getName().equals("MySimpleRecord")) {
message.addField(DescriptorProtos.FieldDescriptorProto.newBuilder().setLabel(DescriptorProtos.FieldDescriptorProto.Label.LABEL_REQUIRED).setType(DescriptorProtos.FieldDescriptorProto.Type.TYPE_INT32).setName("new_int_field").setNumber(message.getFieldList().stream().mapToInt(DescriptorProtos.FieldDescriptorProto::getNumber).max().getAsInt() + 1));
}
}));
assertInvalid("required field added to record type", TestRecords1Proto.getDescriptor(), updatedFile);
RecordMetaData metaData1 = RecordMetaData.build(TestRecords1Proto.getDescriptor());
RecordMetaData metaData2 = replaceRecordsDescriptor(metaData1, updatedFile);
assertInvalid("required field added to record type", metaData1, metaData2);
}
Aggregations