Skip to content

Commit b044858

Browse files
authored
Merge branch 'main' into fix/merge_non_empty_results
2 parents 055eada + 62636f9 commit b044858

File tree

48 files changed

+1086
-194
lines changed

Some content is hidden

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

48 files changed

+1086
-194
lines changed

docs/changelog/126009.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126009
2+
summary: Change ModelLoaderUtils.split to return the correct number of chunks and ranges.
3+
area: Machine Learning
4+
type: bug
5+
issues:
6+
- 121799

docs/changelog/126493.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126493
2+
summary: Bedrock Cohere Task Settings Support
3+
area: Machine Learning
4+
type: enhancement
5+
issues:
6+
- 126156

docs/changelog/126550.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126550
2+
summary: Add leniency to missing array values in mustache
3+
area: Infra/Scripting
4+
type: bug
5+
issues:
6+
- 55200

modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/CustomReflectionObjectHandler.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ public Object get(Object key) {
111111
if ("size".equals(key)) {
112112
return size();
113113
} else if (key instanceof Number number) {
114-
return Array.get(array, number.intValue());
114+
return number.intValue() >= 0 && number.intValue() < length ? Array.get(array, number.intValue()) : null;
115115
}
116116
try {
117117
int index = Integer.parseInt(key.toString());
118-
return Array.get(array, index);
118+
return index >= 0 && index < length ? Array.get(array, index) : null;
119119
} catch (NumberFormatException nfe) {
120120
// if it's not a number it is as if the key doesn't exist
121121
return null;
@@ -169,11 +169,11 @@ public Object get(Object key) {
169169
if ("size".equals(key)) {
170170
return col.size();
171171
} else if (key instanceof Number number) {
172-
return Iterables.get(col, number.intValue());
172+
return number.intValue() >= 0 && number.intValue() < col.size() ? Iterables.get(col, number.intValue()) : null;
173173
}
174174
try {
175175
int index = Integer.parseInt(key.toString());
176-
return Iterables.get(col, index);
176+
return index >= 0 && index < col.size() ? Iterables.get(col, index) : null;
177177
} catch (NumberFormatException nfe) {
178178
// if it's not a number it is as if the key doesn't exist
179179
return null;

modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,26 @@ public void testMapInArrayAccess() throws Exception {
141141
assertThat(output, both(containsString("foo")).and(containsString("bar")));
142142
}
143143

144+
public void testMapInArrayBadAccess() throws Exception {
145+
String template = "{{data.0.key}} {{data.2.key}}";
146+
TemplateScript.Factory factory = engine.compile(null, template, TemplateScript.CONTEXT, Collections.emptyMap());
147+
Map<String, Object> vars = new HashMap<>();
148+
vars.put("data", new Object[] { singletonMap("key", "foo"), singletonMap("key", "bar") });
149+
// assertThat(factory.newInstance(vars).execute(), equalTo("foo "));
150+
151+
vars.put("data", Arrays.asList(singletonMap("key", "foo"), singletonMap("key", "bar")));
152+
factory.newInstance(vars);
153+
assertThat(factory.newInstance(vars).execute(), equalTo("foo "));
154+
155+
// HashSet iteration order isn't fixed
156+
Set<Object> setData = new HashSet<>();
157+
setData.add(singletonMap("key", "foo"));
158+
setData.add(singletonMap("key", "bar"));
159+
vars.put("data", setData);
160+
String output = factory.newInstance(vars).execute();
161+
assertThat(output, both(containsString("foo")).and(not(containsString("bar"))));
162+
}
163+
144164
public void testSizeAccessForCollectionsAndArrays() throws Exception {
145165
String[] randomArrayValues = generateRandomStringArray(10, 20, false);
146166
List<String> randomList = Arrays.asList(generateRandomStringArray(10, 20, false));

muted-tests.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,21 @@ tests:
423423
- class: org.elasticsearch.smoketest.MlWithSecurityIT
424424
method: test {yaml=ml/get_trained_model_stats/Test get stats given trained models}
425425
issue: https://github.com/elastic/elasticsearch/issues/126510
426+
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
427+
method: test {p0=transform/transforms_stats/Test get multiple transform stats}
428+
issue: https://github.com/elastic/elasticsearch/issues/126567
429+
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
430+
method: test {p0=transform/transforms_stats/Test get single transform stats when it does not have a task}
431+
issue: https://github.com/elastic/elasticsearch/issues/126568
432+
- class: org.elasticsearch.repositories.blobstore.testkit.rest.SnapshotRepoTestKitClientYamlTestSuiteIT
433+
method: test {p0=/10_analyze/Analysis without details}
434+
issue: https://github.com/elastic/elasticsearch/issues/126569
435+
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeIT
436+
method: test
437+
issue: https://github.com/elastic/elasticsearch/issues/126573
438+
- class: org.elasticsearch.repositories.blobstore.testkit.analyze.S3RepositoryAnalysisRestIT
439+
method: testRepositoryAnalysis
440+
issue: https://github.com/elastic/elasticsearch/issues/126576
426441

427442
# Examples:
428443
#

server/src/internalClusterTest/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ public void testDeletionOfFailingToRecoverIndexShouldStopRestore() throws Except
748748

749749
logger.info("--> wait for the index to appear");
750750
// that would mean that recovery process started and failing
751-
safeGet(clusterAdmin().prepareHealth(SAFE_AWAIT_TIMEOUT, "test-idx").execute());
751+
awaitIndexExists("test-idx");
752752

753753
logger.info("--> delete index");
754754
cluster().wipeIndices("test-idx");

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ static TransportVersion def(int id) {
157157
public static final TransportVersion INTRODUCE_LIFECYCLE_TEMPLATE_8_19 = def(8_841_0_14);
158158
public static final TransportVersion RERANK_COMMON_OPTIONS_ADDED_8_19 = def(8_841_0_15);
159159
public static final TransportVersion REMOTE_EXCEPTION_8_19 = def(8_841_0_16);
160+
public static final TransportVersion AMAZON_BEDROCK_TASK_SETTINGS_8_19 = def(8_841_0_17);
160161
public static final TransportVersion INITIAL_ELASTICSEARCH_9_0 = def(9_000_0_00);
161162
public static final TransportVersion REMOVE_SNAPSHOT_FAILURES_90 = def(9_000_0_01);
162163
public static final TransportVersion TRANSPORT_STATS_HANDLING_TIME_REQUIRED_90 = def(9_000_0_02);
@@ -215,6 +216,7 @@ static TransportVersion def(int id) {
215216
public static final TransportVersion ADD_PROJECT_ID_TO_DSL_ERROR_INFO = def(9_046_0_00);
216217
public static final TransportVersion SEMANTIC_TEXT_CHUNKING_CONFIG = def(9_047_00_0);
217218
public static final TransportVersion REPO_ANALYSIS_COPY_BLOB = def(9_048_00_0);
219+
public static final TransportVersion AMAZON_BEDROCK_TASK_SETTINGS = def(9_049_00_0);
218220

219221
/*
220222
* STOP! READ THIS FIRST! No, really,

test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@
226226
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
227227
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
228228
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
229+
import static org.hamcrest.CoreMatchers.not;
230+
import static org.hamcrest.Matchers.anEmptyMap;
229231
import static org.hamcrest.Matchers.empty;
230232
import static org.hamcrest.Matchers.equalTo;
231233
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
@@ -1731,6 +1733,31 @@ public static boolean indexExists(String index, Client client) {
17311733
return getIndexResponse.getIndices().length > 0;
17321734
}
17331735

1736+
public static void awaitIndexExists(String index) throws Exception {
1737+
awaitIndexExists(index, client());
1738+
}
1739+
1740+
public static void awaitIndexExists(String index, Client client) throws Exception {
1741+
if (Regex.isSimpleMatchPattern(index) || Metadata.ALL.equals(index)) {
1742+
assertBusy(() -> {
1743+
final var response = clusterHealthWithIndex(index, client);
1744+
assertThat(response.getIndices(), not(anEmptyMap()));
1745+
});
1746+
} else {
1747+
clusterHealthWithIndex(index, client);
1748+
}
1749+
}
1750+
1751+
private static ClusterHealthResponse clusterHealthWithIndex(String index, Client client) {
1752+
return safeGet(
1753+
client.admin()
1754+
.cluster()
1755+
.prepareHealth(SAFE_AWAIT_TIMEOUT, index)
1756+
.setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED)
1757+
.execute()
1758+
);
1759+
}
1760+
17341761
/**
17351762
* Syntactic sugar for enabling allocation for <code>indices</code>
17361763
*/

x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void testAutoFollow() throws Exception {
118118
createLeaderIndex("metrics-201901", leaderIndexSettings);
119119

120120
createLeaderIndex("logs-201901", leaderIndexSettings);
121-
assertLongBusy(() -> { assertTrue(ESIntegTestCase.indexExists("copy-logs-201901", followerClient())); });
121+
ESIntegTestCase.awaitIndexExists("copy-logs-201901", followerClient());
122122
createLeaderIndex("transactions-201901", leaderIndexSettings);
123123
assertLongBusy(() -> {
124124
AutoFollowStats autoFollowStats = getAutoFollowStats();

0 commit comments

Comments
 (0)