use of org.opensearch.Version in project OpenSearch by opensearch-project.
the class FeatureAwareTests method testFeature.
public void testFeature() {
final Version version = VersionUtils.randomVersion(random());
final Version afterVersion = randomVersionBetween(random(), version, Version.CURRENT);
final Custom custom = new RequiredFeatureCustom(version);
// the feature is present
final BytesStreamOutput out = new BytesStreamOutput();
out.setVersion(afterVersion);
assertTrue(custom.getRequiredFeature().isPresent());
out.setFeatures(Collections.singleton(custom.getRequiredFeature().get()));
assertTrue(FeatureAware.shouldSerialize(out, custom));
}
use of org.opensearch.Version in project OpenSearch by opensearch-project.
the class ClusterStateTests method testSupersedes.
public void testSupersedes() {
final Version version = Version.CURRENT;
final DiscoveryNode node1 = new DiscoveryNode("node1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), version);
final DiscoveryNode node2 = new DiscoveryNode("node2", buildNewFakeTransportAddress(), emptyMap(), emptySet(), version);
final DiscoveryNodes nodes = DiscoveryNodes.builder().add(node1).add(node2).build();
ClusterName name = ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY);
ClusterState noMaster1 = ClusterState.builder(name).version(randomInt(5)).nodes(nodes).build();
ClusterState noMaster2 = ClusterState.builder(name).version(randomInt(5)).nodes(nodes).build();
ClusterState withMaster1a = ClusterState.builder(name).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes).masterNodeId(node1.getId())).build();
ClusterState withMaster1b = ClusterState.builder(name).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes).masterNodeId(node1.getId())).build();
ClusterState withMaster2 = ClusterState.builder(name).version(randomInt(5)).nodes(DiscoveryNodes.builder(nodes).masterNodeId(node2.getId())).build();
// states with no master should never supersede anything
assertFalse(noMaster1.supersedes(noMaster2));
assertFalse(noMaster1.supersedes(withMaster1a));
// states should never supersede states from another master
assertFalse(withMaster1a.supersedes(withMaster2));
assertFalse(withMaster1a.supersedes(noMaster1));
// state from the same master compare by version
assertThat(withMaster1a.supersedes(withMaster1b), equalTo(withMaster1a.version() > withMaster1b.version()));
}
use of org.opensearch.Version in project OpenSearch by opensearch-project.
the class MetadataCreateIndexServiceTests method testPrepareResizeIndexSettings.
public void testPrepareResizeIndexSettings() {
final List<Version> versions = Arrays.asList(VersionUtils.randomVersion(random()), VersionUtils.randomVersion(random()));
versions.sort(Comparator.comparingLong(l -> l.id));
final Version version = versions.get(0);
final Version upgraded = versions.get(1);
final Settings.Builder indexSettingsBuilder = Settings.builder().put("index.version.created", version).put("index.version.upgraded", upgraded).put("index.similarity.default.type", "BM25").put("index.analysis.analyzer.default.tokenizer", "keyword").put("index.soft_deletes.enabled", "true");
if (randomBoolean()) {
indexSettingsBuilder.put("index.allocation.max_retries", randomIntBetween(1, 1000));
}
runPrepareResizeIndexSettingsTest(indexSettingsBuilder.build(), Settings.EMPTY, emptyList(), randomBoolean(), settings -> {
assertThat("similarity settings must be copied", settings.get("index.similarity.default.type"), equalTo("BM25"));
assertThat("analysis settings must be copied", settings.get("index.analysis.analyzer.default.tokenizer"), equalTo("keyword"));
assertThat(settings.get("index.routing.allocation.initial_recovery._id"), equalTo("node1"));
assertThat(settings.get("index.allocation.max_retries"), nullValue());
assertThat(settings.getAsVersion("index.version.created", null), equalTo(version));
assertThat(settings.getAsVersion("index.version.upgraded", null), equalTo(upgraded));
assertThat(settings.get("index.soft_deletes.enabled"), equalTo("true"));
});
}
use of org.opensearch.Version in project OpenSearch by opensearch-project.
the class DiscoveryNodeFiltersTests method testIdOrNameMatch.
public void testIdOrNameMatch() {
Settings settings = shuffleSettings(Settings.builder().put("xxx._id", "id1,blah").put("xxx.name", "blah,name2").build());
DiscoveryNodeFilters filters = buildFromSettings(OR, "xxx.", settings);
final Version version = Version.CURRENT;
DiscoveryNode node = new DiscoveryNode("name1", "id1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), version);
assertThat(filters.match(node), equalTo(true));
node = new DiscoveryNode("name2", "id2", buildNewFakeTransportAddress(), emptyMap(), emptySet(), version);
assertThat(filters.match(node), equalTo(true));
node = new DiscoveryNode("name3", "id3", buildNewFakeTransportAddress(), emptyMap(), emptySet(), version);
assertThat(filters.match(node), equalTo(false));
}
use of org.opensearch.Version in project OpenSearch by opensearch-project.
the class MetadataIndexUpgradeServiceTests method testIsUpgraded.
public void testIsUpgraded() {
MetadataIndexUpgradeService service = getMetadataIndexUpgradeService();
IndexMetadata src = newIndexMeta("foo", Settings.builder().put("index.refresh_interval", "-200").build());
assertFalse(service.isUpgraded(src));
Version version = VersionUtils.randomVersionBetween(random(), VersionUtils.getFirstVersion(), VersionUtils.getPreviousVersion());
src = newIndexMeta("foo", Settings.builder().put(IndexMetadata.SETTING_VERSION_UPGRADED, version).build());
assertFalse(service.isUpgraded(src));
src = newIndexMeta("foo", Settings.builder().put(IndexMetadata.SETTING_VERSION_UPGRADED, Version.CURRENT).build());
assertTrue(service.isUpgraded(src));
}
Aggregations