Skip to content

Commit 9739c28

Browse files
fix setting maximum number of tests to run
1 parent 4dcb691 commit 9739c28

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/SemanticTextIndexVersionIT.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import java.util.Locale;
4242
import java.util.Map;
4343
import java.util.Set;
44-
import java.util.function.Function;
4544
import java.util.stream.Collectors;
4645

4746
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
@@ -52,7 +51,6 @@
5251

5352
public class SemanticTextIndexVersionIT extends ESIntegTestCase {
5453
private static final IndexVersion SEMANTIC_TEXT_INTRODUCED_VERSION = IndexVersion.fromId(8512000);
55-
private static final double PERCENTAGE_TO_TEST = 0.5;
5654
private static final int MAXIMUM_NUMBER_OF_VERSIONS_TO_TEST = 25;
5755
private static final String SPARSE_SEMANTIC_FIELD = "sparse_field";
5856
private static final String DENSE_SEMANTIC_FIELD = "dense_field";
@@ -76,17 +74,7 @@ public void setup() throws Exception {
7674
.filter(indexVersion -> indexVersion.after(SEMANTIC_TEXT_INTRODUCED_VERSION))
7775
.collect(Collectors.toSet());
7876

79-
Function<Set<IndexVersion>, Integer> determineNumberOfVersionsToTest = versions -> {
80-
int totalVersions = versions.size();
81-
int percentageTestSize = (int) Math.ceil(totalVersions * PERCENTAGE_TO_TEST);
82-
83-
return totalVersions < MAXIMUM_NUMBER_OF_VERSIONS_TO_TEST
84-
? totalVersions
85-
: Math.min(percentageTestSize, MAXIMUM_NUMBER_OF_VERSIONS_TO_TEST);
86-
};
87-
88-
int versionsCount = determineNumberOfVersionsToTest.apply(availableVersions);
89-
selectedVersions = randomSubsetOf(versionsCount, availableVersions);
77+
selectedVersions = randomSubsetOf(Math.min(availableVersions.size(), MAXIMUM_NUMBER_OF_VERSIONS_TO_TEST), availableVersions);
9078
}
9179

9280
@Override
@@ -163,8 +151,9 @@ public void testSemanticText() throws Exception {
163151
ensureGreen(indexName);
164152

165153
// Semantic search with sparse embedding
166-
SearchSourceBuilder sparseSourceBuilder = new SearchSourceBuilder().query(new SemanticQueryBuilder(SPARSE_SEMANTIC_FIELD, "inference"))
167-
.trackTotalHits(true);
154+
SearchSourceBuilder sparseSourceBuilder = new SearchSourceBuilder().query(
155+
new SemanticQueryBuilder(SPARSE_SEMANTIC_FIELD, "inference")
156+
).trackTotalHits(true);
168157

169158
assertResponse(
170159
client().search(new SearchRequest(indexName).source(sparseSourceBuilder)),
@@ -182,8 +171,9 @@ public void testSemanticText() throws Exception {
182171
});
183172

184173
// Semantic search with text embedding
185-
SearchSourceBuilder textSourceBuilder = new SearchSourceBuilder().query(new SemanticQueryBuilder(DENSE_SEMANTIC_FIELD, "inference"))
186-
.trackTotalHits(true);
174+
SearchSourceBuilder textSourceBuilder = new SearchSourceBuilder().query(
175+
new SemanticQueryBuilder(DENSE_SEMANTIC_FIELD, "inference")
176+
).trackTotalHits(true);
187177

188178
assertResponse(
189179
client().search(new SearchRequest(indexName).source(textSourceBuilder)),

0 commit comments

Comments
 (0)