use of org.elasticsearch.plugins.MetaDataUpgrader in project elasticsearch by elastic.
the class GatewayMetaStateTests method testUpdateCustomMetaDataOnUpgrade.
public void testUpdateCustomMetaDataOnUpgrade() throws Exception {
MetaData metaData = randomMetaData(new CustomMetaData1("data"));
MetaDataUpgrader metaDataUpgrader = new MetaDataUpgrader(Collections.singletonList(customs -> {
customs.put(CustomMetaData1.TYPE, new CustomMetaData1("modified_data1"));
return customs;
}));
MetaData upgrade = GatewayMetaState.upgradeMetaData(metaData, new MockMetaDataIndexUpgradeService(false), metaDataUpgrader);
assertTrue(upgrade != metaData);
assertFalse(MetaData.isGlobalStateEquals(upgrade, metaData));
assertNotNull(upgrade.custom(CustomMetaData1.TYPE));
assertThat(((TestCustomMetaData) upgrade.custom(CustomMetaData1.TYPE)).getData(), equalTo("modified_data1"));
}
use of org.elasticsearch.plugins.MetaDataUpgrader in project elasticsearch by elastic.
the class GatewayMetaStateTests method testIndexMetaDataUpgrade.
public void testIndexMetaDataUpgrade() throws Exception {
MetaData metaData = randomMetaData();
MetaDataUpgrader metaDataUpgrader = new MetaDataUpgrader(Collections.emptyList());
MetaData upgrade = GatewayMetaState.upgradeMetaData(metaData, new MockMetaDataIndexUpgradeService(true), metaDataUpgrader);
assertTrue(upgrade != metaData);
assertTrue(MetaData.isGlobalStateEquals(upgrade, metaData));
for (IndexMetaData indexMetaData : upgrade) {
assertFalse(metaData.hasIndexMetaData(indexMetaData));
}
}
use of org.elasticsearch.plugins.MetaDataUpgrader in project elasticsearch by elastic.
the class GatewayMetaStateTests method testCustomMetaDataValidation.
public void testCustomMetaDataValidation() throws Exception {
MetaData metaData = randomMetaData(new CustomMetaData1("data"));
MetaDataUpgrader metaDataUpgrader = new MetaDataUpgrader(Collections.singletonList(customs -> {
throw new IllegalStateException("custom meta data too old");
}));
try {
GatewayMetaState.upgradeMetaData(metaData, new MockMetaDataIndexUpgradeService(false), metaDataUpgrader);
} catch (IllegalStateException e) {
assertThat(e.getMessage(), equalTo("custom meta data too old"));
}
}
Aggregations