Skip to content

Commit e084062

Browse files
committed
Use Rest to check capability instead of constant.
1 parent a166961 commit e084062

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestRerankTestCase.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
package org.elasticsearch.xpack.esql.qa.rest;
99

10-
import org.elasticsearch.Build;
1110
import org.elasticsearch.client.Request;
1211
import org.elasticsearch.client.ResponseException;
1312
import org.elasticsearch.test.rest.ESRestTestCase;
13+
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1414
import org.junit.After;
1515
import org.junit.Before;
1616

@@ -24,6 +24,14 @@
2424

2525
public class RestRerankTestCase extends ESRestTestCase {
2626

27+
@Before
28+
public void skipWhenRerankDisabled() throws IOException {
29+
assumeTrue(
30+
"Requires RERANK capability",
31+
EsqlSpecTestCase.hasCapabilities(adminClient(), List.of(EsqlCapabilities.Cap.RERANK.capabilityName()))
32+
);
33+
}
34+
2735
@Before
2836
@After
2937
public void assertRequestBreakerEmpty() throws Exception {
@@ -77,8 +85,6 @@ public void wipeData() throws IOException {
7785
}
7886

7987
public void testRerankWithSingleField() throws IOException {
80-
assumeTrue("rerank capability not available", Build.current().isSnapshot());
81-
8288
String query = """
8389
FROM rerank-test-index
8490
| WHERE match(title, "exploration")
@@ -98,8 +104,6 @@ public void testRerankWithSingleField() throws IOException {
98104
}
99105

100106
public void testRerankWithMultipleFields() throws IOException {
101-
assumeTrue("rerank capability not available", Build.current().isSnapshot());
102-
103107
String query = """
104108
FROM rerank-test-index
105109
| WHERE match(title, "exploration")
@@ -119,8 +123,6 @@ public void testRerankWithMultipleFields() throws IOException {
119123
}
120124

121125
public void testRerankWithPositionalParams() throws IOException {
122-
assumeTrue("rerank capability not available", Build.current().isSnapshot());
123-
124126
String query = """
125127
FROM rerank-test-index
126128
| WHERE match(title, "exploration")
@@ -140,8 +142,6 @@ public void testRerankWithPositionalParams() throws IOException {
140142
}
141143

142144
public void testRerankWithNamedParams() throws IOException {
143-
assumeTrue("rerank capability not available", Build.current().isSnapshot());
144-
145145
String query = """
146146
FROM rerank-test-index
147147
| WHERE match(title, ?queryText)
@@ -161,8 +161,6 @@ public void testRerankWithNamedParams() throws IOException {
161161
}
162162

163163
public void testRerankWithMissingInferenceId() {
164-
assumeTrue("rerank capability not available", Build.current().isSnapshot());
165-
166164
String query = """
167165
FROM rerank-test-index
168166
| WHERE match(title, "exploration")

0 commit comments

Comments
 (0)