Skip to content

Commit 275cc30

Browse files
authored
Merge branch 'main' into markjhoy/add_sparse_vector_token_pruning_index_options
2 parents 434a4a6 + 4ce06d1 commit 275cc30

File tree

9 files changed

+109
-7
lines changed

9 files changed

+109
-7
lines changed

muted-tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,12 @@ tests:
568568
- class: org.elasticsearch.search.query.RescoreKnnVectorQueryIT
569569
method: testKnnSearchRescore
570570
issue: https://github.com/elastic/elasticsearch/issues/129713
571+
- class: org.elasticsearch.streams.StreamsYamlTestSuiteIT
572+
method: test {yaml=streams/logs/10_basic/Basic toggle of logs state enable to disable and back}
573+
issue: https://github.com/elastic/elasticsearch/issues/129733
574+
- class: org.elasticsearch.streams.StreamsYamlTestSuiteIT
575+
method: test {yaml=streams/logs/10_basic/Check for repeated toggle to same state}
576+
issue: https://github.com/elastic/elasticsearch/issues/129735
571577

572578
# Examples:
573579
#

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/TsdbIndexingRollingUpgradeIT.java

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,24 @@
1212
import com.carrotsearch.randomizedtesting.annotations.Name;
1313

1414
import org.elasticsearch.client.Request;
15+
import org.elasticsearch.client.Response;
16+
import org.elasticsearch.client.ResponseException;
17+
import org.elasticsearch.client.RestClient;
1518
import org.elasticsearch.common.network.NetworkAddress;
19+
import org.elasticsearch.common.xcontent.XContentHelper;
1620
import org.elasticsearch.test.rest.ObjectPath;
21+
import org.elasticsearch.xcontent.XContentType;
1722

23+
import java.io.IOException;
24+
import java.io.InputStream;
1825
import java.time.Instant;
26+
import java.util.List;
1927
import java.util.Locale;
2028
import java.util.Map;
2129

22-
import static org.elasticsearch.upgrades.LogsIndexModeRollingUpgradeIT.getWriteBackingIndex;
23-
import static org.elasticsearch.upgrades.LogsdbIndexingRollingUpgradeIT.createTemplate;
24-
import static org.elasticsearch.upgrades.LogsdbIndexingRollingUpgradeIT.getIndexSettingsWithDefaults;
25-
import static org.elasticsearch.upgrades.LogsdbIndexingRollingUpgradeIT.startTrial;
2630
import static org.elasticsearch.upgrades.TsdbIT.TEMPLATE;
2731
import static org.elasticsearch.upgrades.TsdbIT.formatInstant;
32+
import static org.hamcrest.Matchers.containsString;
2833
import static org.hamcrest.Matchers.equalTo;
2934
import static org.hamcrest.Matchers.greaterThan;
3035
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
@@ -194,4 +199,51 @@ void query(String dataStreamName) throws Exception {
194199
assertThat(maxTx, notNullValue());
195200
}
196201

202+
protected static void startTrial() throws IOException {
203+
Request startTrial = new Request("POST", "/_license/start_trial");
204+
startTrial.addParameter("acknowledge", "true");
205+
try {
206+
assertOK(client().performRequest(startTrial));
207+
} catch (ResponseException e) {
208+
var responseBody = entityAsMap(e.getResponse());
209+
String error = ObjectPath.evaluate(responseBody, "error_message");
210+
assertThat(error, containsString("Trial was already activated."));
211+
}
212+
}
213+
214+
static Map<String, Object> getIndexSettingsWithDefaults(String index) throws IOException {
215+
Request request = new Request("GET", "/" + index + "/_settings");
216+
request.addParameter("flat_settings", "true");
217+
request.addParameter("include_defaults", "true");
218+
Response response = client().performRequest(request);
219+
try (InputStream is = response.getEntity().getContent()) {
220+
return XContentHelper.convertToMap(
221+
XContentType.fromMediaType(response.getEntity().getContentType().getValue()).xContent(),
222+
is,
223+
true
224+
);
225+
}
226+
}
227+
228+
static void createTemplate(String dataStreamName, String id, String template) throws IOException {
229+
final String INDEX_TEMPLATE = """
230+
{
231+
"index_patterns": ["$DATASTREAM"],
232+
"template": $TEMPLATE,
233+
"data_stream": {
234+
}
235+
}""";
236+
var putIndexTemplateRequest = new Request("POST", "/_index_template/" + id);
237+
putIndexTemplateRequest.setJsonEntity(INDEX_TEMPLATE.replace("$TEMPLATE", template).replace("$DATASTREAM", dataStreamName));
238+
assertOK(client().performRequest(putIndexTemplateRequest));
239+
}
240+
241+
@SuppressWarnings("unchecked")
242+
static String getWriteBackingIndex(final RestClient client, final String dataStreamName, int backingIndex) throws IOException {
243+
final Request request = new Request("GET", "_data_stream/" + dataStreamName);
244+
final List<Object> dataStreams = (List<Object>) entityAsMap(client.performRequest(request)).get("data_streams");
245+
final Map<String, Object> dataStream = (Map<String, Object>) dataStreams.get(0);
246+
final List<Map<String, String>> backingIndices = (List<Map<String, String>>) dataStream.get("indices");
247+
return backingIndices.get(backingIndex).get("index_name");
248+
}
197249
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
import org.elasticsearch.index.seqno.SequenceNumbers;
9595
import org.elasticsearch.index.shard.ShardId;
9696
import org.elasticsearch.index.shard.ShardLongFieldRange;
97+
import org.elasticsearch.index.shard.ShardSplittingQuery;
9798
import org.elasticsearch.index.store.Store;
9899
import org.elasticsearch.index.translog.Translog;
99100
import org.elasticsearch.index.translog.TranslogConfig;
@@ -3610,4 +3611,9 @@ protected long estimateMergeBytes(MergePolicy.OneMerge merge) {
36103611
return 0L;
36113612
}
36123613
}
3614+
3615+
// Used to clean up unowned documents. Client-visible deletes should always be soft deletes.
3616+
protected void deleteByQuery(ShardSplittingQuery query) throws Exception {
3617+
indexWriter.deleteDocuments(query);
3618+
}
36133619
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
* It can be used to split a shard into N shards marking every document that doesn't belong into the shard
5353
* as deleted. See {@link org.apache.lucene.index.IndexWriter#deleteDocuments(Query...)}
5454
*/
55-
final class ShardSplittingQuery extends Query {
55+
public final class ShardSplittingQuery extends Query {
5656
private final IndexMetadata indexMetadata;
5757
private final IndexRouting indexRouting;
5858
private final int shardId;
5959
private final BitSetProducer nestedParentBitSetProducer;
6060

61-
ShardSplittingQuery(IndexMetadata indexMetadata, int shardId, boolean hasNested) {
61+
public ShardSplittingQuery(IndexMetadata indexMetadata, int shardId, boolean hasNested) {
6262
this.indexMetadata = indexMetadata;
6363
this.indexRouting = IndexRouting.fromIndexMetadata(indexMetadata);
6464
this.shardId = shardId;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
8+
9+
apply plugin: 'elasticsearch.internal-java-rest-test'
10+
apply plugin: 'elasticsearch.internal-test-artifact-base'
11+
apply plugin: 'elasticsearch.bwc-test'
12+
apply plugin: 'elasticsearch.fwc-test'
13+
apply plugin: 'elasticsearch.bc-upgrade-test'
14+
15+
dependencies {
16+
javaRestTestImplementation project(xpackModule('logsdb'))
17+
javaRestTestImplementation project(':test:test-clusters')
18+
javaRestTestImplementation testArtifact(project(':qa:rolling-upgrade'), 'javaRestTest')
19+
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
20+
javaRestTestImplementation(testArtifact(project(xpackModule('security'))))
21+
}
22+
23+
buildParams.bwcVersions.withWireCompatible { bwcVersion, baseName ->
24+
tasks.register(bwcTaskName(bwcVersion), StandaloneRestIntegTestTask) {
25+
usesBwcDistribution(bwcVersion)
26+
systemProperty("tests.old_cluster_version", bwcVersion)
27+
}
28+
}
29+
30+
tasks.withType(Test).configureEach {
31+
// CI doesn't like it when there's multiple clusters running at once
32+
maxParallelForks = 1
33+
}

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/LogsdbIndexingRollingUpgradeIT.java renamed to x-pack/plugin/logsdb/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/LogsdbIndexingRollingUpgradeIT.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import org.elasticsearch.client.Response;
1616
import org.elasticsearch.client.ResponseException;
1717
import org.elasticsearch.common.network.NetworkAddress;
18+
import org.elasticsearch.common.time.DateFormatter;
19+
import org.elasticsearch.common.time.FormatNames;
1820
import org.elasticsearch.common.xcontent.XContentHelper;
1921
import org.elasticsearch.test.rest.ObjectPath;
2022
import org.elasticsearch.xcontent.XContentType;
@@ -28,7 +30,6 @@
2830

2931
import static org.elasticsearch.upgrades.LogsIndexModeRollingUpgradeIT.enableLogsdbByDefault;
3032
import static org.elasticsearch.upgrades.LogsIndexModeRollingUpgradeIT.getWriteBackingIndex;
31-
import static org.elasticsearch.upgrades.TsdbIT.formatInstant;
3233
import static org.hamcrest.Matchers.containsString;
3334
import static org.hamcrest.Matchers.equalTo;
3435
import static org.hamcrest.Matchers.greaterThan;
@@ -265,4 +266,8 @@ static Map<String, Object> getIndexSettingsWithDefaults(String index) throws IOE
265266
}
266267
}
267268

269+
static String formatInstant(Instant instant) {
270+
return DateFormatter.forPattern(FormatNames.STRICT_DATE_OPTIONAL_TIME.getName()).format(instant);
271+
}
272+
268273
}

0 commit comments

Comments
 (0)