Skip to content

Commit 97aa468

Browse files
committed
ESQL: Rework FieldExtractorIT's pragmas
This reworks the way `FieldExtractorIT` requests fields to be loaded. Previously it used pragmas and would skip itself if it wasn't a unit test. This removes that behavior and sends pragmas but also sends the `accept_pragma_risks` option which is used in production releases to allow pragmas - it's especially useful for testing. This *should* make the tests more consistent. Closes #127100
1 parent 1234f97 commit 97aa468

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
1111

1212
import org.apache.http.util.EntityUtils;
13-
import org.elasticsearch.Build;
1413
import org.elasticsearch.Version;
1514
import org.elasticsearch.client.Request;
1615
import org.elasticsearch.client.Response;
@@ -34,7 +33,6 @@
3433
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
3534
import org.elasticsearch.xpack.esql.plugin.QueryPragmas;
3635
import org.hamcrest.Matcher;
37-
import org.junit.Before;
3836

3937
import java.io.IOException;
4038
import java.math.BigDecimal;
@@ -80,17 +78,6 @@ public static List<Object[]> args() throws Exception {
8078

8179
protected FieldExtractorTestCase(MappedFieldType.FieldExtractPreference preference) {
8280
this.preference = preference;
83-
if (preference != null) {
84-
assumeTrue("Requires pragma", Build.current().isSnapshot());
85-
}
86-
}
87-
88-
@Before
89-
public void notOld() {
90-
assumeTrue(
91-
"support changed pretty radically in 8.12 so we don't test against 8.11",
92-
getCachedNodesVersions().stream().allMatch(v -> Version.fromString(v).onOrAfter(Version.V_8_12_0))
93-
);
9481
}
9582

9683
public void testTextField() throws IOException {
@@ -1766,6 +1753,7 @@ private Map<String, Object> runEsql(String query) throws IOException {
17661753
request = request.pragmas(
17671754
Settings.builder().put(QueryPragmas.FIELD_EXTRACT_PREFERENCE.getKey(), preference.toString()).build()
17681755
);
1756+
request.pragmasOk();
17691757
}
17701758
return runEsqlSync(request);
17711759
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ public RequestObjectBuilder keepOnCompletion(boolean value) throws IOException {
178178
return this;
179179
}
180180

181+
/**
182+
* Allow sending pragmas even in non-snapshot builds.
183+
*/
184+
public RequestObjectBuilder pragmasOk() throws IOException {
185+
builder.field("accept_pragma_risks", true);
186+
return this;
187+
}
188+
181189
Boolean keepOnCompletion() {
182190
return keepOnCompletion;
183191
}

0 commit comments

Comments
 (0)