use of org.sonar.server.es.newindex.SettingsConfiguration in project sonarqube by SonarSource.
the class IndexDefinitionHashTest method hash_changes_if_refreshInterval_changes.
@Test
public void hash_changes_if_refreshInterval_changes() {
Index index = Index.simple("foo");
IndexMainType mainType = IndexMainType.main(index, "bar");
Configuration emptySettings = new MapSettings().asConfig();
SettingsConfiguration defaultRefreshInterval = SettingsConfiguration.newBuilder(emptySettings).build();
SettingsConfiguration noRefreshInterval = SettingsConfiguration.newBuilder(emptySettings).setRefreshInterval(-1).build();
SettingsConfiguration refreshInterval30 = SettingsConfiguration.newBuilder(emptySettings).setRefreshInterval(30).build();
SettingsConfiguration someRefreshInterval = SettingsConfiguration.newBuilder(emptySettings).setRefreshInterval(56).build();
assertThat(hashOf(new TestNewIndex(mainType, defaultRefreshInterval))).isEqualTo(hashOf(new TestNewIndex(mainType, defaultRefreshInterval))).isEqualTo(hashOf(new TestNewIndex(mainType, refreshInterval30))).isNotEqualTo(hashOf(new TestNewIndex(mainType, noRefreshInterval))).isNotEqualTo(hashOf(new TestNewIndex(mainType, someRefreshInterval)));
assertThat(hashOf(new TestNewIndex(mainType, noRefreshInterval))).isNotEqualTo(hashOf(new TestNewIndex(mainType, someRefreshInterval)));
}
use of org.sonar.server.es.newindex.SettingsConfiguration in project sonarqube by SonarSource.
the class IndexDefinitionHashTest method computeAndVerifyAllDifferentHashesOnMapping.
@SafeVarargs
private final void computeAndVerifyAllDifferentHashesOnMapping(IndexMainType mainType, Consumer<TypeMapping>... fieldTypes) {
List<TestNewIndex> mainIndices = Arrays.stream(fieldTypes).map(consumer -> {
TestNewIndex mainTypeMapping = new TestNewIndex(mainType, settingsConfiguration);
consumer.accept(mainTypeMapping.getMainTypeMapping());
return mainTypeMapping;
}).collect(toList());
List<TestNewIndex> relationIndices = Arrays.stream(fieldTypes).map(consumer -> {
TestNewIndex relationTypeMapping = new TestNewIndex(mainType, settingsConfiguration);
consumer.accept(relationTypeMapping.createRelationMapping("donut"));
return relationTypeMapping;
}).collect(toList());
Set<String> mainHashes = mainIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet());
Set<String> relationHashes = relationIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet());
assertThat(mainHashes).isEqualTo(mainIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet())).doesNotContainAnyElementsOf(relationHashes).hasSize(fieldTypes.length);
assertThat(relationHashes).isEqualTo(relationIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet())).doesNotContainAnyElementsOf(mainHashes).hasSize(fieldTypes.length);
}
use of org.sonar.server.es.newindex.SettingsConfiguration in project sonarqube by SonarSource.
the class IndexDefinitionHashTest method computeAndVerifyAllSameHashesOnMapping.
@SafeVarargs
private final void computeAndVerifyAllSameHashesOnMapping(IndexMainType mainType, Consumer<TypeMapping>... fieldTypes) {
List<Consumer<TypeMapping>> fieldTypes1 = Arrays.asList(fieldTypes);
List<TestNewIndex> mainIndices = fieldTypes1.stream().map(consumer -> {
TestNewIndex mainTypeMapping = new TestNewIndex(mainType, settingsConfiguration);
consumer.accept(mainTypeMapping.getMainTypeMapping());
return mainTypeMapping;
}).collect(toList());
List<TestNewIndex> relationIndices = fieldTypes1.stream().map(consumer -> {
TestNewIndex relationTypeMapping = new TestNewIndex(mainType, settingsConfiguration);
consumer.accept(relationTypeMapping.createRelationMapping("donut"));
return relationTypeMapping;
}).collect(toList());
Set<String> mainHashes = mainIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet());
Set<String> relationHashes = relationIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet());
assertThat(mainHashes).isEqualTo(mainIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet())).doesNotContainAnyElementsOf(relationHashes).hasSize(1);
assertThat(relationHashes).isEqualTo(relationIndices.stream().map(IndexDefinitionHashTest::hashOf).collect(toSet())).doesNotContainAnyElementsOf(mainHashes).hasSize(1);
}
use of org.sonar.server.es.newindex.SettingsConfiguration in project sonarqube by SonarSource.
the class IndexDefinitionHashTest method hash_changes_if_number_of_shards_changes.
@Test
public void hash_changes_if_number_of_shards_changes() {
Index index = Index.simple("foo");
IndexMainType mainType = IndexMainType.main(index, "bar");
Configuration emptySettings = new MapSettings().asConfig();
SettingsConfiguration defaultNbOfShards = SettingsConfiguration.newBuilder(emptySettings).build();
SettingsConfiguration specifiedDefaultNbOfShards = SettingsConfiguration.newBuilder(emptySettings).setDefaultNbOfShards(5).build();
SettingsConfiguration specifyDefaultNbOfShards = SettingsConfiguration.newBuilder(new MapSettings().setProperty("sonar.search." + index.getName() + ".shards", 1).asConfig()).setDefaultNbOfShards(1).build();
SettingsConfiguration specifiedNbOfShards = SettingsConfiguration.newBuilder(new MapSettings().setProperty("sonar.search." + index.getName() + ".shards", 10).asConfig()).setDefaultNbOfShards(5).build();
assertThat(hashOf(new TestNewIndex(mainType, defaultNbOfShards))).isEqualTo(hashOf(new TestNewIndex(mainType, defaultNbOfShards))).isEqualTo(hashOf(new TestNewIndex(mainType, specifyDefaultNbOfShards))).isNotEqualTo(hashOf(new TestNewIndex(mainType, specifiedDefaultNbOfShards))).isNotEqualTo(hashOf(new TestNewIndex(mainType, specifiedNbOfShards)));
assertThat(hashOf(new TestNewIndex(mainType, specifiedDefaultNbOfShards))).isEqualTo(hashOf(new TestNewIndex(mainType, specifiedDefaultNbOfShards))).isNotEqualTo(hashOf(new TestNewIndex(mainType, specifyDefaultNbOfShards)));
}
Aggregations