Skip to content

Commit 07b69d9

Browse files
authored
Merge branch 'main' into tests/fix-129713
2 parents 1d1eea0 + 1d913f3 commit 07b69d9

File tree

11 files changed

+170
-21
lines changed

11 files changed

+170
-21
lines changed

muted-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,6 @@ tests:
448448
- class: org.elasticsearch.xpack.search.CrossClusterAsyncSearchIT
449449
method: testCCSClusterDetailsWhereAllShardsSkippedInCanMatch
450450
issue: https://github.com/elastic/elasticsearch/issues/128418
451-
- class: org.elasticsearch.xpack.esql.action.ForkIT
452-
method: testProfile
453-
issue: https://github.com/elastic/elasticsearch/issues/128377
454451
- class: org.elasticsearch.xpack.esql.action.CrossClusterQueryWithFiltersIT
455452
method: testTimestampFilterFromQuery
456453
issue: https://github.com/elastic/elasticsearch/issues/127332
@@ -568,6 +565,9 @@ tests:
568565
- class: org.elasticsearch.snapshots.SnapshotShutdownIT
569566
method: testSnapshotShutdownProgressTracker
570567
issue: https://github.com/elastic/elasticsearch/issues/129752
568+
- class: org.elasticsearch.xpack.security.SecurityRolesMultiProjectIT
569+
method: testUpdatingFileBasedRoleAffectsAllProjects
570+
issue: https://github.com/elastic/elasticsearch/issues/129775
571571

572572
# Examples:
573573
#

qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/CcsCommonYamlTestSuiteIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ public class CcsCommonYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
9090
// geohex_grid requires gold license
9191
.setting("xpack.license.self_generated.type", "trial")
9292
.feature(FeatureFlag.TIME_SERIES_MODE)
93-
.feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED);
93+
.feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED)
94+
.feature(FeatureFlag.IVF_FORMAT);
9495

9596
private static ElasticsearchCluster remoteCluster = ElasticsearchCluster.local()
9697
.name(REMOTE_CLUSTER_NAME)

qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public class RcsCcsCommonYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
9292
.setting("xpack.security.remote_cluster_client.ssl.enabled", "false")
9393
.feature(FeatureFlag.TIME_SERIES_MODE)
9494
.feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED)
95+
.feature(FeatureFlag.IVF_FORMAT)
9596
.user("test_admin", "x-pack-test-password");
9697

9798
private static ElasticsearchCluster fulfillingCluster = ElasticsearchCluster.local()

server/src/main/java/org/elasticsearch/index/engine/Engine.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@ public ShardFieldStats shardFieldStats() {
262262
}
263263
}
264264

265+
/**
266+
* @throws AlreadyClosedException if the shard is closed
267+
*/
268+
public FieldInfos shardFieldInfos() {
269+
try (var searcher = acquireSearcher("field_has_value")) {
270+
return FieldInfos.getMergedFieldInfos(searcher.getIndexReader());
271+
}
272+
}
273+
265274
protected static ShardFieldStats shardFieldStats(List<LeafReaderContext> leaves) {
266275
int numSegments = 0;
267276
int totalFields = 0;
@@ -2407,6 +2416,13 @@ public final EngineConfig getEngineConfig() {
24072416
return engineConfig;
24082417
}
24092418

2419+
public static SeqNoStats buildSeqNoStats(EngineConfig config, SegmentInfos infos) {
2420+
final SequenceNumbers.CommitInfo seqNoStats = SequenceNumbers.loadSeqNoInfoFromLuceneCommit(infos.userData.entrySet());
2421+
long maxSeqNo = seqNoStats.maxSeqNo();
2422+
long localCheckpoint = seqNoStats.localCheckpoint();
2423+
return new SeqNoStats(maxSeqNo, localCheckpoint, config.getGlobalCheckpointSupplier().getAsLong());
2424+
}
2425+
24102426
/**
24112427
* Allows registering a listener for when the index shard is on a segment generation >= minGeneration.
24122428
*

server/src/main/java/org/elasticsearch/index/engine/ReadOnlyEngine.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,6 @@ protected void closeNoLock(String reason, CountDownLatch closedLatch) {
243243
}
244244
}
245245

246-
private static SeqNoStats buildSeqNoStats(EngineConfig config, SegmentInfos infos) {
247-
final SequenceNumbers.CommitInfo seqNoStats = SequenceNumbers.loadSeqNoInfoFromLuceneCommit(infos.userData.entrySet());
248-
long maxSeqNo = seqNoStats.maxSeqNo();
249-
long localCheckpoint = seqNoStats.localCheckpoint();
250-
return new SeqNoStats(maxSeqNo, localCheckpoint, config.getGlobalCheckpointSupplier().getAsLong());
251-
}
252-
253246
private static TranslogStats translogStats(final EngineConfig config, final SegmentInfos infos) throws IOException {
254247
assert config.getTranslogConfig().hasTranslog();
255248
final String translogUuid = infos.getUserData().get(Translog.TRANSLOG_UUID_KEY);

server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4308,9 +4308,9 @@ public void afterRefresh(boolean didRefresh) {
43084308
}
43094309

43104310
private FieldInfos loadFieldInfos() {
4311-
try (Engine.Searcher hasValueSearcher = getEngine().acquireSearcher("field_has_value")) {
4312-
return FieldInfos.getMergedFieldInfos(hasValueSearcher.getIndexReader());
4313-
} catch (AlreadyClosedException ignore) {
4311+
try {
4312+
return getEngine().shardFieldInfos();
4313+
} catch (AlreadyClosedException ignored) {
43144314
// engine is closed - no update to FieldInfos is fine
43154315
}
43164316
return FieldInfos.EMPTY;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.xpack.esql.qa.multi_node;
9+
10+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
11+
12+
import org.elasticsearch.test.TestClustersThreadFilter;
13+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
14+
import org.elasticsearch.xpack.esql.qa.rest.generative.GenerativeRestTest;
15+
import org.junit.ClassRule;
16+
17+
/**
18+
* This test generates random queries, runs them against the CSV test dataset and checks that they don't throw unexpected exceptions.
19+
*
20+
* If muted, please:
21+
* <ul>
22+
* <li>see the error message reported in the failure and the corresponding query (it's in the logs right before the error)</li>
23+
* <li>update the corresponding issue with the query (if there is no issue for that failure yet, create one)</li>
24+
* <li>add a pattern that matches the error message to {@link GenerativeRestTest#ALLOWED_ERRORS}; also link the issue</li>
25+
* <li>unmute (and possibly check that the test doesn't fail anymore)</li>
26+
* </ul>
27+
*/
28+
@ThreadLeakFilters(filters = TestClustersThreadFilter.class)
29+
public class GenerativeIT extends GenerativeRestTest {
30+
@ClassRule
31+
public static ElasticsearchCluster cluster = Clusters.testCluster(spec -> spec.plugin("inference-service-test"));
32+
33+
@Override
34+
protected String getTestRestCluster() {
35+
return cluster.getHttpAddresses();
36+
}
37+
38+
@Override
39+
protected boolean supportsSourceFieldMapping() {
40+
return false;
41+
}
42+
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.elasticsearch.xpack.esql.CsvTestsDataLoader;
1111
import org.elasticsearch.xpack.esql.qa.rest.generative.command.CommandGenerator;
12+
import org.elasticsearch.xpack.esql.qa.rest.generative.command.pipe.ChangePointGenerator;
1213
import org.elasticsearch.xpack.esql.qa.rest.generative.command.pipe.DissectGenerator;
1314
import org.elasticsearch.xpack.esql.qa.rest.generative.command.pipe.DropGenerator;
1415
import org.elasticsearch.xpack.esql.qa.rest.generative.command.pipe.EnrichGenerator;
@@ -49,6 +50,7 @@ public record QueryExecuted(String query, int depth, List<Column> outputSchema,
4950
* These are downstream commands, ie. that cannot appear as the first command in a query
5051
*/
5152
static List<CommandGenerator> PIPE_COMMANDS = List.of(
53+
ChangePointGenerator.INSTANCE,
5254
DissectGenerator.INSTANCE,
5355
DropGenerator.INSTANCE,
5456
EnrichGenerator.INSTANCE,
@@ -197,6 +199,10 @@ public static String randomNumericOrDateField(List<Column> previousOutput) {
197199
return randomName(previousOutput, Set.of("long", "integer", "double", "date"));
198200
}
199201

202+
public static String randomDateField(List<Column> previousOutput) {
203+
return randomName(previousOutput, Set.of("date"));
204+
}
205+
200206
public static String randomNumericField(List<Column> previousOutput) {
201207
return randomName(previousOutput, Set.of("long", "integer", "double"));
202208
}
@@ -255,6 +261,22 @@ public static String constantExpression() {
255261

256262
}
257263

264+
/**
265+
* returns a random identifier or one of the existing names
266+
*/
267+
public static String randomAttributeOrIdentifier(List<EsqlQueryGenerator.Column> previousOutput) {
268+
String name;
269+
if (randomBoolean()) {
270+
name = EsqlQueryGenerator.randomIdentifier();
271+
} else {
272+
name = EsqlQueryGenerator.randomName(previousOutput);
273+
if (name == null) {
274+
name = EsqlQueryGenerator.randomIdentifier();
275+
}
276+
}
277+
return name;
278+
}
279+
258280
public static String randomIdentifier() {
259281
// Let's create identifiers that are long enough to avoid collisions with reserved keywords.
260282
// There could be a smarter way (introspection on the lexer class?), but probably it's not worth the effort

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.elasticsearch.client.Request;
1111
import org.elasticsearch.client.ResponseException;
1212
import org.elasticsearch.test.rest.ESRestTestCase;
13+
import org.elasticsearch.xpack.esql.AssertWarnings;
1314
import org.elasticsearch.xpack.esql.CsvTestsDataLoader;
1415
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase;
1516
import org.elasticsearch.xpack.esql.qa.rest.generative.command.CommandGenerator;
@@ -44,10 +45,6 @@ public abstract class GenerativeRestTest extends ESRestTestCase {
4445
"The field names are too complex to process", // field_caps problem
4546
"must be \\[any type except counter types\\]", // TODO refine the generation of count()
4647

47-
// warnings
48-
"Field '.*' shadowed by field at line .*",
49-
"evaluation of \\[.*\\] failed, treating result as null", // TODO investigate?
50-
5148
// Awaiting fixes for query failure
5249
"Unknown column \\[<all-fields-projected>\\]", // https://github.com/elastic/elasticsearch/issues/121741,
5350
"Plan \\[ProjectExec\\[\\[<no-fields>.* optimized incorrectly due to missing references", // https://github.com/elastic/elasticsearch/issues/125866
@@ -99,10 +96,10 @@ public void test() throws IOException {
9996
EsqlQueryGenerator.QueryExecuted result = execute(command, 0);
10097
if (result.exception() != null) {
10198
checkException(result);
102-
break;
99+
continue;
103100
}
104101
if (checkResults(List.of(), commandGenerator, desc, null, result).success() == false) {
105-
break;
102+
continue;
106103
}
107104
previousResult = result;
108105
previousCommands.add(desc);
@@ -168,7 +165,11 @@ private void checkException(EsqlQueryGenerator.QueryExecuted query) {
168165
@SuppressWarnings("unchecked")
169166
private EsqlQueryGenerator.QueryExecuted execute(String command, int depth) {
170167
try {
171-
Map<String, Object> a = RestEsqlTestCase.runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query(command).build());
168+
Map<String, Object> a = RestEsqlTestCase.runEsql(
169+
new RestEsqlTestCase.RequestObjectBuilder().query(command).build(),
170+
new AssertWarnings.AllowedRegexes(List.of(Pattern.compile(".*"))),// we don't care about warnings
171+
RestEsqlTestCase.Mode.SYNC
172+
);
172173
List<EsqlQueryGenerator.Column> outputSchema = outputSchema(a);
173174
List<List<Object>> values = (List<List<Object>>) a.get("values");
174175
return new EsqlQueryGenerator.QueryExecuted(command, depth, outputSchema, values, null);

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,22 @@ static ValidationResult expectSameColumns(List<EsqlQueryGenerator.Column> previo
139139

140140
return VALIDATION_OK;
141141
}
142+
143+
/**
144+
* The command doesn't have to produce LESS columns than the previous query
145+
*/
146+
static ValidationResult expectAtLeastSameNumberOfColumns(
147+
List<EsqlQueryGenerator.Column> previousColumns,
148+
List<EsqlQueryGenerator.Column> columns
149+
) {
150+
if (previousColumns.stream().anyMatch(x -> x.name().contains("<all-fields-projected>"))) {
151+
return VALIDATION_OK; // known bug
152+
}
153+
154+
if (previousColumns.size() > columns.size()) {
155+
return new ValidationResult(false, "Expecting at least [" + previousColumns.size() + "] columns, got [" + columns.size() + "]");
156+
}
157+
158+
return VALIDATION_OK;
159+
}
142160
}

0 commit comments

Comments
 (0)