Search in sources :

Example 1 with IndexMainType

use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.

the class AuthorizationScope method getAuthorizationIndexType.

/**
 * @return the identifier of the ElasticSearch type (including it's index name), that corresponds to a certain document type
 */
private static IndexMainType getAuthorizationIndexType(IndexRelationType functionalType) {
    requireNonNull(functionalType);
    IndexMainType mainType = functionalType.getMainType();
    checkArgument(TYPE_AUTHORIZATION.equals(mainType.getType()), "Index %s doesn't seem to be an authorized index as main type is not %s (got %s)", mainType.getIndex(), TYPE_AUTHORIZATION, mainType.getType());
    return mainType;
}
Also used : IndexMainType(org.sonar.server.es.IndexType.IndexMainType)

Example 2 with IndexMainType

use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.

the class IndexDefinitionHashTest method hash_is_the_same_if_only_order_of_textFieldBuilder_options_change.

@Test
public void hash_is_the_same_if_only_order_of_textFieldBuilder_options_change() {
    Index index = Index.withRelations("foo");
    IndexMainType mainType = IndexMainType.main(index, "bar");
    String fieldName = "field1";
    computeAndVerifyAllSameHashesOnMapping(mainType, (mapping) -> mapping.textFieldBuilder(fieldName).disableSearch().disableNorms().build(), (mapping) -> mapping.textFieldBuilder(fieldName).disableNorms().disableSearch().build());
}
Also used : TestNewIndex(org.sonar.server.es.newindex.TestNewIndex) IndexMainType(org.sonar.server.es.IndexType.IndexMainType) Test(org.junit.Test)

Example 3 with IndexMainType

use of org.sonar.server.es.IndexType.IndexMainType 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)));
}
Also used : SettingsConfiguration(org.sonar.server.es.newindex.SettingsConfiguration) Configuration(org.sonar.api.config.Configuration) MapSettings(org.sonar.api.config.internal.MapSettings) SettingsConfiguration(org.sonar.server.es.newindex.SettingsConfiguration) TestNewIndex(org.sonar.server.es.newindex.TestNewIndex) IndexMainType(org.sonar.server.es.IndexType.IndexMainType) TestNewIndex(org.sonar.server.es.newindex.TestNewIndex) Test(org.junit.Test)

Example 4 with IndexMainType

use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.

the class IndexDefinitionHashTest method hash_is_the_same_if_only_relations_order_changes.

@Test
public void hash_is_the_same_if_only_relations_order_changes() {
    Index index = Index.withRelations("foo");
    IndexMainType mainType = IndexMainType.main(index, "bar");
    TestNewIndex indexTwoRelations = new TestNewIndex(mainType, settingsConfiguration).addRelation("donut1").addRelation("donut2").addRelation("donut3");
    TestNewIndex indexTwoRelationsOtherOrder = new TestNewIndex(mainType, settingsConfiguration).addRelation("donut2").addRelation("donut1").addRelation("donut3");
    TestNewIndex indexTwoRelationsOtherOrder2 = new TestNewIndex(mainType, settingsConfiguration).addRelation("donut2").addRelation("donut3").addRelation("donut1");
    assertThat(hashOf(indexTwoRelations)).isEqualTo(hashOf(indexTwoRelationsOtherOrder)).isEqualTo(hashOf(indexTwoRelationsOtherOrder2));
}
Also used : TestNewIndex(org.sonar.server.es.newindex.TestNewIndex) IndexMainType(org.sonar.server.es.IndexType.IndexMainType) TestNewIndex(org.sonar.server.es.newindex.TestNewIndex) Test(org.junit.Test)

Example 5 with IndexMainType

use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.

the class IndexDefinitionHashTest method hash_is_the_same_if_only_order_of_keyword_options_change.

@Test
public void hash_is_the_same_if_only_order_of_keyword_options_change() {
    Index index = Index.withRelations("foo");
    IndexMainType mainType = IndexMainType.main(index, "bar");
    String fieldName = "field1";
    computeAndVerifyAllSameHashesOnMapping(mainType, (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSortingAndAggregating().disableNorms().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableNorms().disableSortingAndAggregating().build());
    computeAndVerifyAllSameHashesOnMapping(mainType, (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSortingAndAggregating().disableSearch().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSearch().disableSortingAndAggregating().build());
    computeAndVerifyAllSameHashesOnMapping(mainType, (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSearch().disableNorms().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableNorms().disableSearch().build());
    computeAndVerifyAllSameHashesOnMapping(mainType, (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSortingAndAggregating().disableSearch().disableNorms().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSearch().disableNorms().disableSortingAndAggregating().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableNorms().disableSearch().disableSortingAndAggregating().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableNorms().disableSortingAndAggregating().disableSearch().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSearch().disableSortingAndAggregating().disableNorms().build());
}
Also used : TestNewIndex(org.sonar.server.es.newindex.TestNewIndex) IndexMainType(org.sonar.server.es.IndexType.IndexMainType) Test(org.junit.Test)

Aggregations

IndexMainType (org.sonar.server.es.IndexType.IndexMainType)31 Test (org.junit.Test)27 TestNewIndex (org.sonar.server.es.newindex.TestNewIndex)15 MapSettings (org.sonar.api.config.internal.MapSettings)6 SimpleIndexMainType (org.sonar.server.es.IndexType.SimpleIndexMainType)6 Configuration (org.sonar.api.config.Configuration)4 SettingsConfiguration (org.sonar.server.es.newindex.SettingsConfiguration)4 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)3 IndexRelationType (org.sonar.server.es.IndexType.IndexRelationType)3 Arrays (java.util.Arrays)2 List (java.util.List)2 Set (java.util.Set)2 Consumer (java.util.function.Consumer)2 Collectors.toList (java.util.stream.Collectors.toList)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 CLUSTER_ENABLED (org.sonar.process.ProcessProperties.Property.CLUSTER_ENABLED)2 Index (org.sonar.server.es.Index)2 TypeMapping (org.sonar.server.es.newindex.TypeMapping)2 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)1