Skip to content

Commit 0b4273a

Browse files
authored
Merge branch 'main' into bootstrap-entitlements-for-testing
2 parents 5ef8233 + 9e19b85 commit 0b4273a

File tree

20 files changed

+209
-281
lines changed

20 files changed

+209
-281
lines changed

muted-tests.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,15 @@ 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
577+
- class: org.elasticsearch.snapshots.GetSnapshotsIT
578+
method: testFilterByState
579+
issue: https://github.com/elastic/elasticsearch/issues/129740
571580

572581
# Examples:
573582
#

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/TransportVersions.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ static TransportVersion def(int id) {
244244
public static final TransportVersion RESCORE_VECTOR_ALLOW_ZERO = def(9_039_0_00);
245245
public static final TransportVersion PROJECT_ID_IN_SNAPSHOT = def(9_040_0_00);
246246
public static final TransportVersion INDEX_STATS_AND_METADATA_INCLUDE_PEAK_WRITE_LOAD = def(9_041_0_00);
247-
public static final TransportVersion REPOSITORIES_METADATA_AS_PROJECT_CUSTOM = def(9_042_0_00);
248247
public static final TransportVersion BATCHED_QUERY_PHASE_VERSION = def(9_043_0_00);
249248
public static final TransportVersion REMOTE_EXCEPTION = def(9_044_0_00);
250249
public static final TransportVersion ESQL_REMOVE_AGGREGATE_TYPE = def(9_045_0_00);

server/src/main/java/org/elasticsearch/action/bulk/IncrementalBulkService.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import org.elasticsearch.core.Releasables;
2323
import org.elasticsearch.core.TimeValue;
2424
import org.elasticsearch.index.IndexingPressure;
25+
import org.elasticsearch.telemetry.metric.LongHistogram;
26+
import org.elasticsearch.telemetry.metric.MeterRegistry;
2527

2628
import java.util.ArrayList;
2729
import java.util.Collections;
@@ -33,6 +35,7 @@
3335
import static org.elasticsearch.common.settings.Setting.boolSetting;
3436

3537
public class IncrementalBulkService {
38+
public static final String CHUNK_WAIT_TIME_HISTOGRAM_NAME = "es.rest.incremental_bulk.wait_for_next_chunk.duration.histogram";
3639

3740
public static final Setting<Boolean> INCREMENTAL_BULK = boolSetting(
3841
"rest.incremental_bulk",
@@ -44,9 +47,17 @@ public class IncrementalBulkService {
4447
private final AtomicBoolean enabledForTests = new AtomicBoolean(true);
4548
private final IndexingPressure indexingPressure;
4649

47-
public IncrementalBulkService(Client client, IndexingPressure indexingPressure) {
50+
/* Capture in milliseconds because the APM histogram only has a range of 100,000 */
51+
private final LongHistogram chunkWaitTimeMillisHistogram;
52+
53+
public IncrementalBulkService(Client client, IndexingPressure indexingPressure, MeterRegistry meterRegistry) {
4854
this.client = client;
4955
this.indexingPressure = indexingPressure;
56+
this.chunkWaitTimeMillisHistogram = meterRegistry.registerLongHistogram(
57+
CHUNK_WAIT_TIME_HISTOGRAM_NAME,
58+
"Total time in millis spent waiting for next chunk of a bulk request",
59+
"ms"
60+
);
5061
}
5162

5263
public Handler newBulkRequest() {
@@ -56,7 +67,7 @@ public Handler newBulkRequest() {
5667

5768
public Handler newBulkRequest(@Nullable String waitForActiveShards, @Nullable TimeValue timeout, @Nullable String refresh) {
5869
ensureEnabled();
59-
return new Handler(client, indexingPressure, waitForActiveShards, timeout, refresh);
70+
return new Handler(client, indexingPressure, waitForActiveShards, timeout, refresh, chunkWaitTimeMillisHistogram);
6071
}
6172

6273
private void ensureEnabled() {
@@ -99,6 +110,8 @@ public static class Handler implements Releasable {
99110
private final ArrayList<Releasable> releasables = new ArrayList<>(4);
100111
private final ArrayList<BulkResponse> responses = new ArrayList<>(2);
101112
private final IndexingPressure.Incremental incrementalOperation;
113+
// Ideally this should be in RestBulkAction, but it's harder to inject the metric registry there
114+
private final LongHistogram chunkWaitTimeMillisHistogram;
102115
private boolean closed = false;
103116
private boolean globalFailure = false;
104117
private boolean incrementalRequestSubmitted = false;
@@ -111,20 +124,26 @@ protected Handler(
111124
IndexingPressure indexingPressure,
112125
@Nullable String waitForActiveShards,
113126
@Nullable TimeValue timeout,
114-
@Nullable String refresh
127+
@Nullable String refresh,
128+
LongHistogram chunkWaitTimeMillisHistogram
115129
) {
116130
this.client = client;
117131
this.waitForActiveShards = waitForActiveShards != null ? ActiveShardCount.parseString(waitForActiveShards) : null;
118132
this.timeout = timeout;
119133
this.refresh = refresh;
120134
this.incrementalOperation = indexingPressure.startIncrementalCoordinating(0, 0, false);
135+
this.chunkWaitTimeMillisHistogram = chunkWaitTimeMillisHistogram;
121136
createNewBulkRequest(EMPTY_STATE);
122137
}
123138

124139
public IndexingPressure.Incremental getIncrementalOperation() {
125140
return incrementalOperation;
126141
}
127142

143+
public void updateWaitForChunkMetrics(long chunkWaitTimeInMillis) {
144+
chunkWaitTimeMillisHistogram.record(chunkWaitTimeInMillis);
145+
}
146+
128147
public void addItems(List<DocWriteRequest<?>> items, Releasable releasable, Runnable nextItems) {
129148
assert closed == false;
130149
assert bulkInProgress == false;

0 commit comments

Comments
 (0)