Skip to content

Commit 3fee6af

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 623bd7b + b1fb31e commit 3fee6af

File tree

62 files changed

+1269
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1269
-295
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/testfixtures/TestFixturesPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void apply(Project project) {
122122
composeExtension.getRemoveContainers().set(true);
123123
composeExtension.getCaptureContainersOutput()
124124
.set(EnumSet.of(LogLevel.INFO, LogLevel.DEBUG).contains(project.getGradle().getStartParameter().getLogLevel()));
125-
composeExtension.getUseDockerComposeV2().set(true);
125+
composeExtension.getUseDockerComposeV2().set(false);
126126
composeExtension.getExecutable().set(this.providerFactory.provider(() -> {
127127
String composePath = dockerSupport.get().getDockerAvailability().dockerComposePath();
128128
LOGGER.debug("Docker Compose path: {}", composePath);

docs/changelog/120207.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 120207
2+
summary: Make `requests_per_second` configurable to throttle reindexing
3+
area: Data streams
4+
type: enhancement
5+
issues: []

docs/changelog/120231.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 120231
2+
summary: Add sanity check to `ReindexDatastreamIndexAction`
3+
area: Data streams
4+
type: enhancement
5+
issues: []

qa/lucene-index-compatibility/src/javaRestTest/java/org/elasticsearch/lucene/AbstractIndexCompatibilityTestCase.java

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import org.apache.http.entity.InputStreamEntity;
1414
import org.elasticsearch.client.Request;
1515
import org.elasticsearch.cluster.metadata.IndexMetadata;
16+
import org.elasticsearch.common.Strings;
1617
import org.elasticsearch.common.settings.Settings;
17-
import org.elasticsearch.core.Strings;
1818
import org.elasticsearch.index.IndexSettings;
1919
import org.elasticsearch.index.mapper.MapperService;
2020
import org.elasticsearch.test.XContentTestUtils;
@@ -42,7 +42,9 @@
4242
import static org.elasticsearch.test.rest.ObjectPath.createFromResponse;
4343
import static org.hamcrest.Matchers.allOf;
4444
import static org.hamcrest.Matchers.equalTo;
45+
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
4546
import static org.hamcrest.Matchers.is;
47+
import static org.hamcrest.Matchers.lessThanOrEqualTo;
4648
import static org.hamcrest.Matchers.notNullValue;
4749

4850
public abstract class AbstractIndexCompatibilityTestCase extends ESRestTestCase {
@@ -156,8 +158,16 @@ protected static Version indexVersion(String indexName) throws Exception {
156158
return new Version((byte) ((id / 1000000) % 100), (byte) ((id / 10000) % 100), (byte) ((id / 100) % 100));
157159
}
158160

161+
protected static int getNumberOfReplicas(String indexName) throws Exception {
162+
var indexSettings = (Map<?, ?>) ((Map<?, ?>) getIndexSettings(indexName).get(indexName)).get("settings");
163+
var numberOfReplicas = Integer.parseInt((String) indexSettings.get(IndexMetadata.SETTING_NUMBER_OF_REPLICAS));
164+
assertThat(numberOfReplicas, allOf(greaterThanOrEqualTo(0), lessThanOrEqualTo(NODES - 1)));
165+
return numberOfReplicas;
166+
}
167+
159168
protected static void indexDocs(String indexName, int numDocs) throws Exception {
160169
var request = new Request("POST", "/_bulk");
170+
request.addParameter("refresh", "true");
161171
var docs = new StringBuilder();
162172
IntStream.range(0, numDocs).forEach(n -> docs.append(Strings.format("""
163173
{"index":{"_index":"%s"}}
@@ -185,19 +195,30 @@ protected static void mountIndex(String repository, String snapshot, String inde
185195
}
186196

187197
protected static void restoreIndex(String repository, String snapshot, String indexName, String renamedIndexName) throws Exception {
198+
restoreIndex(repository, snapshot, indexName, renamedIndexName, Settings.EMPTY);
199+
}
200+
201+
protected static void restoreIndex(
202+
String repository,
203+
String snapshot,
204+
String indexName,
205+
String renamedIndexName,
206+
Settings indexSettings
207+
) throws Exception {
188208
var request = new Request("POST", "/_snapshot/" + repository + "/" + snapshot + "/_restore");
189209
request.addParameter("wait_for_completion", "true");
190-
request.setJsonEntity(org.elasticsearch.common.Strings.format("""
210+
request.setJsonEntity(Strings.format("""
191211
{
192212
"indices": "%s",
193213
"include_global_state": false,
194214
"rename_pattern": "(.+)",
195215
"rename_replacement": "%s",
196-
"include_aliases": false
197-
}""", indexName, renamedIndexName));
216+
"include_aliases": false,
217+
"index_settings": %s
218+
}""", indexName, renamedIndexName, Strings.toString(indexSettings)));
198219
var responseBody = createFromResponse(client().performRequest(request));
199-
assertThat(responseBody.evaluate("snapshot.shards.total"), equalTo((int) responseBody.evaluate("snapshot.shards.failed")));
200-
assertThat(responseBody.evaluate("snapshot.shards.successful"), equalTo(0));
220+
assertThat(responseBody.evaluate("snapshot.shards.total"), equalTo((int) responseBody.evaluate("snapshot.shards.successful")));
221+
assertThat(responseBody.evaluate("snapshot.shards.failed"), equalTo(0));
201222
}
202223

203224
protected static void updateRandomIndexSettings(String indexName) throws IOException {
@@ -215,20 +236,19 @@ protected static void updateRandomIndexSettings(String indexName) throws IOExcep
215236
updateIndexSettings(indexName, settings);
216237
}
217238

218-
protected static void updateRandomMappings(String indexName) throws IOException {
239+
protected static void updateRandomMappings(String indexName) throws Exception {
219240
final var runtime = new HashMap<>();
220241
runtime.put("field_" + randomInt(2), Map.of("type", "keyword"));
221242
final var properties = new HashMap<>();
222243
properties.put(randomIdentifier(), Map.of("type", "long"));
223-
var body = XContentTestUtils.convertToXContent(Map.of("runtime", runtime, "properties", properties), XContentType.JSON);
244+
updateMappings(indexName, Map.of("runtime", runtime, "properties", properties));
245+
}
246+
247+
protected static void updateMappings(String indexName, Map<String, ?> mappings) throws Exception {
248+
var body = XContentTestUtils.convertToXContent(mappings, XContentType.JSON);
224249
var request = new Request("PUT", indexName + "/_mappings");
225250
request.setEntity(
226-
new InputStreamEntity(
227-
body.streamInput(),
228-
body.length(),
229-
230-
ContentType.create(XContentType.JSON.mediaTypeWithoutParameters())
231-
)
251+
new InputStreamEntity(body.streamInput(), body.length(), ContentType.create(XContentType.JSON.mediaTypeWithoutParameters()))
232252
);
233253
assertOK(client().performRequest(request));
234254
}
@@ -238,4 +258,14 @@ protected static boolean isIndexClosed(String indexName) throws Exception {
238258
var state = responseBody.evaluate("metadata.indices." + indexName + ".state");
239259
return IndexMetadata.State.fromString((String) state) == IndexMetadata.State.CLOSE;
240260
}
261+
262+
protected static void addIndexWriteBlock(String indexName) throws Exception {
263+
assertAcknowledged(client().performRequest(new Request("PUT", Strings.format("/%s/_block/write", indexName))));
264+
}
265+
266+
protected static void forceMerge(String indexName, int maxNumSegments) throws Exception {
267+
var request = new Request("POST", '/' + indexName + "/_forcemerge");
268+
request.addParameter("max_num_segments", String.valueOf(maxNumSegments));
269+
assertOK(client().performRequest(request));
270+
}
241271
}

0 commit comments

Comments
 (0)