use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class ChangeSetManagerTest method getExecutedChangeSets_invalidCheckSum.
@Test(expected = IllegalArgumentException.class)
public void getExecutedChangeSets_invalidCheckSum() {
ChangeSet changeSet = newChangeSet("id1", "value1");
List<ChangeSet> changeSets = Arrays.asList(changeSet);
CheckSum invalidCheckSum = CheckSum.compute(CheckSum.getCurrentVersion(), "value2");
List<SchemaChangeLog> schemaChangeLogs = Arrays.asList(newSchemaChangeLog("id1", "value1", invalidCheckSum, 1));
ChangeSetManager changeSetManager = new ChangeSetManager(changeSets);
changeSetManager.getExecutedChangeSets(schemaChangeLogs);
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class ChangeSetManagerTest method filterExecutedChangeSets_invalidId.
@Test(expected = IllegalArgumentException.class)
public void filterExecutedChangeSets_invalidId() {
ChangeSet changeSet = newChangeSet("id1", "value1");
List<ChangeSet> changeSets = Arrays.asList(changeSet);
List<SchemaChangeLog> schemaChangeLogs = Arrays.asList(newSchemaChangeLog("id2", "value1", 1));
ChangeSetManager changeSetManager = new ChangeSetManager(changeSets);
changeSetManager.filterExecutedChangeSets(schemaChangeLogs);
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class ChangeSetManagerTest method filterExecutedChangeSets_emptySchemaChangeLogs.
@Test
public void filterExecutedChangeSets_emptySchemaChangeLogs() {
ChangeSet changeSet1 = newChangeSet("id1", "value1");
ChangeSet changeSet2 = newChangeSet("id2", "value2");
List<ChangeSet> changeSets = Arrays.asList(changeSet1, changeSet2);
ChangeSetManager changeSetManager = new ChangeSetManager(changeSets);
assertThat(changeSetManager.filterExecutedChangeSets(Collections.emptyList()), contains(changeSet1, changeSet2));
assertThat(changeSetManager.filterExecutedChangeSets(null), contains(changeSet1, changeSet2));
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class HbaseSchemaCommandManagerTest method creatingExistingTableShouldFail.
@Test(expected = InvalidHbaseSchemaException.class)
public void creatingExistingTableShouldFail() {
String namespace = "namespace";
String tableName = "table";
HTableDescriptor existingTable = createHtd(namespace, tableName, "CF");
HbaseSchemaCommandManager manager = new HbaseSchemaCommandManager(namespace, null, Arrays.asList(existingTable));
TableChange createTableChange = newTableChange(ChangeType.CREATE, tableName);
ChangeSet createTableChangeSet = newChangeSet(createTableChange);
manager.applyChangeSet(createTableChangeSet);
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class HbaseSchemaCommandManagerTest method failedChangesShouldNotAffectTheSchema.
@Test
public void failedChangesShouldNotAffectTheSchema() {
String namespace = "namespace";
String tableName = "table";
String columnFamilyName = "CF";
HbaseSchemaCommandManager manager = new HbaseSchemaCommandManager(namespace, null);
// initial create table
ColumnFamilyChange columnFamilyChange = newColumnFamilyChange(columnFamilyName);
TableChange createTableChange = newTableChange(ChangeType.CREATE, tableName, columnFamilyChange);
ChangeSet createTableChangeSet = newChangeSet(createTableChange);
manager.applyChangeSet(createTableChangeSet);
List<HTableDescriptor> initialSnapshot = manager.getSchemaSnapshot();
// modify non-existing table
TableChange modifyNonExistingTableChange = newTableChange(ChangeType.MODIFY, "nonExistingTable", newColumnFamilyChange("newCF"));
ChangeSet modifyNonExistingTableChangeSet = newChangeSet(modifyNonExistingTableChange);
try {
manager.applyChangeSet(modifyNonExistingTableChangeSet);
fail("Expected an InvalidHbaseSchemaException to be thrown");
} catch (InvalidHbaseSchemaException expected) {
List<HTableDescriptor> currentSnapshot = manager.getSchemaSnapshot();
assertThat(currentSnapshot, equalTo(initialSnapshot));
}
// create existing table
TableChange createExistingTableChange = newTableChange(ChangeType.CREATE, tableName);
ChangeSet createExistingTableChangeSet = newChangeSet(createExistingTableChange);
try {
manager.applyChangeSet(createExistingTableChangeSet);
fail("Expected an InvalidHbaseSchemaException to be thrown");
} catch (InvalidHbaseSchemaException expected) {
List<HTableDescriptor> currentSnapshot = manager.getSchemaSnapshot();
assertThat(currentSnapshot, equalTo(initialSnapshot));
}
// create existing column family
ColumnFamilyChange createExistingColumnFamilyChange = newColumnFamilyChange(columnFamilyName);
TableChange createExistingColumnFamilyTableChange = newTableChange(ChangeType.MODIFY, tableName, createExistingColumnFamilyChange);
ChangeSet createExistingColumnFamilyChangeSet = newChangeSet(createExistingColumnFamilyTableChange);
try {
manager.applyChangeSet(createExistingColumnFamilyChangeSet);
fail("Expected an InvalidHbaseSchemaException to be thrown");
} catch (InvalidHbaseSchemaException expected) {
List<HTableDescriptor> currentSnapshot = manager.getSchemaSnapshot();
assertThat(currentSnapshot, equalTo(initialSnapshot));
}
}
Aggregations