Skip to content

Commit

Permalink
HSEARCH-5218 Disable range aggregation tests for OpenSearch 2.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Aug 9, 2024
1 parent 3c337f4 commit 6a946c2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,16 @@ public Optional<Comparator<? super Object>> rawValueEqualsComparator(FieldTypeDe
public boolean normalizesStringArgumentToPrefixPredicateForAnalyzedStringField() {
return false;
}

@Override
public boolean rangeAggregationsDoNotIgnoreQuery() {
// See https://github.com/opensearch-project/OpenSearch/issues/15169
// There is a problem with OpenSearch 2.16.0 where query is ignored for a range aggregation,
// leading to routes, being ignored and incorrect counts produced in the results:
return isActualVersion(
es -> true,
os -> os.isLessThan( "2.16.0" ),
aoss -> false
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -26,6 +27,7 @@
import org.hibernate.search.integrationtest.backend.tck.testsupport.operations.expectations.UnsupportedSingleFieldAggregationExpectations;
import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ExpectationsAlternative;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TypeAssertionHelper;
import org.hibernate.search.util.common.data.Range;
import org.hibernate.search.util.impl.integrationtest.common.NormalizationUtils;
Expand Down Expand Up @@ -129,6 +131,10 @@ public AggregationScenario<?> onMultiValuedIndex() {

private <T> AggregationScenario<Map<Range<T>, Long>> doCreate(Map<Range<F>, Long> expectedResult,
TypeAssertionHelper<F, T> helper) {
assumeTrue(
TckConfiguration.get().getBackendFeatures().rangeAggregationsDoNotIgnoreQuery()
);

return new AggregationScenario<Map<Range<T>, Long>>() {
@Override
public AggregationFinalStep<Map<Range<T>, Long>> setup(SearchAggregationFactory factory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,8 @@ public Optional<Comparator<? super Object>> rawValueEqualsComparator(FieldTypeDe
public boolean normalizesStringArgumentToPrefixPredicateForAnalyzedStringField() {
return true;
}

public boolean rangeAggregationsDoNotIgnoreQuery() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import static org.hibernate.search.integrationtest.showcase.library.service.TestDataService.SUBURBAN_2_ID;
import static org.hibernate.search.integrationtest.showcase.library.service.TestDataService.THESAURUS_OF_LANGUAGES_ID;
import static org.hibernate.search.integrationtest.showcase.library.service.TestDataService.UNIVERSITY_ID;
import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.dialect.ElasticsearchTestDialect.isActualVersion;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -462,6 +464,15 @@ void searchAndProjectToMethodLocalClass() {

@Test
void searchFaceted() {
assumeTrue(
TestActiveProfilesResolver.isLucene()
|| isActualVersion(
es -> true,
// See https://github.com/opensearch-project/OpenSearch/issues/15169
os -> os.isLessThan( "2.16.0" ),
aoss -> false
)
);
LibraryFacetedSearchResult result = libraryService.searchFaceted(
null, null, null,
0, 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ public String[] resolve(Class<?> testClass) {
public static String configuredBackend() {
return System.getProperty( "test.backend", DEFAULT_BACKEND );
}

public static boolean isLucene() {
return DEFAULT_BACKEND.equals( configuredBackend() );
}
}

0 comments on commit 6a946c2

Please sign in to comment.