Skip to content

Commit 5fcef40

Browse files
ES|QL: fix generative tests (#126107)
Manage envs where source field mapping is not supported
1 parent edc5379 commit 5fcef40

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/GenerativeIT.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ public class GenerativeIT extends GenerativeRestTest {
3434
protected String getTestRestCluster() {
3535
return cluster.getHttpAddresses();
3636
}
37+
38+
@Override
39+
protected boolean supportsSourceFieldMapping() {
40+
return cluster.getNumNodes() == 1;
41+
}
3742
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private static String grok(List<Column> previousOutput) {
164164
} else {
165165
String fieldName = randomRawName(previousOutput);
166166
if (fieldName.isEmpty()) { // it's a bug, managed later, skipping for now
167-
randomAlphaOfLength(5);
167+
fieldName = randomAlphaOfLength(5);
168168
}
169169
result.append(fieldName);
170170
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ public abstract class GenerativeRestTest extends ESRestTestCase {
6767
@Before
6868
public void setup() throws IOException {
6969
if (indexExists(CSV_DATASET_MAP.keySet().iterator().next()) == false) {
70-
loadDataSetIntoEs(client(), true, true);
70+
loadDataSetIntoEs(client(), true, supportsSourceFieldMapping());
7171
}
7272
}
7373

74+
protected abstract boolean supportsSourceFieldMapping();
75+
7476
@AfterClass
7577
public static void wipeTestData() throws IOException {
7678
try {

0 commit comments

Comments
 (0)