From 383b4e5041d20be48fc559774664015870b86be1 Mon Sep 17 00:00:00 2001
From: elasticsearchmachine
<58790826+elasticsearchmachine@users.noreply.github.com>
Date: Tue, 10 Sep 2024 02:21:21 +1000
Subject: [PATCH 01/31] Mute
org.elasticsearch.packaging.test.PackagesSecurityAutoConfigurationTests
test20SecurityNotAutoConfiguredOnReInstallation #112635
---
muted-tests.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/muted-tests.yml b/muted-tests.yml
index 6600ae65d5809..53570b3432721 100644
--- a/muted-tests.yml
+++ b/muted-tests.yml
@@ -204,6 +204,9 @@ tests:
- class: org.elasticsearch.xpack.security.authc.kerberos.KerberosTicketValidatorTests
method: testKerbTicketGeneratedForDifferentServerFailsValidation
issue: https://github.com/elastic/elasticsearch/issues/112639
+- class: org.elasticsearch.packaging.test.PackagesSecurityAutoConfigurationTests
+ method: test20SecurityNotAutoConfiguredOnReInstallation
+ issue: https://github.com/elastic/elasticsearch/issues/112635
# Examples:
#
From ef3a5a138530c43b8e6cd94585d13b853b819c57 Mon Sep 17 00:00:00 2001
From: Nik Everett
Date: Mon, 9 Sep 2024 12:32:19 -0400
Subject: [PATCH 02/31] ESQL: Fix CASE when conditions are multivalued
(#112401)
When CASE hits a multivalued field it was previously either crashing on
fold or evaluating it to the first value. Since booleans are loaded in
sorted order from lucene that *usually* means `false`. This changes the
behavior to line up with the rest of ESQL - now multivalued fields are
treated as `false` with a warning.
You might say "hey wait! multivalued fields usually become `null`, not
`false`!". Yes, dear reader, you are right. Very right. But! `CASE`'s
contract is to immediatly convert its values into `true` or `false`
using the standard boolean tri-valued logic. So `null` just become
`false` immediately. This is how PostgreSQL, MySQL, and SQLite behave:
```
> SELECT CASE WHEN null THEN 1 ELSE 2 END;
2
```
They turn that `null` into a false. And we're right there with them.
Except, of course, that we're turning `[false, false]` and the like into
`null` first. See!? It's consitent. Consistently confusing, but sane at
least.
The warning message just says "treating multivalued field as false"
rather than explaining all of that.
This also fixes up a few of CASE's docs which I noticed were kind of
busted while working on CASE. I think the docs generation is having a
lot of trouble with CASE so I've manually hacked the right thing into
place, but we should figure out a better solution eventually.
Closes #112359
---
docs/changelog/112401.yaml | 6 +
.../functions/kibana/definition/case.json | 370 ++++++-
.../esql/functions/parameters/case.asciidoc | 3 +
.../esql/functions/signature/case.svg | 2 +-
.../esql/functions/types/case.asciidoc | 41 +-
.../src/main/resources/conditional.csv-spec | 76 ++
.../src/main/resources/meta.csv-spec | 6 +-
.../xpack/esql/action/EsqlCapabilities.java | 5 +
.../esql/expression/function/Warnings.java | 49 +-
.../function/scalar/conditional/Case.java | 125 ++-
.../function/AbstractAggregationTestCase.java | 2 +
.../function/AbstractFunctionTestCase.java | 51 +-
.../AbstractScalarFunctionTestCase.java | 29 +-
.../expression/function/RailRoadDiagram.java | 30 +-
.../expression/function/TestCaseSupplier.java | 127 ++-
.../scalar/conditional/CaseExtraTests.java | 13 +
.../scalar/conditional/CaseTests.java | 913 +++++++++++++++---
.../test/esql/160_union_types.yml | 64 +-
18 files changed, 1646 insertions(+), 266 deletions(-)
create mode 100644 docs/changelog/112401.yaml
diff --git a/docs/changelog/112401.yaml b/docs/changelog/112401.yaml
new file mode 100644
index 0000000000000..65e9e76ac25f6
--- /dev/null
+++ b/docs/changelog/112401.yaml
@@ -0,0 +1,6 @@
+pr: 112401
+summary: "ESQL: Fix CASE when conditions are multivalued"
+area: ES|QL
+type: bug
+issues:
+ - 112359
diff --git a/docs/reference/esql/functions/kibana/definition/case.json b/docs/reference/esql/functions/kibana/definition/case.json
index 27705cd3897f9..ab10460f48b25 100644
--- a/docs/reference/esql/functions/kibana/definition/case.json
+++ b/docs/reference/esql/functions/kibana/definition/case.json
@@ -22,6 +22,30 @@
"variadic" : true,
"returnType" : "boolean"
},
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "boolean",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "boolean"
+ },
{
"params" : [
{
@@ -40,6 +64,90 @@
"variadic" : true,
"returnType" : "cartesian_point"
},
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "cartesian_point",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "cartesian_point",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "cartesian_point"
+ },
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "cartesian_shape",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "cartesian_shape"
+ },
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "cartesian_shape",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "cartesian_shape",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "cartesian_shape"
+ },
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "date",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "date"
+ },
{
"params" : [
{
@@ -53,6 +161,12 @@
"type" : "date",
"optional" : false,
"description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "date",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
}
],
"variadic" : true,
@@ -76,6 +190,30 @@
"variadic" : true,
"returnType" : "double"
},
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "double",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "double",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "double"
+ },
{
"params" : [
{
@@ -94,6 +232,90 @@
"variadic" : true,
"returnType" : "geo_point"
},
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "geo_point",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "geo_point",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "geo_point"
+ },
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "geo_shape",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "geo_shape"
+ },
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "geo_shape",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "geo_shape",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "geo_shape"
+ },
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "integer",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "integer"
+ },
{
"params" : [
{
@@ -107,6 +329,12 @@
"type" : "integer",
"optional" : false,
"description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "integer",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
}
],
"variadic" : true,
@@ -130,6 +358,30 @@
"variadic" : true,
"returnType" : "ip"
},
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "ip",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "ip",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "ip"
+ },
{
"params" : [
{
@@ -143,12 +395,30 @@
"type" : "keyword",
"optional" : false,
"description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "keyword"
+ },
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
},
{
- "name" : "falseValue",
+ "name" : "trueValue",
"type" : "keyword",
- "optional" : true,
+ "optional" : false,
"description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "keyword",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
}
],
"variadic" : true,
@@ -172,6 +442,30 @@
"variadic" : true,
"returnType" : "long"
},
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "long",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "long",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "long"
+ },
{
"params" : [
{
@@ -190,6 +484,48 @@
"variadic" : true,
"returnType" : "text"
},
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "text",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "text",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "text"
+ },
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "unsigned_long",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "unsigned_long"
+ },
{
"params" : [
{
@@ -203,6 +539,12 @@
"type" : "unsigned_long",
"optional" : false,
"description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "unsigned_long",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
}
],
"variadic" : true,
@@ -225,6 +567,30 @@
],
"variadic" : true,
"returnType" : "version"
+ },
+ {
+ "params" : [
+ {
+ "name" : "condition",
+ "type" : "boolean",
+ "optional" : false,
+ "description" : "A condition."
+ },
+ {
+ "name" : "trueValue",
+ "type" : "version",
+ "optional" : false,
+ "description" : "The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches."
+ },
+ {
+ "name" : "elseValue",
+ "type" : "version",
+ "optional" : true,
+ "description" : "The value that's returned when no condition evaluates to `true`."
+ }
+ ],
+ "variadic" : true,
+ "returnType" : "version"
}
],
"examples" : [
diff --git a/docs/reference/esql/functions/parameters/case.asciidoc b/docs/reference/esql/functions/parameters/case.asciidoc
index ee6f7e499b3b3..f12eade4d5780 100644
--- a/docs/reference/esql/functions/parameters/case.asciidoc
+++ b/docs/reference/esql/functions/parameters/case.asciidoc
@@ -7,3 +7,6 @@ A condition.
`trueValue`::
The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches.
+
+`elseValue`::
+The value that's returned when no condition evaluates to `true`.
diff --git a/docs/reference/esql/functions/signature/case.svg b/docs/reference/esql/functions/signature/case.svg
index d6fd7da38aca6..0d51a0647627d 100644
--- a/docs/reference/esql/functions/signature/case.svg
+++ b/docs/reference/esql/functions/signature/case.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/docs/reference/esql/functions/types/case.asciidoc b/docs/reference/esql/functions/types/case.asciidoc
index f6c8cfe9361d1..e8aa3eaf5daae 100644
--- a/docs/reference/esql/functions/types/case.asciidoc
+++ b/docs/reference/esql/functions/types/case.asciidoc
@@ -4,16 +4,33 @@
[%header.monospaced.styled,format=dsv,separator=|]
|===
-condition | trueValue | result
-boolean | boolean | boolean
-boolean | cartesian_point | cartesian_point
-boolean | date | date
-boolean | double | double
-boolean | geo_point | geo_point
-boolean | integer | integer
-boolean | ip | ip
-boolean | long | long
-boolean | text | text
-boolean | unsigned_long | unsigned_long
-boolean | version | version
+condition | trueValue | elseValue | result
+boolean | boolean | boolean | boolean
+boolean | boolean | | boolean
+boolean | cartesian_point | cartesian_point | cartesian_point
+boolean | cartesian_point | | cartesian_point
+boolean | cartesian_shape | cartesian_shape | cartesian_shape
+boolean | cartesian_shape | | cartesian_shape
+boolean | date | date | date
+boolean | date | | date
+boolean | double | double | double
+boolean | double | | double
+boolean | geo_point | geo_point | geo_point
+boolean | geo_point | | geo_point
+boolean | geo_shape | geo_shape | geo_shape
+boolean | geo_shape | | geo_shape
+boolean | integer | integer | integer
+boolean | integer | | integer
+boolean | ip | ip | ip
+boolean | ip | | ip
+boolean | keyword | keyword | keyword
+boolean | keyword | | keyword
+boolean | long | long | long
+boolean | long | | long
+boolean | text | text | text
+boolean | text | | text
+boolean | unsigned_long | unsigned_long | unsigned_long
+boolean | unsigned_long | | unsigned_long
+boolean | version | version | version
+boolean | version | | version
|===
diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/conditional.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/conditional.csv-spec
index d4b45ca37fc2d..996b2b5030d82 100644
--- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/conditional.csv-spec
+++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/conditional.csv-spec
@@ -94,6 +94,82 @@ M |10
M |10
;
+caseOnMv
+required_capability: case_mv
+
+FROM employees
+| WHERE emp_no == 10010
+| EVAL foo = CASE(still_hired, "still", is_rehired, "rehired", "not")
+| KEEP still_hired, is_rehired, foo;
+warning:Line 3:41: evaluation of [is_rehired] failed, treating result as false. Only first 20 failures recorded.
+warning:Line 3:41: java.lang.IllegalArgumentException: CASE expects a single-valued boolean
+
+still_hired:boolean | is_rehired:boolean | foo:keyword
+ false | [false, false, true, true] | not
+;
+
+caseOnConstantMvFalseTrue
+required_capability: case_mv
+
+ROW foo = CASE([false, true], "a", "b");
+warning:Line 1:16: evaluation of [[false, true]] failed, treating result as false. Only first 20 failures recorded.
+warning:Line 1:16: java.lang.IllegalArgumentException: CASE expects a single-valued boolean
+
+foo:keyword
+b
+;
+
+caseOnConstantMvTrueTrue
+required_capability: case_mv
+
+ROW foo = CASE([true, true], "a", "b");
+warning:Line 1:16: evaluation of [[true, true]] failed, treating result as false. Only first 20 failures recorded.
+warning:Line 1:16: java.lang.IllegalArgumentException: CASE expects a single-valued boolean
+
+foo:keyword
+b
+;
+
+caseOnMvSliceMv
+required_capability: case_mv
+
+ROW foo = [true, false, false] | EVAL foo = CASE(MV_SLICE(foo, 0, 1), "a", "b");
+warning:Line 1:50: evaluation of [MV_SLICE(foo, 0, 1)] failed, treating result as false. Only first 20 failures recorded.
+warning:Line 1:50: java.lang.IllegalArgumentException: CASE expects a single-valued boolean
+
+foo:keyword
+b
+;
+
+caseOnMvSliceSv
+required_capability: case_mv
+
+ROW foo = [true, false, false] | EVAL foo = CASE(MV_SLICE(foo, 0), "a", "b");
+
+foo:keyword
+a
+;
+
+caseOnConvertMvSliceMv
+required_capability: case_mv
+
+ROW foo = ["true", "false", "false"] | EVAL foo = CASE(MV_SLICE(foo::BOOLEAN, 0, 1), "a", "b");
+warning:Line 1:56: evaluation of [MV_SLICE(foo::BOOLEAN, 0, 1)] failed, treating result as false. Only first 20 failures recorded.
+warning:Line 1:56: java.lang.IllegalArgumentException: CASE expects a single-valued boolean
+
+foo:keyword
+b
+;
+
+caseOnConvertMvSliceSv
+required_capability: case_mv
+
+ROW foo = ["true", "false", "false"] | EVAL foo = CASE(MV_SLICE(foo::BOOLEAN, 0), "a", "b");
+
+foo:keyword
+a
+;
+
docsCaseSuccessRate
// tag::docsCaseSuccessRate[]
FROM sample_data
diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/meta.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/meta.csv-spec
index cd3ecfc367ddd..bc90f7f616631 100644
--- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/meta.csv-spec
+++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/meta.csv-spec
@@ -11,7 +11,7 @@ synopsis:keyword
"double avg(number:double|integer|long)"
"double|date bin(field:integer|long|double|date, buckets:integer|long|double|date_period|time_duration, ?from:integer|long|double|date|keyword|text, ?to:integer|long|double|date|keyword|text)"
"double|date bucket(field:integer|long|double|date, buckets:integer|long|double|date_period|time_duration, ?from:integer|long|double|date|keyword|text, ?to:integer|long|double|date|keyword|text)"
-"boolean|cartesian_point|date|double|geo_point|integer|ip|keyword|long|text|unsigned_long|version case(condition:boolean, trueValue...:boolean|cartesian_point|date|double|geo_point|integer|ip|keyword|long|text|unsigned_long|version)"
+"boolean|cartesian_point|cartesian_shape|date|date_nanos|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version case(condition:boolean, trueValue...:boolean|cartesian_point|cartesian_shape|date|date_nanos|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version)"
"double cbrt(number:double|integer|long|unsigned_long)"
"double|integer|long|unsigned_long ceil(number:double|integer|long|unsigned_long)"
"boolean cidr_match(ip:ip, blockX...:keyword|text)"
@@ -137,7 +137,7 @@ atan2 |[y_coordinate, x_coordinate] |["double|integer|long|unsign
avg |number |"double|integer|long" |[""]
bin |[field, buckets, from, to] |["integer|long|double|date", "integer|long|double|date_period|time_duration", "integer|long|double|date|keyword|text", "integer|long|double|date|keyword|text"] |[Numeric or date expression from which to derive buckets., Target number of buckets\, or desired bucket size if `from` and `to` parameters are omitted., Start of the range. Can be a number\, a date or a date expressed as a string., End of the range. Can be a number\, a date or a date expressed as a string.]
bucket |[field, buckets, from, to] |["integer|long|double|date", "integer|long|double|date_period|time_duration", "integer|long|double|date|keyword|text", "integer|long|double|date|keyword|text"] |[Numeric or date expression from which to derive buckets., Target number of buckets\, or desired bucket size if `from` and `to` parameters are omitted., Start of the range. Can be a number\, a date or a date expressed as a string., End of the range. Can be a number\, a date or a date expressed as a string.]
-case |[condition, trueValue] |[boolean, "boolean|cartesian_point|date|double|geo_point|integer|ip|keyword|long|text|unsigned_long|version"] |[A condition., The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches.]
+case |[condition, trueValue] |[boolean, "boolean|cartesian_point|cartesian_shape|date|date_nanos|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version"] |[A condition., The value that's returned when the corresponding condition is the first to evaluate to `true`. The default value is returned when no condition matches.]
cbrt |number |"double|integer|long|unsigned_long" |"Numeric expression. If `null`, the function returns `null`."
ceil |number |"double|integer|long|unsigned_long" |Numeric expression. If `null`, the function returns `null`.
cidr_match |[ip, blockX] |[ip, "keyword|text"] |[IP address of type `ip` (both IPv4 and IPv6 are supported)., CIDR block to test the IP against.]
@@ -391,7 +391,7 @@ atan2 |double
avg |double |false |false |true
bin |"double|date" |[false, false, true, true] |false |false
bucket |"double|date" |[false, false, true, true] |false |false
-case |"boolean|cartesian_point|date|double|geo_point|integer|ip|keyword|long|text|unsigned_long|version" |[false, false] |true |false
+case |"boolean|cartesian_point|cartesian_shape|date|date_nanos|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version" |[false, false] |true |false
cbrt |double |false |false |false
ceil |"double|integer|long|unsigned_long" |false |false |false
cidr_match |boolean |[false, false] |true |false
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
index 6e8d64edb6c86..858e2a3332bf8 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
@@ -97,6 +97,11 @@ public enum Cap {
*/
AGG_TOP_IP_SUPPORT,
+ /**
+ * {@code CASE} properly handling multivalue conditions.
+ */
+ CASE_MV,
+
/**
* Optimization for ST_CENTROID changed some results in cartesian data. #108713
*/
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/Warnings.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/Warnings.java
index 630cf62d0030a..87809ba536879 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/Warnings.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/Warnings.java
@@ -32,30 +32,53 @@ public void registerException(Exception exception) {
};
/**
- * Create a new warnings object based on the given mode
+ * Create a new warnings object based on the given mode which warns that
+ * it treats the result as {@code null}.
* @param warningsMode The warnings collection strategy to use
- * @param source used to indicate where in the query the warning occured
+ * @param source used to indicate where in the query the warning occurred
* @return A warnings collector object
*/
public static Warnings createWarnings(DriverContext.WarningsMode warningsMode, Source source) {
- switch (warningsMode) {
- case COLLECT -> {
- return new Warnings(source);
- }
- case IGNORE -> {
- return NOOP_WARNINGS;
- }
- }
- throw new IllegalStateException("Unreachable");
+ return createWarnings(warningsMode, source, "treating result as null");
+ }
+
+ /**
+ * Create a new warnings object based on the given mode which warns that
+ * it treats the result as {@code false}.
+ * @param warningsMode The warnings collection strategy to use
+ * @param source used to indicate where in the query the warning occurred
+ * @return A warnings collector object
+ */
+ public static Warnings createWarningsTreatedAsFalse(DriverContext.WarningsMode warningsMode, Source source) {
+ return createWarnings(warningsMode, source, "treating result as false");
+ }
+
+ /**
+ * Create a new warnings object based on the given mode
+ * @param warningsMode The warnings collection strategy to use
+ * @param source used to indicate where in the query the warning occurred
+ * @param first warning message attached to the first result
+ * @return A warnings collector object
+ */
+ public static Warnings createWarnings(DriverContext.WarningsMode warningsMode, Source source, String first) {
+ return switch (warningsMode) {
+ case COLLECT -> new Warnings(source, first);
+ case IGNORE -> NOOP_WARNINGS;
+ };
}
public Warnings(Source source) {
+ this(source, "treating result as null");
+ }
+
+ public Warnings(Source source, String first) {
location = format("Line {}:{}: ", source.source().getLineNumber(), source.source().getColumnNumber());
- first = format(
+ this.first = format(
null,
- "{}evaluation of [{}] failed, treating result as null. Only first {} failures recorded.",
+ "{}evaluation of [{}] failed, {}. Only first {} failures recorded.",
location,
source.text(),
+ first,
MAX_ADDED_WARNINGS
);
}
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java
index 3239afabf6a24..979f681a7fbd0 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java
@@ -11,6 +11,7 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BlockFactory;
import org.elasticsearch.compute.data.BooleanBlock;
import org.elasticsearch.compute.data.ElementType;
import org.elasticsearch.compute.data.Page;
@@ -29,6 +30,7 @@
import org.elasticsearch.xpack.esql.expression.function.Example;
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
import org.elasticsearch.xpack.esql.expression.function.Param;
+import org.elasticsearch.xpack.esql.expression.function.Warnings;
import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction;
import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
import org.elasticsearch.xpack.esql.planner.PlannerUtils;
@@ -46,7 +48,11 @@
public final class Case extends EsqlScalarFunction {
public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Case", Case::new);
- record Condition(Expression condition, Expression value) {}
+ record Condition(Expression condition, Expression value) {
+ ConditionEvaluatorSupplier toEvaluator(Function toEvaluator) {
+ return new ConditionEvaluatorSupplier(condition.source(), toEvaluator.apply(condition), toEvaluator.apply(value));
+ }
+ }
private final List conditions;
private final Expression elseValue;
@@ -56,9 +62,12 @@ record Condition(Expression condition, Expression value) {}
returnType = {
"boolean",
"cartesian_point",
+ "cartesian_shape",
"date",
+ "date_nanos",
"double",
"geo_point",
+ "geo_shape",
"integer",
"ip",
"keyword",
@@ -94,9 +103,12 @@ public Case(
type = {
"boolean",
"cartesian_point",
+ "cartesian_shape",
"date",
+ "date_nanos",
"double",
"geo_point",
+ "geo_shape",
"integer",
"ip",
"keyword",
@@ -215,25 +227,26 @@ public boolean foldable() {
if (condition.condition.foldable() == false) {
return false;
}
- Boolean b = (Boolean) condition.condition.fold();
- if (b != null && b) {
+ if (Boolean.TRUE.equals(condition.condition.fold())) {
+ /*
+ * `fold` can make four things here:
+ * 1. `TRUE`
+ * 2. `FALSE`
+ * 3. null
+ * 4. A list with more than one `TRUE` or `FALSE` in it.
+ *
+ * In the first case, we're foldable if the condition is foldable.
+ * The multivalued field will make a warning, but eventually
+ * become null. And null will become false. So cases 2-4 are
+ * the same. In those cases we are foldable only if the *rest*
+ * of the condition is foldable.
+ */
return condition.value.foldable();
}
}
return elseValue.foldable();
}
- @Override
- public Object fold() {
- for (Condition condition : conditions) {
- Boolean b = (Boolean) condition.condition.fold();
- if (b != null && b) {
- return condition.value.fold();
- }
- }
- return elseValue.fold();
- }
-
/**
* Fold the arms of {@code CASE} statements.
*
@@ -261,8 +274,20 @@ public Expression partiallyFold() {
continue;
}
modified = true;
- Boolean b = (Boolean) condition.condition.fold();
- if (b != null && b) {
+ if (Boolean.TRUE.equals(condition.condition.fold())) {
+ /*
+ * `fold` can make four things here:
+ * 1. `TRUE`
+ * 2. `FALSE`
+ * 3. null
+ * 4. A list with more than one `TRUE` or `FALSE` in it.
+ *
+ * In the first case, we fold to the value of the condition.
+ * The multivalued field will make a warning, but eventually
+ * become null. And null will become false. So cases 2-4 are
+ * the same. In those cases we fold the entire condition
+ * away, returning just what ever's remaining in the CASE.
+ */
newChildren.add(condition.value);
return finishPartialFold(newChildren);
}
@@ -277,24 +302,23 @@ public Expression partiallyFold() {
}
private Expression finishPartialFold(List newChildren) {
- if (newChildren.size() == 1) {
- return newChildren.get(0);
- }
- return replaceChildren(newChildren);
+ return switch (newChildren.size()) {
+ case 0 -> new Literal(source(), null, dataType());
+ case 1 -> newChildren.get(0);
+ default -> replaceChildren(newChildren);
+ };
}
@Override
public ExpressionEvaluator.Factory toEvaluator(Function toEvaluator) {
ElementType resultType = PlannerUtils.toElementType(dataType());
- List conditionsFactories = conditions.stream()
- .map(c -> new ConditionEvaluatorSupplier(toEvaluator.apply(c.condition), toEvaluator.apply(c.value)))
- .toList();
+ List conditionsFactories = conditions.stream().map(c -> c.toEvaluator(toEvaluator)).toList();
ExpressionEvaluator.Factory elseValueFactory = toEvaluator.apply(elseValue);
return new ExpressionEvaluator.Factory() {
@Override
public ExpressionEvaluator get(DriverContext context) {
return new CaseEvaluator(
- context,
+ context.blockFactory(),
resultType,
conditionsFactories.stream().map(x -> x.apply(context)).toList(),
elseValueFactory.get(context)
@@ -303,40 +327,58 @@ public ExpressionEvaluator get(DriverContext context) {
@Override
public String toString() {
- return "CaseEvaluator[resultType="
- + resultType
- + ", conditions="
- + conditionsFactories
- + ", elseVal="
- + elseValueFactory
- + ']';
+ return "CaseEvaluator[conditions=" + conditionsFactories + ", elseVal=" + elseValueFactory + ']';
}
};
}
- record ConditionEvaluatorSupplier(ExpressionEvaluator.Factory condition, ExpressionEvaluator.Factory value)
+ record ConditionEvaluatorSupplier(Source conditionSource, ExpressionEvaluator.Factory condition, ExpressionEvaluator.Factory value)
implements
Function {
@Override
public ConditionEvaluator apply(DriverContext driverContext) {
- return new ConditionEvaluator(condition.get(driverContext), value.get(driverContext));
+ return new ConditionEvaluator(
+ /*
+ * We treat failures as null just like any other failure.
+ * It's just that we then *immediately* convert it to
+ * true or false using the tri-valued boolean logic stuff.
+ * And that makes it into false. This is, *exactly* what
+ * happens in PostgreSQL and MySQL and SQLite:
+ * > SELECT CASE WHEN null THEN 1 ELSE 2 END;
+ * 2
+ * Rather than go into depth about this in the warning message,
+ * we just say "false".
+ */
+ Warnings.createWarningsTreatedAsFalse(driverContext.warningsMode(), conditionSource),
+ condition.get(driverContext),
+ value.get(driverContext)
+ );
}
@Override
public String toString() {
- return "ConditionEvaluator[" + "condition=" + condition + ", value=" + value + ']';
+ return "ConditionEvaluator[condition=" + condition + ", value=" + value + ']';
}
}
- record ConditionEvaluator(EvalOperator.ExpressionEvaluator condition, EvalOperator.ExpressionEvaluator value) implements Releasable {
+ record ConditionEvaluator(
+ Warnings conditionWarnings,
+ EvalOperator.ExpressionEvaluator condition,
+ EvalOperator.ExpressionEvaluator value
+ ) implements Releasable {
@Override
public void close() {
Releasables.closeExpectNoException(condition, value);
}
+
+ @Override
+ public String toString() {
+ return "ConditionEvaluator[condition=" + condition + ", value=" + value + ']';
+ }
}
private record CaseEvaluator(
- DriverContext driverContext,
+ BlockFactory blockFactory,
ElementType resultType,
List conditions,
EvalOperator.ExpressionEvaluator elseVal
@@ -353,10 +395,11 @@ public Block eval(Page page) {
* a time - but it's not at all fast.
*/
int positionCount = page.getPositionCount();
- try (Block.Builder result = resultType.newBlockBuilder(positionCount, driverContext.blockFactory())) {
+ try (Block.Builder result = resultType.newBlockBuilder(positionCount, blockFactory)) {
position: for (int p = 0; p < positionCount; p++) {
int[] positions = new int[] { p };
Page limited = new Page(
+ 1,
IntStream.range(0, page.getBlockCount()).mapToObj(b -> page.getBlock(b).filter(positions)).toArray(Block[]::new)
);
try (Releasable ignored = limited::releaseBlocks) {
@@ -365,6 +408,12 @@ public Block eval(Page page) {
if (b.isNull(0)) {
continue;
}
+ if (b.getValueCount(0) > 1) {
+ condition.conditionWarnings.registerException(
+ new IllegalArgumentException("CASE expects a single-valued boolean")
+ );
+ continue;
+ }
if (false == b.getBoolean(b.getFirstValueIndex(0))) {
continue;
}
@@ -390,7 +439,7 @@ public void close() {
@Override
public String toString() {
- return "CaseEvaluator[resultType=" + resultType + ", conditions=" + conditions + ", elseVal=" + elseVal + ']';
+ return "CaseEvaluator[conditions=" + conditions + ", elseVal=" + elseVal + ']';
}
}
}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAggregationTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAggregationTestCase.java
index 4e26baddd013b..54db9afa291ad 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAggregationTestCase.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAggregationTestCase.java
@@ -105,8 +105,10 @@ protected static List withNoRowsExpectingNull(List anyNullIsNull(
expectedType.expectedType(finalNullPosition, nulledData.type(), oc),
nullValue(),
null,
+ null,
oc.getExpectedTypeError(),
null,
+ null,
null
);
}));
@@ -246,8 +248,10 @@ protected static List anyNullIsNull(
expectedType.expectedType(finalNullPosition, DataType.NULL, oc),
nullValue(),
null,
+ null,
oc.getExpectedTypeError(),
null,
+ null,
null
);
}));
@@ -642,9 +646,11 @@ protected static List randomizeBytesRefsOffset(List args = description.args();
@@ -707,7 +711,7 @@ public static void testFunctionInfo() {
);
List> typesFromSignature = new ArrayList<>();
- Set returnFromSignature = new HashSet<>();
+ Set returnFromSignature = new TreeSet<>();
for (int i = 0; i < args.size(); i++) {
typesFromSignature.add(new HashSet<>());
}
@@ -828,6 +832,28 @@ public static void renderDocs() throws IOException {
FunctionDefinition definition = definition(name);
if (definition != null) {
EsqlFunctionRegistry.FunctionDescription description = EsqlFunctionRegistry.description(definition);
+ if (name.equals("case")) {
+ /*
+ * Hack the description, so we render a proper one for case.
+ */
+ // TODO build the description properly *somehow*
+ EsqlFunctionRegistry.ArgSignature trueValue = description.args().get(1);
+ EsqlFunctionRegistry.ArgSignature falseValue = new EsqlFunctionRegistry.ArgSignature(
+ "elseValue",
+ trueValue.type(),
+ "The value that's returned when no condition evaluates to `true`.",
+ true,
+ EsqlFunctionRegistry.getTargetType(trueValue.type())
+ );
+ description = new EsqlFunctionRegistry.FunctionDescription(
+ description.name(),
+ List.of(description.args().get(0), trueValue, falseValue),
+ description.returnType(),
+ description.description(),
+ description.variadic(),
+ description.isAggregation()
+ );
+ }
renderTypes(description.argNames());
renderParametersList(description.argNames(), description.argDescriptions());
FunctionInfo info = EsqlFunctionRegistry.functionInfo(definition);
@@ -836,22 +862,7 @@ public static void renderDocs() throws IOException {
boolean hasAppendix = renderAppendix(info.appendix());
renderFullLayout(name, info.preview(), hasExamples, hasAppendix);
renderKibanaInlineDocs(name, info);
- List args = description.args();
- if (name.equals("case")) {
- EsqlFunctionRegistry.ArgSignature falseValue = args.get(1);
- args = List.of(
- args.get(0),
- falseValue,
- new EsqlFunctionRegistry.ArgSignature(
- "falseValue",
- falseValue.type(),
- falseValue.description(),
- true,
- EsqlFunctionRegistry.getTargetType(falseValue.type())
- )
- );
- }
- renderKibanaFunctionDefinition(name, info, args, description.variadic());
+ renderKibanaFunctionDefinition(name, info, description.args(), description.variadic());
return;
}
LogManager.getLogger(getTestClass()).info("Skipping rendering types because the function '" + name + "' isn't registered");
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractScalarFunctionTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractScalarFunctionTestCase.java
index fed81d4260bcd..85db73901352b 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractScalarFunctionTestCase.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractScalarFunctionTestCase.java
@@ -38,7 +38,6 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import static org.elasticsearch.compute.data.BlockUtils.toJavaObject;
import static org.hamcrest.Matchers.either;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
@@ -120,6 +119,9 @@ public final void testEvaluate() {
Object result;
try (ExpressionEvaluator evaluator = evaluator(expression).get(driverContext())) {
+ if (testCase.getExpectedBuildEvaluatorWarnings() != null) {
+ assertWarnings(testCase.getExpectedBuildEvaluatorWarnings());
+ }
try (Block block = evaluator.eval(row(testCase.getDataValues()))) {
assertThat(block.getPositionCount(), is(1));
result = toJavaObjectUnsignedLongAware(block, 0);
@@ -177,6 +179,10 @@ public final void testEvaluateBlockWithNulls() {
*/
public final void testCrankyEvaluateBlockWithoutNulls() {
assumeTrue("sometimes the cranky breaker silences warnings, just skip these cases", testCase.getExpectedWarnings() == null);
+ assumeTrue(
+ "sometimes the cranky breaker silences warnings, just skip these cases",
+ testCase.getExpectedBuildEvaluatorWarnings() == null
+ );
try {
testEvaluateBlock(driverContext().blockFactory(), crankyContext(), false);
} catch (CircuitBreakingException ex) {
@@ -190,6 +196,10 @@ public final void testCrankyEvaluateBlockWithoutNulls() {
*/
public final void testCrankyEvaluateBlockWithNulls() {
assumeTrue("sometimes the cranky breaker silences warnings, just skip these cases", testCase.getExpectedWarnings() == null);
+ assumeTrue(
+ "sometimes the cranky breaker silences warnings, just skip these cases",
+ testCase.getExpectedBuildEvaluatorWarnings() == null
+ );
try {
testEvaluateBlock(driverContext().blockFactory(), crankyContext(), true);
} catch (CircuitBreakingException ex) {
@@ -242,10 +252,13 @@ private void testEvaluateBlock(BlockFactory inputBlockFactory, DriverContext con
ExpressionEvaluator eval = evaluator(expression).get(context);
Block block = eval.eval(new Page(positions, manyPositionsBlocks))
) {
+ if (testCase.getExpectedBuildEvaluatorWarnings() != null) {
+ assertWarnings(testCase.getExpectedBuildEvaluatorWarnings());
+ }
assertThat(block.getPositionCount(), is(positions));
for (int p = 0; p < positions; p++) {
if (nullPositions.contains(p)) {
- assertThat(toJavaObject(block, p), allNullsMatcher());
+ assertThat(toJavaObjectUnsignedLongAware(block, p), allNullsMatcher());
continue;
}
assertThat(toJavaObjectUnsignedLongAware(block, p), testCase.getMatcher());
@@ -275,6 +288,9 @@ public final void testEvaluateInManyThreads() throws ExecutionException, Interru
int count = 10_000;
int threads = 5;
var evalSupplier = evaluator(expression);
+ if (testCase.getExpectedBuildEvaluatorWarnings() != null) {
+ assertWarnings(testCase.getExpectedBuildEvaluatorWarnings());
+ }
ExecutorService exec = Executors.newFixedThreadPool(threads);
try {
List> futures = new ArrayList<>();
@@ -310,6 +326,9 @@ public final void testEvaluatorToString() {
assumeTrue("Can't build evaluator", testCase.canBuildEvaluator());
var factory = evaluator(expression);
try (ExpressionEvaluator ev = factory.get(driverContext())) {
+ if (testCase.getExpectedBuildEvaluatorWarnings() != null) {
+ assertWarnings(testCase.getExpectedBuildEvaluatorWarnings());
+ }
assertThat(ev.toString(), testCase.evaluatorToString());
}
}
@@ -322,6 +341,9 @@ public final void testFactoryToString() {
}
assumeTrue("Can't build evaluator", testCase.canBuildEvaluator());
var factory = evaluator(buildFieldExpression(testCase));
+ if (testCase.getExpectedBuildEvaluatorWarnings() != null) {
+ assertWarnings(testCase.getExpectedBuildEvaluatorWarnings());
+ }
assertThat(factory.toString(), testCase.evaluatorToString());
}
@@ -342,6 +364,9 @@ public final void testFold() {
result = NumericUtils.unsignedLongAsBigInteger((Long) result);
}
assertThat(result, testCase.getMatcher());
+ if (testCase.getExpectedBuildEvaluatorWarnings() != null) {
+ assertWarnings(testCase.getExpectedBuildEvaluatorWarnings());
+ }
if (testCase.getExpectedWarnings() != null) {
assertWarnings(testCase.getExpectedWarnings());
}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/RailRoadDiagram.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/RailRoadDiagram.java
index 4e00fa9f41fbd..df0737feadd8d 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/RailRoadDiagram.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/RailRoadDiagram.java
@@ -49,18 +49,28 @@ static String functionSignature(FunctionDefinition definition) throws IOExceptio
List expressions = new ArrayList<>();
expressions.add(new SpecialSequence(definition.name().toUpperCase(Locale.ROOT)));
expressions.add(new Syntax("("));
- boolean first = true;
- List args = EsqlFunctionRegistry.description(definition).argNames();
- for (String arg : args) {
- if (arg.endsWith("...")) {
- expressions.add(new Repetition(new Sequence(new Syntax(","), new Literal(arg.substring(0, arg.length() - 3))), 0, null));
- } else {
- if (first) {
- first = false;
+
+ if (definition.name().equals("case")) {
+ // CASE is so weird let's just hack this together manually
+ Sequence seq = new Sequence(new Literal("condition"), new Syntax(","), new Literal("trueValue"));
+ expressions.add(new Repetition(seq, 1, null));
+ expressions.add(new Repetition(new Literal("elseValue"), 0, 1));
+ } else {
+ boolean first = true;
+ List args = EsqlFunctionRegistry.description(definition).argNames();
+ for (String arg : args) {
+ if (arg.endsWith("...")) {
+ expressions.add(
+ new Repetition(new Sequence(new Syntax(","), new Literal(arg.substring(0, arg.length() - 3))), 0, null)
+ );
} else {
- expressions.add(new Syntax(","));
+ if (first) {
+ first = false;
+ } else {
+ expressions.add(new Syntax(","));
+ }
+ expressions.add(new Literal(arg));
}
- expressions.add(new Literal(arg));
}
}
expressions.add(new Syntax(")"));
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/TestCaseSupplier.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/TestCaseSupplier.java
index a1caa784c9787..e44ea907518b4 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/TestCaseSupplier.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/TestCaseSupplier.java
@@ -67,6 +67,21 @@ public static String nameFromTypes(List types) {
return types.stream().map(t -> "<" + t.typeName() + ">").collect(Collectors.joining(", "));
}
+ /**
+ * Build a name for the test case based on objects likely to describe it.
+ */
+ public static String nameFrom(List
+ *
+ * Finally, it's possible for a single position to be collected into
+ * groupIds. In that case it's positionOffset may
+ * be skipped entirely or the groupIds block could contain a
+ * {@code null} value at that position.
+ *
* @param positionOffset offset into the {@link Page} used to build this
* {@link AddInput} of these ids
* @param groupIds {@link Block} of group id, some of which may be null
@@ -68,7 +74,7 @@ interface AddInput {
}
/**
- * Prepare to process a single page of results.
+ * Prepare to process a single page of input.
*
* This should load the input {@link Block}s and check their types and
* select an optimal path and return that path as an {@link AddInput}.
@@ -76,6 +82,16 @@ interface AddInput {
*/
AddInput prepareProcessPage(SeenGroupIds seenGroupIds, Page page); // TODO allow returning null to opt out of the callback loop
+ /**
+ * Call this to signal to the aggregation that the {@code selected}
+ * parameter that's passed to {@link #evaluateIntermediate} or
+ * {@link #evaluateFinal} may reference groups that haven't been
+ * seen. This puts the underlying storage into a mode where it'll
+ * track which group ids have been seen, even if that increases the
+ * overhead.
+ */
+ void selectedMayContainUnseenGroups(SeenGroupIds seenGroupIds);
+
/**
* Add data produced by {@link #evaluateIntermediate}.
*/
diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/ToPartialGroupingAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/ToPartialGroupingAggregatorFunction.java
index 13d4bd5d6c0d6..18b907a3d7080 100644
--- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/ToPartialGroupingAggregatorFunction.java
+++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/ToPartialGroupingAggregatorFunction.java
@@ -60,6 +60,11 @@ public AddInput prepareProcessPage(SeenGroupIds seenGroupIds, Page page) {
return delegate.prepareProcessPage(seenGroupIds, page);
}
+ @Override
+ public void selectedMayContainUnseenGroups(SeenGroupIds seenGroupIds) {
+ delegate.selectedMayContainUnseenGroups(seenGroupIds);
+ }
+
@Override
public void addIntermediateInput(int positionOffset, IntVector groupIdVector, Page page) {
final CompositeBlock inputBlock = page.getBlock(channels.get(0));
diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/AddBlock.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/AddBlock.java
index 786c61e6f602a..496624fc1189d 100644
--- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/AddBlock.java
+++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/AddBlock.java
@@ -13,6 +13,7 @@
import org.elasticsearch.compute.data.IntBlock;
import org.elasticsearch.compute.data.Page;
import org.elasticsearch.core.Releasable;
+import org.elasticsearch.core.Releasables;
/**
* Helper for adding a {@link Page} worth of {@link Block}s to a {@link BlockHash}
@@ -149,6 +150,6 @@ private void rollover(int position) {
@Override
public void close() {
- ords.close();
+ Releasables.closeExpectNoException(ords, addInput);
}
}
diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/table/BlockHashRowInTableLookup.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/table/BlockHashRowInTableLookup.java
index 1acd1c30ed334..c198853bb36ad 100644
--- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/table/BlockHashRowInTableLookup.java
+++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/table/BlockHashRowInTableLookup.java
@@ -65,6 +65,9 @@ public void add(int positionOffset, IntVector groupIds) {
lastOrd = ord;
}
}
+
+ @Override
+ public void close() {}
});
success = true;
} finally {
diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/HashAggregationOperator.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/HashAggregationOperator.java
index 42bc75a49f4a7..03a4ca2b0ad5e 100644
--- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/HashAggregationOperator.java
+++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/HashAggregationOperator.java
@@ -150,18 +150,23 @@ private void end() {
hashStart = System.nanoTime();
aggregationNanos += hashStart - aggStart;
}
+
+ @Override
+ public void close() {
+ Releasables.closeExpectNoException(prepared);
+ }
}
- AddInput add = new AddInput();
+ try (AddInput add = new AddInput()) {
+ checkState(needsInput(), "Operator is already finishing");
+ requireNonNull(page, "page is null");
- checkState(needsInput(), "Operator is already finishing");
- requireNonNull(page, "page is null");
+ for (int i = 0; i < prepared.length; i++) {
+ prepared[i] = aggregators.get(i).prepareProcessPage(blockHash, page);
+ }
- for (int i = 0; i < prepared.length; i++) {
- prepared[i] = aggregators.get(i).prepareProcessPage(blockHash, page);
+ blockHash.add(wrapPage(page), add);
+ hashNanos += System.nanoTime() - add.hashStart;
}
-
- blockHash.add(wrapPage(page), add);
- hashNanos += System.nanoTime() - add.hashStart;
} finally {
page.releaseBlocks();
pagesProcessed++;
diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/FilteredGroupingAggregatorFunctionTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/FilteredGroupingAggregatorFunctionTests.java
new file mode 100644
index 0000000000000..7b924076c0186
--- /dev/null
+++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/FilteredGroupingAggregatorFunctionTests.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.compute.aggregation;
+
+import org.elasticsearch.compute.data.Block;
+import org.elasticsearch.compute.data.BlockFactory;
+import org.elasticsearch.compute.data.BooleanVector;
+import org.elasticsearch.compute.data.IntBlock;
+import org.elasticsearch.compute.data.LongBlock;
+import org.elasticsearch.compute.data.Page;
+import org.elasticsearch.compute.operator.DriverContext;
+import org.elasticsearch.compute.operator.EvalOperator;
+import org.elasticsearch.compute.operator.LongIntBlockSourceOperator;
+import org.elasticsearch.compute.operator.SourceOperator;
+import org.elasticsearch.core.Tuple;
+import org.junit.After;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.IntStream;
+
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.equalTo;
+
+public class FilteredGroupingAggregatorFunctionTests extends GroupingAggregatorFunctionTestCase {
+ private final List unclosed = Collections.synchronizedList(new ArrayList<>());
+
+ // TODO some version of this test that applies across all aggs
+ @Override
+ protected AggregatorFunctionSupplier aggregatorFunction(List inputChannels) {
+ return new FilteredAggregatorFunctionSupplier(
+ new SumIntAggregatorFunctionSupplier(inputChannels),
+ new AnyGreaterThanFactory(unclosed, inputChannels)
+ );
+ }
+
+ @Override
+ protected String expectedDescriptionOfAggregator() {
+ return "Filtered[next=sum of ints, filter=any > 0]";
+ }
+
+ @Override
+ protected String expectedToStringOfSimpleAggregator() {
+ return "FilteredGroupingAggregatorFunction[next=SumIntGroupingAggregatorFunction[channels=[1]], filter=any > 0]";
+ }
+
+ @Override
+ protected void assertSimpleGroup(List input, Block result, int position, Long group) {
+ long sum = 0;
+ for (Page page : input) {
+ LongBlock groups = page.getBlock(0);
+ IntBlock ints = page.getBlock(1);
+ for (int p = 0; p < ints.getPositionCount(); p++) {
+ /*
+ * Perform the sum on the values *only* if:
+ * 1. Any of the values is > 0 to line up with the condition
+ * 2. Any of the groups matches the group we're asserting
+ */
+ int start = ints.getFirstValueIndex(p);
+ int end = start + ints.getValueCount(p);
+ boolean selected = false;
+ for (int i = start; i < end; i++) {
+ selected |= ints.getInt(i) > 0;
+ }
+ if (selected == false) {
+ continue;
+ }
+ selected = false;
+ if (group == null) {
+ selected = groups.isNull(p);
+ } else {
+ start = groups.getFirstValueIndex(p);
+ end = start + groups.getValueCount(p);
+ for (int i = start; i < end; i++) {
+ selected |= groups.getLong(i) == group;
+ }
+ }
+ if (selected == false) {
+ continue;
+ }
+
+ start = ints.getFirstValueIndex(p);
+ end = start + ints.getValueCount(p);
+ for (int i = start; i < end; i++) {
+ sum += ints.getInt(i);
+ }
+ }
+ }
+ assertThat(((LongBlock) result).getLong(position), equalTo(sum));
+ }
+
+ @Override
+ protected SourceOperator simpleInput(BlockFactory blockFactory, int size) {
+ int max = between(1, Integer.MAX_VALUE / size / 5);
+ return new LongIntBlockSourceOperator(
+ blockFactory,
+ IntStream.range(0, size).mapToObj(l -> Tuple.tuple(randomLongBetween(0, 4), between(-max, max)))
+ );
+ }
+
+ @After
+ public void checkUnclosed() {
+ for (Exception tracker : unclosed) {
+ logger.error("unclosed", tracker);
+ }
+ assertThat(unclosed, empty());
+ }
+
+ /**
+ * This checks if *any* of the integers are > 0. If so we push the group to
+ * the aggregation.
+ */
+ private record AnyGreaterThanFactory(List unclosed, List inputChannels)
+ implements
+ EvalOperator.ExpressionEvaluator.Factory {
+ @Override
+ public EvalOperator.ExpressionEvaluator get(DriverContext context) {
+ Exception tracker = new Exception(Integer.toString(unclosed.size()));
+ unclosed.add(tracker);
+ return new AnyGreaterThan(context.blockFactory(), unclosed, tracker, inputChannels);
+ }
+
+ @Override
+ public String toString() {
+ return "any > 0";
+ }
+ }
+
+ private record AnyGreaterThan(BlockFactory blockFactory, List unclosed, Exception tracker, List inputChannels)
+ implements
+ EvalOperator.ExpressionEvaluator {
+ @Override
+ public Block eval(Page page) {
+ IntBlock ints = page.getBlock(inputChannels.get(0));
+ try (BooleanVector.FixedBuilder result = blockFactory.newBooleanVectorFixedBuilder(ints.getPositionCount())) {
+ position: for (int p = 0; p < ints.getPositionCount(); p++) {
+ int start = ints.getFirstValueIndex(p);
+ int end = start + ints.getValueCount(p);
+ for (int i = start; i < end; i++) {
+ if (ints.getInt(i) > 0) {
+ result.appendBoolean(p, true);
+ continue position;
+ }
+ }
+ result.appendBoolean(p, false);
+ }
+ return result.build().asBlock();
+ }
+ }
+
+ @Override
+ public void close() {
+ if (unclosed.remove(tracker) == false) {
+ throw new IllegalStateException("close failure!");
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "any > 0";
+ }
+ }
+}
diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java
index f6558d54b2779..de9337f5fce2c 100644
--- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java
+++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java
@@ -52,11 +52,14 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
+/**
+ * Shared tests for testing grouped aggregations.
+ */
public abstract class GroupingAggregatorFunctionTestCase extends ForkingOperatorTestCase {
protected abstract AggregatorFunctionSupplier aggregatorFunction(List inputChannels);
protected final int aggregatorIntermediateBlockCount() {
- try (var agg = aggregatorFunction(List.of()).aggregator(driverContext())) {
+ try (var agg = aggregatorFunction(List.of()).groupingAggregator(driverContext())) {
return agg.intermediateBlockCount();
}
}
@@ -101,16 +104,20 @@ protected final Matcher expectedDescriptionOfSimple() {
@Override
protected final Matcher expectedToStringOfSimple() {
String hash = "blockHash=LongBlockHash{channel=0, entries=0, seenNull=false}";
- String type = getClass().getSimpleName().replace("Tests", "");
return equalTo(
"HashAggregationOperator["
+ hash
+ ", aggregators=[GroupingAggregator[aggregatorFunction="
- + type
- + "[channels=[1]], mode=SINGLE]]]"
+ + expectedToStringOfSimpleAggregator()
+ + ", mode=SINGLE]]]"
);
}
+ protected String expectedToStringOfSimpleAggregator() {
+ String type = getClass().getSimpleName().replace("Tests", "");
+ return type + "[channels=[1]]";
+ }
+
private SeenGroups seenGroups(List input) {
boolean seenNullGroup = false;
SortedSet seenGroups = new TreeSet<>();
@@ -544,7 +551,7 @@ public GroupingAggregatorFunction groupingAggregator(DriverContext driverContext
@Override
public AddInput prepareProcessPage(SeenGroupIds ignoredSeenGroupIds, Page page) {
return new AddInput() {
- AddInput delegateAddInput = delegate.prepareProcessPage(bigArrays -> {
+ final AddInput delegateAddInput = delegate.prepareProcessPage(bigArrays -> {
BitArray seen = new BitArray(0, bigArrays);
seen.or(seenGroupIds);
return seen;
@@ -595,9 +602,19 @@ public void add(int positionOffset, IntVector groupIds) {
delegateAddInput.add(positionOffset + offset, blockFactory.newIntArrayVector(chunk, count));
}
}
+
+ @Override
+ public void close() {
+ delegateAddInput.close();
+ }
};
}
+ @Override
+ public void selectedMayContainUnseenGroups(SeenGroupIds seenGroupIds) {
+ delegate.selectedMayContainUnseenGroups(seenGroupIds);
+ }
+
@Override
public void addIntermediateInput(int positionOffset, IntVector groupIds, Page page) {
int[] chunk = new int[emitChunkSize];
diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/AddBlockTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/AddBlockTests.java
index fbe696aa2997b..da9529cb761ef 100644
--- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/AddBlockTests.java
+++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/AddBlockTests.java
@@ -39,6 +39,7 @@ public void testSv() {
}
expected.add(added(3, 4));
assertThat(result.added, equalTo(expected));
+ assertThat(result.closed, equalTo(true));
}
public void testMvBlockEndsOnBatchBoundary() {
@@ -62,6 +63,7 @@ public void testMvBlockEndsOnBatchBoundary() {
// We uselessly flush an empty position if emitBatchSize lines up with the total count
expected.add(new Added(1, List.of(List.of())));
assertThat(result.added, equalTo(expected));
+ assertThat(result.closed, equalTo(true));
}
public void testMvPositionEndOnBatchBoundary() {
@@ -83,6 +85,7 @@ public void testMvPositionEndOnBatchBoundary() {
// Because the first position ended on a block boundary we uselessly emit an empty position there
expected.add(new Added(0, List.of(List.of(), List.of(0, 2))));
assertThat(result.added, equalTo(expected));
+ assertThat(result.closed, equalTo(true));
}
public void testMv() {
@@ -103,6 +106,7 @@ public void testMv() {
}
expected.add(new Added(1, List.of(List.of(2))));
assertThat(result.added, equalTo(expected));
+ assertThat(result.closed, equalTo(true));
}
@After
@@ -117,6 +121,8 @@ Added added(int positionOffset, int... ords) {
}
private class TestAddInput implements GroupingAggregatorFunction.AddInput {
+ private boolean closed = false;
+
private final List added = new ArrayList<>();
@Override
@@ -139,5 +145,10 @@ public void add(int positionOffset, IntBlock groupIds) {
public void add(int positionOffset, IntVector groupIds) {
add(positionOffset, groupIds.asBlock());
}
+
+ @Override
+ public void close() {
+ closed = true;
+ }
}
}
diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/BlockHashTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/BlockHashTests.java
index 259d4f1249d69..c4042ea15afc6 100644
--- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/BlockHashTests.java
+++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/BlockHashTests.java
@@ -1166,6 +1166,9 @@ public void add(int positionOffset, IntVector groupIds) {
groupIds.incRef();
output1.add(new Output(positionOffset, null, groupIds));
}
+
+ @Override
+ public void close() {}
});
hash2.add(page, new GroupingAggregatorFunction.AddInput() {
@Override
@@ -1179,6 +1182,9 @@ public void add(int positionOffset, IntVector groupIds) {
groupIds.incRef();
output2.add(new Output(positionOffset, null, groupIds));
}
+
+ @Override
+ public void close() {}
});
assertThat(output1.size(), equalTo(output1.size()));
for (int i = 0; i < output1.size(); i++) {
@@ -1297,6 +1303,9 @@ public void add(int positionOffset, IntBlock groupIds) {
public void add(int positionOffset, IntVector groupIds) {
add(positionOffset, groupIds.asBlock());
}
+
+ @Override
+ public void close() {}
});
if (blockHash instanceof LongLongBlockHash == false
&& blockHash instanceof BytesRefLongBlockHash == false
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAggregationTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAggregationTestCase.java
index 54db9afa291ad..eb9f10f7b2e0f 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAggregationTestCase.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAggregationTestCase.java
@@ -11,6 +11,7 @@
import org.elasticsearch.compute.aggregation.AggregatorFunctionSupplier;
import org.elasticsearch.compute.aggregation.AggregatorMode;
import org.elasticsearch.compute.aggregation.GroupingAggregator;
+import org.elasticsearch.compute.aggregation.GroupingAggregatorFunction;
import org.elasticsearch.compute.aggregation.SeenGroupIds;
import org.elasticsearch.compute.data.Block;
import org.elasticsearch.compute.data.ElementType;
@@ -455,22 +456,26 @@ private void processPageGrouping(GroupingAggregator aggregator, Page inputPage,
for (int currentGroupOffset = 0; currentGroupOffset < groupCount;) {
int groupSliceRemainingSize = Math.min(groupSliceSize, groupCount - currentGroupOffset);
var seenGroupIds = new SeenGroupIds.Range(0, allValuesNull ? 0 : currentGroupOffset + groupSliceRemainingSize);
- var addInput = aggregator.prepareProcessPage(seenGroupIds, inputPage);
-
- var positionCount = inputPage.getPositionCount();
- var dataSliceSize = 1;
- // Divide data in chunks
- for (int currentDataOffset = 0; currentDataOffset < positionCount;) {
- int dataSliceRemainingSize = Math.min(dataSliceSize, positionCount - currentDataOffset);
- try (
- var groups = makeGroupsVector(currentGroupOffset, currentGroupOffset + groupSliceRemainingSize, dataSliceRemainingSize)
- ) {
- addInput.add(currentDataOffset, groups);
- }
+ try (GroupingAggregatorFunction.AddInput addInput = aggregator.prepareProcessPage(seenGroupIds, inputPage)) {
+ var positionCount = inputPage.getPositionCount();
+ var dataSliceSize = 1;
+ // Divide data in chunks
+ for (int currentDataOffset = 0; currentDataOffset < positionCount;) {
+ int dataSliceRemainingSize = Math.min(dataSliceSize, positionCount - currentDataOffset);
+ try (
+ var groups = makeGroupsVector(
+ currentGroupOffset,
+ currentGroupOffset + groupSliceRemainingSize,
+ dataSliceRemainingSize
+ )
+ ) {
+ addInput.add(currentDataOffset, groups);
+ }
- currentDataOffset += dataSliceSize;
- if (positionCount > currentDataOffset) {
- dataSliceSize = randomIntBetween(1, Math.min(100, positionCount - currentDataOffset));
+ currentDataOffset += dataSliceSize;
+ if (positionCount > currentDataOffset) {
+ dataSliceSize = randomIntBetween(1, Math.min(100, positionCount - currentDataOffset));
+ }
}
}
From 04d192921d467286eef5f82060d86d21d986dabc Mon Sep 17 00:00:00 2001
From: Kathleen DeRusso
Date: Mon, 9 Sep 2024 14:55:44 -0400
Subject: [PATCH 10/31] Allow fields with dots in sparse vector field mapper
(#111981)
* Remove dot validation for sparse vector field mapper
* Update docs/changelog/111981.yaml
* Update changelog
* Fix test permissions
* PR feedback - yaml test
* PR feedback - remove non-dot values from sparse vector query in test to verify the dot is searched correctly
* Add additional test cases for field collissions
* Update docs/changelog/111981.yaml
* Update key for SparseVectorFieldMapper
* Fix test
* Update yaml test to include scores
* Update server/src/main/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapper.java
Co-authored-by: Jim Ferenczi
* Revert "Update server/src/main/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapper.java"
This reverts commit 58fc087535484698426d96d02dd45521fa43d519.
* PR feedback - escape dots
---------
Co-authored-by: Elastic Machine
Co-authored-by: Jim Ferenczi
---
docs/changelog/111981.yaml | 6 +
.../vectors/SparseVectorFieldMapper.java | 8 +-
.../vectors/SparseVectorFieldMapperTests.java | 28 ++-
.../test/ml/sparse_vector_search.yml | 163 ++++++++++++++++++
4 files changed, 192 insertions(+), 13 deletions(-)
create mode 100644 docs/changelog/111981.yaml
diff --git a/docs/changelog/111981.yaml b/docs/changelog/111981.yaml
new file mode 100644
index 0000000000000..13b8fe4b7e38d
--- /dev/null
+++ b/docs/changelog/111981.yaml
@@ -0,0 +1,6 @@
+pr: 111981
+summary: Allow fields with dots in sparse vector field mapper
+area: Mapping
+type: enhancement
+issues:
+ - 109118
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapper.java
index 0e05d49f35a6e..7155fc1161ed1 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapper.java
@@ -177,15 +177,11 @@ public void parse(DocumentParserContext context) throws IOException {
for (Token token = context.parser().nextToken(); token != Token.END_OBJECT; token = context.parser().nextToken()) {
if (token == Token.FIELD_NAME) {
feature = context.parser().currentName();
- if (feature.contains(".")) {
- throw new IllegalArgumentException(
- "[sparse_vector] fields do not support dots in feature names but found [" + feature + "]"
- );
- }
} else if (token == Token.VALUE_NULL) {
// ignore feature, this is consistent with numeric fields
} else if (token == Token.VALUE_NUMBER || token == Token.VALUE_STRING) {
- final String key = fullPath() + "." + feature;
+ // Use a delimiter that won't collide with subfields & escape the dots in the feature name
+ final String key = fullPath() + "\\." + feature.replace(".", "\\.");
float value = context.parser().floatValue(true);
// if we have an existing feature of the same name we'll select for the one with the max value
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapperTests.java
index 271f0c12be611..9cfbbad5ebf50 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapperTests.java
@@ -111,12 +111,26 @@ public void testDefaults() throws Exception {
public void testDotInFieldName() throws Exception {
DocumentMapper mapper = createDocumentMapper(fieldMapping(this::minimalMapping));
- DocumentParsingException ex = expectThrows(
- DocumentParsingException.class,
- () -> mapper.parse(source(b -> b.field("field", Map.of("politi.cs", 10, "sports", 20))))
- );
- assertThat(ex.getCause().getMessage(), containsString("do not support dots in feature names"));
- assertThat(ex.getCause().getMessage(), containsString("politi.cs"));
+ ParsedDocument parsedDocument = mapper.parse(source(b -> b.field("field", Map.of("foo.bar", 10, "foobar", 20))));
+
+ List fields = parsedDocument.rootDoc().getFields("field");
+ assertEquals(2, fields.size());
+ assertThat(fields.get(0), Matchers.instanceOf(FeatureField.class));
+ FeatureField featureField1 = null;
+ FeatureField featureField2 = null;
+ for (IndexableField field : fields) {
+ if (field.stringValue().equals("foo.bar")) {
+ featureField1 = (FeatureField) field;
+ } else if (field.stringValue().equals("foobar")) {
+ featureField2 = (FeatureField) field;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ int freq1 = getFrequency(featureField1.tokenStream(null, null));
+ int freq2 = getFrequency(featureField2.tokenStream(null, null));
+ assertTrue(freq1 < freq2);
}
public void testHandlesMultiValuedFields() throws MapperParsingException, IOException {
@@ -156,7 +170,7 @@ public void testHandlesMultiValuedFields() throws MapperParsingException, IOExce
}));
// then validate that the generate document stored both values appropriately and we have only the max value stored
- FeatureField barField = ((FeatureField) doc1.rootDoc().getByKey("foo.field.bar"));
+ FeatureField barField = ((FeatureField) doc1.rootDoc().getByKey("foo.field\\.bar"));
assertEquals(20, barField.getFeatureValue(), 1);
FeatureField storedBarField = ((FeatureField) doc1.rootDoc().getFields("foo.field").get(1));
diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/ml/sparse_vector_search.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/ml/sparse_vector_search.yml
index 75823d22504f3..332981a580802 100644
--- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/ml/sparse_vector_search.yml
+++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/ml/sparse_vector_search.yml
@@ -313,3 +313,166 @@ setup:
query: "octopus comforter smells"
- match: { status: 400 }
+
+---
+"Search on a sparse_vector field with dots in the field names":
+
+ - requires:
+ cluster_features: [ "gte_v8.16.0" ]
+ reason: dots in field names allowed starting in in 8.16.0
+
+ - do:
+ indices.create:
+ index: index-with-sparse-vector2
+ body:
+ mappings:
+ properties:
+ ml.tokens:
+ type: sparse_vector
+
+ - match: { acknowledged: true }
+
+ - do:
+ headers:
+ Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
+ index:
+ index: index-with-sparse-vector2
+ id: "has-dots"
+ refresh: true
+ body:
+ ml:
+ tokens:
+ running: 2.4097164
+ good: 2.170997
+ run: 2.052153
+ race: 1.4575411
+ for: 1.1908325
+ 5.0k: 2.489943
+
+ - match: { result: "created" }
+
+ - do:
+ headers:
+ Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
+ get:
+ index: index-with-sparse-vector2
+ id: "has-dots"
+
+ - match:
+ _source:
+ ml:
+ tokens:
+ running: 2.4097164
+ good: 2.170997
+ run: 2.052153
+ race: 1.4575411
+ for: 1.1908325
+ 5.0k: 2.489943
+
+ - do:
+ search:
+ index: index-with-sparse-vector2
+ body:
+ query:
+ sparse_vector:
+ field: ml.tokens
+ query_vector:
+ 5.0k: 2.489943
+
+ - match: { hits.total.value: 1 }
+
+---
+"Search on a nested sparse_vector field with dots in the field names and conflicting child fields":
+
+ - requires:
+ cluster_features: [ "gte_v8.16.0" ]
+ reason: dots in field names allowed starting in in 8.16.0
+
+ - do:
+ indices.create:
+ index: index-with-sparse-vector3
+ body:
+ mappings:
+ properties:
+ parent:
+ type: object
+ subobjects: false
+ properties:
+ foo:
+ type: sparse_vector
+ foo.bar:
+ type: sparse_vector
+
+ - match: { acknowledged: true }
+
+ - do:
+ headers:
+ Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
+ Content-Type: application/json
+ bulk:
+ index: index-with-sparse-vector3
+ refresh: true
+ body: |
+ {"index": { "_id": "parent-foo" }}
+ {"parent.foo": { "bar.baz": 1.0 }}
+ {"index": { "_id": "parent-foo-bar" }}
+ {"parent.foo.bar": { "baz": 2.0 }}
+ {"index": { "_id": "both-docs" }}
+ {"parent.foo": { "bar.baz": 3.0 }, "parent.foo.bar": { "baz": 4.0 }}
+
+
+ - do:
+ headers:
+ Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
+ get:
+ index: index-with-sparse-vector3
+ id: "parent-foo"
+
+ - match:
+ _source:
+ parent.foo:
+ bar.baz: 1.0
+
+ - do:
+ headers:
+ Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
+ get:
+ index: index-with-sparse-vector3
+ id: "parent-foo-bar"
+
+ - match:
+ _source:
+ parent.foo.bar:
+ baz: 2.0
+
+ - do:
+ search:
+ index: index-with-sparse-vector3
+ body:
+ query:
+ sparse_vector:
+ field: parent.foo
+ query_vector:
+ bar.baz: 1.0
+
+ - match: { hits.total.value: 2 }
+ - match: { hits.hits.0._id: "both-docs" }
+ - match: { hits.hits.0._score: 3.0 }
+ - match: { hits.hits.1._id: "parent-foo" }
+ - match: { hits.hits.1._score: 1.0 }
+
+ - do:
+ search:
+ index: index-with-sparse-vector3
+ body:
+ query:
+ sparse_vector:
+ field: parent.foo.bar
+ query_vector:
+ baz: 1.0
+
+ - match: { hits.total.value: 2 }
+ - match: { hits.hits.0._id: "both-docs" }
+ - match: { hits.hits.0._score: 4.0 }
+ - match: { hits.hits.1._id: "parent-foo-bar" }
+ - match: { hits.hits.1._score: 2.0 }
From e8569356ea3c4bd2d23d1ca848d4c5e43547bb4e Mon Sep 17 00:00:00 2001
From: Fang Xing <155562079+fang-xing-esql@users.noreply.github.com>
Date: Mon, 9 Sep 2024 14:56:43 -0400
Subject: [PATCH 11/31] [ES|QL] explicit cast a string literal to date_period
and time_duration in arithmetic operations (#109193)
explicit cast to date_period and time_duration in arithmic operation
---
docs/changelog/109193.yaml | 6 +
.../description/to_dateperiod.asciidoc | 5 +
.../description/to_timeduration.asciidoc | 5 +
.../functions/examples/to_dateperiod.asciidoc | 13 +
.../examples/to_timeduration.asciidoc | 13 +
.../kibana/definition/to_dateperiod.json | 47 ++++
.../kibana/definition/to_timeduration.json | 47 ++++
.../functions/kibana/docs/to_dateperiod.md | 10 +
.../functions/kibana/docs/to_timeduration.md | 10 +
.../esql/functions/kibana/inline_cast.json | 2 +
.../functions/layout/to_dateperiod.asciidoc | 15 ++
.../functions/layout/to_timeduration.asciidoc | 15 ++
.../parameters/to_dateperiod.asciidoc | 6 +
.../parameters/to_timeduration.asciidoc | 6 +
.../functions/signature/to_dateperiod.svg | 1 +
.../functions/signature/to_timeduration.svg | 1 +
.../type-conversion-functions.asciidoc | 4 +
.../functions/types/to_dateperiod.asciidoc | 11 +
.../functions/types/to_timeduration.asciidoc | 11 +
.../xpack/esql/qa/rest/RestEsqlTestCase.java | 35 +++
.../src/main/resources/convert.csv-spec | 137 ++++++++++
.../src/main/resources/meta.csv-spec | 10 +-
.../xpack/esql/action/EsqlCapabilities.java | 7 +-
.../xpack/esql/analysis/Verifier.java | 7 +-
.../function/EsqlFunctionRegistry.java | 4 +
.../convert/AbstractConvertFunction.java | 2 +-
.../convert/FoldablesConvertFunction.java | 75 ++++++
.../function/scalar/convert/ToDatePeriod.java | 54 ++++
.../scalar/convert/ToTimeDuration.java | 54 ++++
.../xpack/esql/parser/ExpressionBuilder.java | 4 +-
.../esql/type/EsqlDataTypeConverter.java | 148 +++++++++--
.../xpack/esql/analysis/VerifierTests.java | 245 +++++++++++++++++-
.../scalar/convert/ToDatePeriodTests.java | 88 +++++++
.../scalar/convert/ToTimeDurationTests.java | 87 +++++++
.../optimizer/LogicalPlanOptimizerTests.java | 141 ++++++++++
.../esql/parser/StatementParserTests.java | 16 ++
.../rest-api-spec/test/esql/10_basic.yml | 29 +++
37 files changed, 1335 insertions(+), 36 deletions(-)
create mode 100644 docs/changelog/109193.yaml
create mode 100644 docs/reference/esql/functions/description/to_dateperiod.asciidoc
create mode 100644 docs/reference/esql/functions/description/to_timeduration.asciidoc
create mode 100644 docs/reference/esql/functions/examples/to_dateperiod.asciidoc
create mode 100644 docs/reference/esql/functions/examples/to_timeduration.asciidoc
create mode 100644 docs/reference/esql/functions/kibana/definition/to_dateperiod.json
create mode 100644 docs/reference/esql/functions/kibana/definition/to_timeduration.json
create mode 100644 docs/reference/esql/functions/kibana/docs/to_dateperiod.md
create mode 100644 docs/reference/esql/functions/kibana/docs/to_timeduration.md
create mode 100644 docs/reference/esql/functions/layout/to_dateperiod.asciidoc
create mode 100644 docs/reference/esql/functions/layout/to_timeduration.asciidoc
create mode 100644 docs/reference/esql/functions/parameters/to_dateperiod.asciidoc
create mode 100644 docs/reference/esql/functions/parameters/to_timeduration.asciidoc
create mode 100644 docs/reference/esql/functions/signature/to_dateperiod.svg
create mode 100644 docs/reference/esql/functions/signature/to_timeduration.svg
create mode 100644 docs/reference/esql/functions/types/to_dateperiod.asciidoc
create mode 100644 docs/reference/esql/functions/types/to_timeduration.asciidoc
create mode 100644 x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/FoldablesConvertFunction.java
create mode 100644 x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatePeriod.java
create mode 100644 x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToTimeDuration.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatePeriodTests.java
create mode 100644 x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToTimeDurationTests.java
diff --git a/docs/changelog/109193.yaml b/docs/changelog/109193.yaml
new file mode 100644
index 0000000000000..5cc664eaee2cd
--- /dev/null
+++ b/docs/changelog/109193.yaml
@@ -0,0 +1,6 @@
+pr: 109193
+summary: "[ES|QL] explicit cast a string literal to `date_period` and `time_duration`\
+ \ in arithmetic operations"
+area: ES|QL
+type: enhancement
+issues: []
diff --git a/docs/reference/esql/functions/description/to_dateperiod.asciidoc b/docs/reference/esql/functions/description/to_dateperiod.asciidoc
new file mode 100644
index 0000000000000..443e377bf51c5
--- /dev/null
+++ b/docs/reference/esql/functions/description/to_dateperiod.asciidoc
@@ -0,0 +1,5 @@
+// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
+
+*Description*
+
+Converts an input value into a `date_period` value.
diff --git a/docs/reference/esql/functions/description/to_timeduration.asciidoc b/docs/reference/esql/functions/description/to_timeduration.asciidoc
new file mode 100644
index 0000000000000..87c405a98ff65
--- /dev/null
+++ b/docs/reference/esql/functions/description/to_timeduration.asciidoc
@@ -0,0 +1,5 @@
+// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
+
+*Description*
+
+Converts an input value into a `time_duration` value.
diff --git a/docs/reference/esql/functions/examples/to_dateperiod.asciidoc b/docs/reference/esql/functions/examples/to_dateperiod.asciidoc
new file mode 100644
index 0000000000000..91272b33b45ed
--- /dev/null
+++ b/docs/reference/esql/functions/examples/to_dateperiod.asciidoc
@@ -0,0 +1,13 @@
+// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
+
+*Example*
+
+[source.merge.styled,esql]
+----
+include::{esql-specs}/convert.csv-spec[tag=castToDatePeriod]
+----
+[%header.monospaced.styled,format=dsv,separator=|]
+|===
+include::{esql-specs}/convert.csv-spec[tag=castToDatePeriod-result]
+|===
+
diff --git a/docs/reference/esql/functions/examples/to_timeduration.asciidoc b/docs/reference/esql/functions/examples/to_timeduration.asciidoc
new file mode 100644
index 0000000000000..7e62a39bbe3e2
--- /dev/null
+++ b/docs/reference/esql/functions/examples/to_timeduration.asciidoc
@@ -0,0 +1,13 @@
+// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
+
+*Example*
+
+[source.merge.styled,esql]
+----
+include::{esql-specs}/convert.csv-spec[tag=castToTimeDuration]
+----
+[%header.monospaced.styled,format=dsv,separator=|]
+|===
+include::{esql-specs}/convert.csv-spec[tag=castToTimeDuration-result]
+|===
+
diff --git a/docs/reference/esql/functions/kibana/definition/to_dateperiod.json b/docs/reference/esql/functions/kibana/definition/to_dateperiod.json
new file mode 100644
index 0000000000000..dc9176f4cc0b0
--- /dev/null
+++ b/docs/reference/esql/functions/kibana/definition/to_dateperiod.json
@@ -0,0 +1,47 @@
+{
+ "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.",
+ "type" : "eval",
+ "name" : "to_dateperiod",
+ "description" : "Converts an input value into a `date_period` value.",
+ "signatures" : [
+ {
+ "params" : [
+ {
+ "name" : "field",
+ "type" : "date_period",
+ "optional" : false,
+ "description" : "Input value. The input is a valid constant date period expression."
+ }
+ ],
+ "variadic" : false,
+ "returnType" : "date_period"
+ },
+ {
+ "params" : [
+ {
+ "name" : "field",
+ "type" : "keyword",
+ "optional" : false,
+ "description" : "Input value. The input is a valid constant date period expression."
+ }
+ ],
+ "variadic" : false,
+ "returnType" : "date_period"
+ },
+ {
+ "params" : [
+ {
+ "name" : "field",
+ "type" : "text",
+ "optional" : false,
+ "description" : "Input value. The input is a valid constant date period expression."
+ }
+ ],
+ "variadic" : false,
+ "returnType" : "date_period"
+ }
+ ],
+ "examples" : [
+ "row x = \"2024-01-01\"::datetime | eval y = x + \"3 DAYS\"::date_period, z = x - to_dateperiod(\"3 days\");"
+ ]
+}
diff --git a/docs/reference/esql/functions/kibana/definition/to_timeduration.json b/docs/reference/esql/functions/kibana/definition/to_timeduration.json
new file mode 100644
index 0000000000000..039de323044ed
--- /dev/null
+++ b/docs/reference/esql/functions/kibana/definition/to_timeduration.json
@@ -0,0 +1,47 @@
+{
+ "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.",
+ "type" : "eval",
+ "name" : "to_timeduration",
+ "description" : "Converts an input value into a `time_duration` value.",
+ "signatures" : [
+ {
+ "params" : [
+ {
+ "name" : "field",
+ "type" : "keyword",
+ "optional" : false,
+ "description" : "Input value. The input is a valid constant time duration expression."
+ }
+ ],
+ "variadic" : false,
+ "returnType" : "time_duration"
+ },
+ {
+ "params" : [
+ {
+ "name" : "field",
+ "type" : "text",
+ "optional" : false,
+ "description" : "Input value. The input is a valid constant time duration expression."
+ }
+ ],
+ "variadic" : false,
+ "returnType" : "time_duration"
+ },
+ {
+ "params" : [
+ {
+ "name" : "field",
+ "type" : "time_duration",
+ "optional" : false,
+ "description" : "Input value. The input is a valid constant time duration expression."
+ }
+ ],
+ "variadic" : false,
+ "returnType" : "time_duration"
+ }
+ ],
+ "examples" : [
+ "row x = \"2024-01-01\"::datetime | eval y = x + \"3 hours\"::time_duration, z = x - to_timeduration(\"3 hours\");"
+ ]
+}
diff --git a/docs/reference/esql/functions/kibana/docs/to_dateperiod.md b/docs/reference/esql/functions/kibana/docs/to_dateperiod.md
new file mode 100644
index 0000000000000..adbbe75783051
--- /dev/null
+++ b/docs/reference/esql/functions/kibana/docs/to_dateperiod.md
@@ -0,0 +1,10 @@
+
+
+### TO_DATEPERIOD
+Converts an input value into a `date_period` value.
+
+```
+row x = "2024-01-01"::datetime | eval y = x + "3 DAYS"::date_period, z = x - to_dateperiod("3 days");
+```
diff --git a/docs/reference/esql/functions/kibana/docs/to_timeduration.md b/docs/reference/esql/functions/kibana/docs/to_timeduration.md
new file mode 100644
index 0000000000000..52e32ba97d11c
--- /dev/null
+++ b/docs/reference/esql/functions/kibana/docs/to_timeduration.md
@@ -0,0 +1,10 @@
+
+
+### TO_TIMEDURATION
+Converts an input value into a `time_duration` value.
+
+```
+row x = "2024-01-01"::datetime | eval y = x + "3 hours"::time_duration, z = x - to_timeduration("3 hours");
+```
diff --git a/docs/reference/esql/functions/kibana/inline_cast.json b/docs/reference/esql/functions/kibana/inline_cast.json
index f71572d3d651c..f1aa283c52e95 100644
--- a/docs/reference/esql/functions/kibana/inline_cast.json
+++ b/docs/reference/esql/functions/kibana/inline_cast.json
@@ -3,6 +3,7 @@
"boolean" : "to_boolean",
"cartesian_point" : "to_cartesianpoint",
"cartesian_shape" : "to_cartesianshape",
+ "date_period" : "to_dateperiod",
"datetime" : "to_datetime",
"double" : "to_double",
"geo_point" : "to_geopoint",
@@ -14,6 +15,7 @@
"long" : "to_long",
"string" : "to_string",
"text" : "to_string",
+ "time_duration" : "to_timeduration",
"unsigned_long" : "to_unsigned_long",
"version" : "to_version"
}
\ No newline at end of file
diff --git a/docs/reference/esql/functions/layout/to_dateperiod.asciidoc b/docs/reference/esql/functions/layout/to_dateperiod.asciidoc
new file mode 100644
index 0000000000000..0345c1a6680c8
--- /dev/null
+++ b/docs/reference/esql/functions/layout/to_dateperiod.asciidoc
@@ -0,0 +1,15 @@
+// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
+
+[discrete]
+[[esql-to_dateperiod]]
+=== `TO_DATEPERIOD`
+
+*Syntax*
+
+[.text-center]
+image::esql/functions/signature/to_dateperiod.svg[Embedded,opts=inline]
+
+include::../parameters/to_dateperiod.asciidoc[]
+include::../description/to_dateperiod.asciidoc[]
+include::../types/to_dateperiod.asciidoc[]
+include::../examples/to_dateperiod.asciidoc[]
diff --git a/docs/reference/esql/functions/layout/to_timeduration.asciidoc b/docs/reference/esql/functions/layout/to_timeduration.asciidoc
new file mode 100644
index 0000000000000..bed4743c730a8
--- /dev/null
+++ b/docs/reference/esql/functions/layout/to_timeduration.asciidoc
@@ -0,0 +1,15 @@
+// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
+
+[discrete]
+[[esql-to_timeduration]]
+=== `TO_TIMEDURATION`
+
+*Syntax*
+
+[.text-center]
+image::esql/functions/signature/to_timeduration.svg[Embedded,opts=inline]
+
+include::../parameters/to_timeduration.asciidoc[]
+include::../description/to_timeduration.asciidoc[]
+include::../types/to_timeduration.asciidoc[]
+include::../examples/to_timeduration.asciidoc[]
diff --git a/docs/reference/esql/functions/parameters/to_dateperiod.asciidoc b/docs/reference/esql/functions/parameters/to_dateperiod.asciidoc
new file mode 100644
index 0000000000000..1e5ed14cf44ae
--- /dev/null
+++ b/docs/reference/esql/functions/parameters/to_dateperiod.asciidoc
@@ -0,0 +1,6 @@
+// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
+
+*Parameters*
+
+`field`::
+Input value. The input is a valid constant date period expression.
diff --git a/docs/reference/esql/functions/parameters/to_timeduration.asciidoc b/docs/reference/esql/functions/parameters/to_timeduration.asciidoc
new file mode 100644
index 0000000000000..0289dc37dbfe6
--- /dev/null
+++ b/docs/reference/esql/functions/parameters/to_timeduration.asciidoc
@@ -0,0 +1,6 @@
+// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
+
+*Parameters*
+
+`field`::
+Input value. The input is a valid constant time duration expression.
diff --git a/docs/reference/esql/functions/signature/to_dateperiod.svg b/docs/reference/esql/functions/signature/to_dateperiod.svg
new file mode 100644
index 0000000000000..302a9ee3bfa69
--- /dev/null
+++ b/docs/reference/esql/functions/signature/to_dateperiod.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/docs/reference/esql/functions/signature/to_timeduration.svg b/docs/reference/esql/functions/signature/to_timeduration.svg
new file mode 100644
index 0000000000000..b237441b3b40d
--- /dev/null
+++ b/docs/reference/esql/functions/signature/to_timeduration.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/docs/reference/esql/functions/type-conversion-functions.asciidoc b/docs/reference/esql/functions/type-conversion-functions.asciidoc
index 96c29a776bc2b..9ac9ec290c07b 100644
--- a/docs/reference/esql/functions/type-conversion-functions.asciidoc
+++ b/docs/reference/esql/functions/type-conversion-functions.asciidoc
@@ -16,6 +16,7 @@
* <>
* <>
* <>
+* experimental:[] <>
* <>
* <>
* <>
@@ -26,6 +27,7 @@
* <>
* <>
* <>
+* experimental:[] <>
* experimental:[] <>
* <>
// end::type_list[]
@@ -33,6 +35,7 @@
include::layout/to_boolean.asciidoc[]
include::layout/to_cartesianpoint.asciidoc[]
include::layout/to_cartesianshape.asciidoc[]
+include::layout/to_dateperiod.asciidoc[]
include::layout/to_datetime.asciidoc[]
include::layout/to_degrees.asciidoc[]
include::layout/to_double.asciidoc[]
@@ -43,5 +46,6 @@ include::layout/to_ip.asciidoc[]
include::layout/to_long.asciidoc[]
include::layout/to_radians.asciidoc[]
include::layout/to_string.asciidoc[]
+include::layout/to_timeduration.asciidoc[]
include::layout/to_unsigned_long.asciidoc[]
include::layout/to_version.asciidoc[]
diff --git a/docs/reference/esql/functions/types/to_dateperiod.asciidoc b/docs/reference/esql/functions/types/to_dateperiod.asciidoc
new file mode 100644
index 0000000000000..1bbc33fe3ca7d
--- /dev/null
+++ b/docs/reference/esql/functions/types/to_dateperiod.asciidoc
@@ -0,0 +1,11 @@
+// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
+
+*Supported types*
+
+[%header.monospaced.styled,format=dsv,separator=|]
+|===
+field | result
+date_period | date_period
+keyword | date_period
+text | date_period
+|===
diff --git a/docs/reference/esql/functions/types/to_timeduration.asciidoc b/docs/reference/esql/functions/types/to_timeduration.asciidoc
new file mode 100644
index 0000000000000..b82a5bb4f9f87
--- /dev/null
+++ b/docs/reference/esql/functions/types/to_timeduration.asciidoc
@@ -0,0 +1,11 @@
+// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
+
+*Supported types*
+
+[%header.monospaced.styled,format=dsv,separator=|]
+|===
+field | result
+keyword | time_duration
+text | time_duration
+time_duration | time_duration
+|===
diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java
index 6f5297bbeef4d..d9d11c3568ab7 100644
--- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java
+++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java
@@ -609,6 +609,41 @@ public void testErrorMessageForInvalidParams() throws IOException {
assertThat(EntityUtils.toString(re.getResponse().getEntity()), containsString("Unknown query parameter [n0], did you mean [n1]"));
}
+ public void testErrorMessageForInvalidIntervalParams() throws IOException {
+ ResponseException re = expectThrows(
+ ResponseException.class,
+ () -> runEsqlSync(
+ requestObjectBuilder().query("row x = ?n1::datetime | eval y = x + ?n2::time_duration")
+ .params("[{\"n1\": \"2024-01-01\"}, {\"n2\": \"3 days\"}]")
+ )
+ );
+
+ String error = re.getMessage().replaceAll("\\\\\n\s+\\\\", "");
+ assertThat(
+ error,
+ containsString(
+ "Invalid interval value in [?n2::time_duration], expected integer followed by one of "
+ + "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3 days]"
+ )
+ );
+
+ re = expectThrows(
+ ResponseException.class,
+ () -> runEsqlSync(
+ requestObjectBuilder().query("row x = ?n1::datetime | eval y = x - ?n2::date_period")
+ .params("[{\"n1\": \"2024-01-01\"}, {\"n2\": \"3 hours\"}]")
+ )
+ );
+ error = re.getMessage().replaceAll("\\\\\n\s+\\\\", "");
+ assertThat(
+ error,
+ containsString(
+ "Invalid interval value in [?n2::date_period], expected integer followed by one of "
+ + "[DAY, DAYS, D, WEEK, WEEKS, W, MONTH, MONTHS, MO, QUARTER, QUARTERS, Q, YEAR, YEARS, YR, Y] but got [3 hours]"
+ )
+ );
+ }
+
public void testErrorMessageForLiteralDateMathOverflow() throws IOException {
List dateMathOverflowExpressions = List.of(
"2147483647 day + 1 day",
diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/convert.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/convert.csv-spec
index 42b5c0344b559..1397965145a1a 100644
--- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/convert.csv-spec
+++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/convert.csv-spec
@@ -214,3 +214,140 @@ from employees
emp_no:integer | languages:integer | height:double
10037 | 2 | 2.0
;
+
+convertToDatePeriod
+required_capability: cast_string_literal_to_temporal_amount
+//tag::castToDatePeriod[]
+row x = "2024-01-01"::datetime | eval y = x + "3 DAYS"::date_period, z = x - to_dateperiod("3 days");
+//end::castToDatePeriod[]
+
+//tag::castToDatePeriod-result[]
+x:datetime |y:datetime |z:datetime
+2024-01-01 |2024-01-04 |2023-12-29
+//end::castToDatePeriod-result[]
+;
+
+convertToTimeDuration
+required_capability: cast_string_literal_to_temporal_amount
+//tag::castToTimeDuration[]
+row x = "2024-01-01"::datetime | eval y = x + "3 hours"::time_duration, z = x - to_timeduration("3 hours");
+//end::castToTimeDuration[]
+
+//tag::castToTimeDuration-result[]
+x:datetime |y:datetime |z:datetime
+2024-01-01 |2024-01-01T03:00:00.000Z |2023-12-31T21:00:00.000Z
+//end::castToTimeDuration-result[]
+;
+
+convertToDatePeriodTimeDuration
+required_capability: cast_string_literal_to_temporal_amount
+row x = "2024-01-01"::datetime + "3 hours"::time_duration, y = "2024-01-01"::datetime - to_timeduration("3 hours"),
+z = "2024-01-01"::datetime + "3 DAYS"::date_period, w = "2024-01-01"::datetime - to_dateperiod("3 days"), u = "3 days",
+v = "3 hours"
+| eval a = "2024-01-01" + u::date_period, b = "2024-01-01" - v::time_duration
+| keep x, y, z, w, a, b;
+
+x:datetime |y:datetime |z:datetime |w:datetime |a:datetime |b:datetime
+2024-01-01T03:00:00.000Z |2023-12-31T21:00:00.000Z |2024-01-04T00:00:00.000Z |2023-12-29T00:00:00.000Z |2024-01-04T00:00:00.000Z |2023-12-31T21:00:00.000Z
+;
+
+convertToDatePeriodNested
+required_capability: cast_string_literal_to_temporal_amount
+row x = "2024-01-01"::datetime
+| eval y = x + to_dateperiod("3 days"::date_period)
+;
+
+x:datetime |y:datetime
+2024-01-01 |2024-01-04
+;
+
+convertToTimeDurationNested
+required_capability: cast_string_literal_to_temporal_amount
+row x = "2024-01-01"::datetime
+| eval y = x + to_timeduration("3 hours"::time_duration)
+;
+
+x:datetime |y:datetime
+2024-01-01 |2024-01-01T03:00:00.000Z
+;
+
+convertToDatePeriodFromIndex
+required_capability: cast_string_literal_to_temporal_amount
+FROM employees
+| WHERE emp_no == 10001
+| EVAL x = birth_date + "3 days"::date_period, y = birth_date - to_dateperiod("3 days")
+| KEEP birth_date, x, y;
+
+birth_date:datetime |x:datetime |y:datetime
+1953-09-02T00:00:00Z |1953-09-05T00:00:00Z |1953-08-30T00:00:00Z
+;
+
+convertToTimeDurationFromIndex
+required_capability: cast_string_literal_to_temporal_amount
+FROM employees
+| WHERE emp_no == 10001
+| EVAL x = birth_date + "3 hours"::time_duration, y = birth_date - to_timeduration("3 hours")
+| KEEP birth_date, x, y;
+
+birth_date:datetime |x:datetime |y:datetime
+1953-09-02T00:00:00Z |1953-09-02T03:00:00Z |1953-09-01T21:00:00Z
+;
+
+convertToDatePeriodTimeDurationRef
+required_capability: cast_string_literal_to_temporal_amount
+FROM employees
+| WHERE emp_no == 10001
+| EVAL interval_timeduration = "3 hours", x = birth_date + interval_timeduration::time_duration, y = birth_date - concat("3 ", "hours")::time_duration
+| EVAL interval_dateperiod = "3 months", z = birth_date + interval_dateperiod::date_period, w = birth_date - concat("3 ", "months")::date_period
+| EVAL a = "3", b = "hours", c = birth_date + concat(concat(a, " "), b)::time_duration
+| KEEP birth_date, x, y, z, w, c;
+
+birth_date:datetime |x:datetime |y:datetime |z:datetime |w:datetime |c:datetime
+1953-09-02T00:00:00Z |1953-09-02T03:00:00Z |1953-09-01T21:00:00Z |1953-12-02T00:00:00Z |1953-06-02T00:00:00Z |1953-09-02T03:00:00Z
+;
+
+convertToDatePeriodNull
+required_capability: cast_string_literal_to_temporal_amount
+FROM employees
+| WHERE emp_no == 10001
+| EVAL x = birth_date + null::date_period, y = birth_date - to_dateperiod(null), z = birth_date + to_string(null)::date_period
+| KEEP birth_date, x, y, z;
+
+birth_date:datetime |x:datetime |y:datetime |z:datetime
+1953-09-02T00:00:00Z |null |null |null
+;
+
+convertToTimeDurationNull
+required_capability: cast_string_literal_to_temporal_amount
+FROM employees
+| WHERE emp_no == 10001
+| EVAL x = birth_date + null::time_duration, y = birth_date - to_timeduration(null), z = birth_date + to_string(null)::time_duration
+| KEEP birth_date, x, y, z;
+
+birth_date:datetime |x:datetime |y:datetime |z:datetime
+1953-09-02T00:00:00Z |null |null |null
+;
+
+convertToDatePeriodIntegerLiteral
+required_capability: cast_string_literal_to_temporal_amount
+FROM employees
+| WHERE emp_no == 10001
+| EVAL x = birth_date + 3 days::date_period, y = birth_date - to_dateperiod(3 days),
+z = birth_date + 3 months + 3 days::date_period, w = birth_date + (3 months + 3 days)::date_period
+| KEEP birth_date, x, y, z, w;
+
+birth_date:datetime |x:datetime |y:datetime |z:datetime |w:datetime
+1953-09-02T00:00:00Z |1953-09-05T00:00:00Z |1953-08-30T00:00:00Z |1953-12-05T00:00:00Z |1953-12-05T00:00:00Z
+;
+
+convertToTimeDurationIntegerLiteral
+required_capability: cast_string_literal_to_temporal_amount
+FROM employees
+| WHERE emp_no == 10001
+| EVAL x = birth_date + 3 hours::time_duration, y = birth_date - to_timeduration(3 hours),
+z = birth_date + 3 hours + 3 minutes::time_duration, w = birth_date + (3 hours + 3 minutes)::time_duration
+| KEEP birth_date, x, y, z, w;
+
+birth_date:datetime |x:datetime |y:datetime |z:datetime |w:datetime
+1953-09-02T00:00:00Z |1953-09-02T03:00:00Z |1953-09-01T21:00:00Z |1953-09-02T03:03:00Z |1953-09-02T03:03:00Z
+;
diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/meta.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/meta.csv-spec
index bc90f7f616631..6909f0aeb42f5 100644
--- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/meta.csv-spec
+++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/meta.csv-spec
@@ -95,6 +95,7 @@ double tau()
"boolean to_boolean(field:boolean|keyword|text|double|long|unsigned_long|integer)"
"cartesian_point to_cartesianpoint(field:cartesian_point|keyword|text)"
"cartesian_shape to_cartesianshape(field:cartesian_point|cartesian_shape|keyword|text)"
+"date_period to_dateperiod(field:date_period|keyword|text)"
"date to_datetime(field:date|date_nanos|keyword|text|double|long|unsigned_long|integer)"
"double to_dbl(field:boolean|date|keyword|text|double|long|unsigned_long|integer|counter_double|counter_integer|counter_long)"
"double to_degrees(number:double|integer|long|unsigned_long)"
@@ -110,6 +111,7 @@ double tau()
"double to_radians(number:double|integer|long|unsigned_long)"
"keyword to_str(field:boolean|cartesian_point|cartesian_shape|date|date_nanos|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version)"
"keyword to_string(field:boolean|cartesian_point|cartesian_shape|date|date_nanos|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version)"
+"time_duration to_timeduration(field:time_duration|keyword|text)"
"unsigned_long to_ul(field:boolean|date|keyword|text|double|long|unsigned_long|integer)"
"unsigned_long to_ulong(field:boolean|date|keyword|text|double|long|unsigned_long|integer)"
"unsigned_long to_unsigned_long(field:boolean|date|keyword|text|double|long|unsigned_long|integer)"
@@ -221,6 +223,7 @@ to_bool |field |"boolean|keyword|text|double
to_boolean |field |"boolean|keyword|text|double|long|unsigned_long|integer" |Input value. The input can be a single- or multi-valued column or an expression.
to_cartesianpo|field |"cartesian_point|keyword|text" |Input value. The input can be a single- or multi-valued column or an expression.
to_cartesiansh|field |"cartesian_point|cartesian_shape|keyword|text" |Input value. The input can be a single- or multi-valued column or an expression.
+to_dateperiod |field |"date_period|keyword|text" |Input value. The input is a valid constant date period expression.
to_datetime |field |"date|date_nanos|keyword|text|double|long|unsigned_long|integer" |Input value. The input can be a single- or multi-valued column or an expression.
to_dbl |field |"boolean|date|keyword|text|double|long|unsigned_long|integer|counter_double|counter_integer|counter_long" |Input value. The input can be a single- or multi-valued column or an expression.
to_degrees |number |"double|integer|long|unsigned_long" |Input value. The input can be a single- or multi-valued column or an expression.
@@ -236,6 +239,7 @@ to_lower |str |"keyword|text"
to_radians |number |"double|integer|long|unsigned_long" |Input value. The input can be a single- or multi-valued column or an expression.
to_str |field |"boolean|cartesian_point|cartesian_shape|date|date_nanos|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version" |Input value. The input can be a single- or multi-valued column or an expression.
to_string |field |"boolean|cartesian_point|cartesian_shape|date|date_nanos|double|geo_point|geo_shape|integer|ip|keyword|long|text|unsigned_long|version" |Input value. The input can be a single- or multi-valued column or an expression.
+to_timeduratio|field |"time_duration|keyword|text" |Input value. The input is a valid constant time duration expression.
to_ul |field |"boolean|date|keyword|text|double|long|unsigned_long|integer" |Input value. The input can be a single- or multi-valued column or an expression.
to_ulong |field |"boolean|date|keyword|text|double|long|unsigned_long|integer" |Input value. The input can be a single- or multi-valued column or an expression.
to_unsigned_lo|field |"boolean|date|keyword|text|double|long|unsigned_long|integer" |Input value. The input can be a single- or multi-valued column or an expression.
@@ -347,6 +351,7 @@ to_bool |Converts an input value to a boolean value. A string value of *tr
to_boolean |Converts an input value to a boolean value. A string value of *true* will be case-insensitive converted to the Boolean *true*. For anything else, including the empty string, the function will return *false*. The numerical value of *0* will be converted to *false*, anything else will be converted to *true*.
to_cartesianpo|Converts an input value to a `cartesian_point` value. A string will only be successfully converted if it respects the {wikipedia}/Well-known_text_representation_of_geometry[WKT Point] format.
to_cartesiansh|Converts an input value to a `cartesian_shape` value. A string will only be successfully converted if it respects the {wikipedia}/Well-known_text_representation_of_geometry[WKT] format.
+to_dateperiod |Converts an input value into a `date_period` value.
to_datetime |Converts an input value to a date value. A string will only be successfully converted if it's respecting the format `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`. To convert dates in other formats, use <>.
to_dbl |Converts an input value to a double value. If the input parameter is of a date type, its value will be interpreted as milliseconds since the {wikipedia}/Unix_time[Unix epoch], converted to double. Boolean *true* will be converted to double *1.0*, *false* to *0.0*.
to_degrees |Converts a number in {wikipedia}/Radian[radians] to {wikipedia}/Degree_(angle)[degrees].
@@ -362,6 +367,7 @@ to_lower |Returns a new string representing the input string converted to l
to_radians |Converts a number in {wikipedia}/Degree_(angle)[degrees] to {wikipedia}/Radian[radians].
to_str |Converts an input value into a string.
to_string |Converts an input value into a string.
+to_timeduratio|Converts an input value into a `time_duration` value.
to_ul |Converts an input value to an unsigned long value. If the input parameter is of a date type, its value will be interpreted as milliseconds since the {wikipedia}/Unix_time[Unix epoch], converted to unsigned long. Boolean *true* will be converted to unsigned long *1*, *false* to *0*.
to_ulong |Converts an input value to an unsigned long value. If the input parameter is of a date type, its value will be interpreted as milliseconds since the {wikipedia}/Unix_time[Unix epoch], converted to unsigned long. Boolean *true* will be converted to unsigned long *1*, *false* to *0*.
to_unsigned_lo|Converts an input value to an unsigned long value. If the input parameter is of a date type, its value will be interpreted as milliseconds since the {wikipedia}/Unix_time[Unix epoch], converted to unsigned long. Boolean *true* will be converted to unsigned long *1*, *false* to *0*.
@@ -475,6 +481,7 @@ to_bool |boolean
to_boolean |boolean |false |false |false
to_cartesianpo|cartesian_point |false |false |false
to_cartesiansh|cartesian_shape |false |false |false
+to_dateperiod |date_period |false |false |false
to_datetime |date |false |false |false
to_dbl |double |false |false |false
to_degrees |double |false |false |false
@@ -490,6 +497,7 @@ to_lower |"keyword|text"
to_radians |double |false |false |false
to_str |keyword |false |false |false
to_string |keyword |false |false |false
+to_timeduratio|time_duration |false |false |false
to_ul |unsigned_long |false |false |false
to_ulong |unsigned_long |false |false |false
to_unsigned_lo|unsigned_long |false |false |false
@@ -516,5 +524,5 @@ countFunctions#[skip:-8.15.99]
meta functions | stats a = count(*), b = count(*), c = count(*) | mv_expand c;
a:long | b:long | c:long
-117 | 117 | 117
+119 | 119 | 119
;
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
index 858e2a3332bf8..c0c5ebf010ffd 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
@@ -289,7 +289,12 @@ public enum Cap {
/**
* Support for requesting the "SPACE" function.
*/
- SPACE;
+ SPACE,
+
+ /**
+ * Support explicit casting from string literal to DATE_PERIOD or TIME_DURATION.
+ */
+ CAST_STRING_LITERAL_TO_TEMPORAL_AMOUNT;
private final boolean snapshotOnly;
private final FeatureFlag featureFlag;
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java
index f295c4b64bd8d..9714d3fce6d9f 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java
@@ -394,7 +394,12 @@ private static void checkEvalFields(LogicalPlan p, Set failures) {
DataType dataType = field.dataType();
if (DataType.isRepresentable(dataType) == false) {
failures.add(
- fail(field, "EVAL does not support type [{}] in expression [{}]", dataType.typeName(), field.child().sourceText())
+ fail(
+ field,
+ "EVAL does not support type [{}] as the return data type of expression [{}]",
+ dataType.typeName(),
+ field.child().sourceText()
+ )
);
}
// check no aggregate functions are used
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java
index ea7d601369bc7..49076a1d65e72 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java
@@ -41,6 +41,7 @@
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToBoolean;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToCartesianPoint;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToCartesianShape;
+import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDatePeriod;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDatetime;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDegrees;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDouble;
@@ -51,6 +52,7 @@
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToLong;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToRadians;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToString;
+import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToTimeDuration;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToUnsignedLong;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToVersion;
import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateDiff;
@@ -343,6 +345,7 @@ private FunctionDefinition[][] functions() {
def(ToBoolean.class, ToBoolean::new, "to_boolean", "to_bool"),
def(ToCartesianPoint.class, ToCartesianPoint::new, "to_cartesianpoint"),
def(ToCartesianShape.class, ToCartesianShape::new, "to_cartesianshape"),
+ def(ToDatePeriod.class, ToDatePeriod::new, "to_dateperiod"),
def(ToDatetime.class, ToDatetime::new, "to_datetime", "to_dt"),
def(ToDegrees.class, ToDegrees::new, "to_degrees"),
def(ToDouble.class, ToDouble::new, "to_double", "to_dbl"),
@@ -353,6 +356,7 @@ private FunctionDefinition[][] functions() {
def(ToLong.class, ToLong::new, "to_long"),
def(ToRadians.class, ToRadians::new, "to_radians"),
def(ToString.class, ToString::new, "to_string", "to_str"),
+ def(ToTimeDuration.class, ToTimeDuration::new, "to_timeduration"),
def(ToUnsignedLong.class, ToUnsignedLong::new, "to_unsigned_long", "to_ulong", "to_ul"),
def(ToVersion.class, ToVersion::new, "to_version", "to_ver"), },
// multivalue functions
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/AbstractConvertFunction.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/AbstractConvertFunction.java
index cf97558cd2676..2795ac857983c 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/AbstractConvertFunction.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/AbstractConvertFunction.java
@@ -72,7 +72,7 @@ protected final ExpressionEvaluator.Factory evaluator(ExpressionEvaluator.Factor
}
@Override
- protected final TypeResolution resolveType() {
+ protected TypeResolution resolveType() {
if (childrenResolved() == false) {
return new TypeResolution("Unresolved children");
}
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/FoldablesConvertFunction.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/FoldablesConvertFunction.java
new file mode 100644
index 0000000000000..6e2b5bb63532d
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/FoldablesConvertFunction.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.convert;
+
+import org.elasticsearch.common.io.stream.StreamOutput;
+import org.elasticsearch.xpack.esql.capabilities.Validatable;
+import org.elasticsearch.xpack.esql.common.Failures;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.core.type.DataType;
+
+import java.util.Locale;
+import java.util.Map;
+
+import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isType;
+import static org.elasticsearch.xpack.esql.core.type.DataType.isString;
+import static org.elasticsearch.xpack.esql.expression.Validations.isFoldable;
+import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.foldToTemporalAmount;
+
+/**
+ * Base class for functions that converts a constant into an interval type - DATE_PERIOD or TIME_DURATION.
+ * The functions will be folded at the end of LogicalPlanOptimizer by the coordinator, it does not reach data node.
+ */
+public abstract class FoldablesConvertFunction extends AbstractConvertFunction implements Validatable {
+
+ protected FoldablesConvertFunction(Source source, Expression field) {
+ super(source, field);
+ }
+
+ @Override
+ public final void writeTo(StreamOutput out) {
+ throw new UnsupportedOperationException("not serialized");
+ }
+
+ @Override
+ public final String getWriteableName() {
+ throw new UnsupportedOperationException("not serialized");
+ }
+
+ @Override
+ protected final TypeResolution resolveType() {
+ if (childrenResolved() == false) {
+ return new TypeResolution("Unresolved children");
+ }
+ return isType(
+ field(),
+ dt -> isString(dt) || dt == dataType(),
+ sourceText(),
+ null,
+ false,
+ dataType().typeName().toLowerCase(Locale.ROOT) + " or string"
+ );
+ }
+
+ @Override
+ protected final Map factories() {
+ // TODO if a union type field is provided as an input, the correct error message is not shown, #112668 is a follow up
+ return Map.of();
+ }
+
+ @Override
+ public final Object fold() {
+ return foldToTemporalAmount(field(), sourceText(), dataType());
+ }
+
+ @Override
+ public final void validate(Failures failures) {
+ failures.add(isFoldable(field(), sourceText(), null));
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatePeriod.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatePeriod.java
new file mode 100644
index 0000000000000..86b46c792c85b
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatePeriod.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.convert;
+
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.core.type.DataType;
+import org.elasticsearch.xpack.esql.expression.function.Example;
+import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
+import org.elasticsearch.xpack.esql.expression.function.Param;
+
+import java.util.List;
+
+import static org.elasticsearch.xpack.esql.core.type.DataType.DATE_PERIOD;
+
+public class ToDatePeriod extends FoldablesConvertFunction {
+
+ @FunctionInfo(
+ returnType = "date_period",
+ description = "Converts an input value into a `date_period` value.",
+ examples = @Example(file = "convert", tag = "castToDatePeriod")
+ )
+ public ToDatePeriod(
+ Source source,
+ @Param(
+ name = "field",
+ type = { "date_period", "keyword", "text" },
+ description = "Input value. The input is a valid constant date period expression."
+ ) Expression v
+ ) {
+ super(source, v);
+ }
+
+ @Override
+ public DataType dataType() {
+ return DATE_PERIOD;
+ }
+
+ @Override
+ public Expression replaceChildren(List newChildren) {
+ return new ToDatePeriod(source(), newChildren.get(0));
+ }
+
+ @Override
+ protected NodeInfo extends Expression> info() {
+ return NodeInfo.create(this, ToDatePeriod::new, field());
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToTimeDuration.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToTimeDuration.java
new file mode 100644
index 0000000000000..95425deccdda1
--- /dev/null
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToTimeDuration.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.convert;
+
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.core.type.DataType;
+import org.elasticsearch.xpack.esql.expression.function.Example;
+import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
+import org.elasticsearch.xpack.esql.expression.function.Param;
+
+import java.util.List;
+
+import static org.elasticsearch.xpack.esql.core.type.DataType.TIME_DURATION;
+
+public class ToTimeDuration extends FoldablesConvertFunction {
+
+ @FunctionInfo(
+ returnType = "time_duration",
+ description = "Converts an input value into a `time_duration` value.",
+ examples = @Example(file = "convert", tag = "castToTimeDuration")
+ )
+ public ToTimeDuration(
+ Source source,
+ @Param(
+ name = "field",
+ type = { "time_duration", "keyword", "text" },
+ description = "Input value. The input is a valid constant time duration expression."
+ ) Expression v
+ ) {
+ super(source, v);
+ }
+
+ @Override
+ public DataType dataType() {
+ return TIME_DURATION;
+ }
+
+ @Override
+ public Expression replaceChildren(List newChildren) {
+ return new ToTimeDuration(source(), newChildren.get(0));
+ }
+
+ @Override
+ protected NodeInfo extends Expression> info() {
+ return NodeInfo.create(this, ToTimeDuration::new, field());
+ }
+}
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java
index 2621c76805591..cae0f3e084d54 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java
@@ -83,7 +83,7 @@
import static org.elasticsearch.xpack.esql.parser.ParserUtils.typedParsing;
import static org.elasticsearch.xpack.esql.parser.ParserUtils.visitList;
import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.bigIntegerToUnsignedLong;
-import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.parseTemporalAmout;
+import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.parseTemporalAmount;
import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.stringToIntegral;
public abstract class ExpressionBuilder extends IdentifierBuilder {
@@ -458,7 +458,7 @@ public Object visitQualifiedIntegerLiteral(EsqlBaseParser.QualifiedIntegerLitera
String qualifier = ctx.UNQUOTED_IDENTIFIER().getText().toLowerCase(Locale.ROOT);
try {
- TemporalAmount quantity = parseTemporalAmout(value, qualifier, source);
+ TemporalAmount quantity = parseTemporalAmount(value, qualifier, source);
return new Literal(source, quantity, quantity instanceof Duration ? TIME_DURATION : DATE_PERIOD);
} catch (InvalidArgumentException | ArithmeticException e) {
// the range varies by unit: Duration#ofMinutes(), #ofHours() will Math#multiplyExact() to reduce the unit to seconds;
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/type/EsqlDataTypeConverter.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/type/EsqlDataTypeConverter.java
index b090708a64ad3..0c530bd0eb273 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/type/EsqlDataTypeConverter.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/type/EsqlDataTypeConverter.java
@@ -10,12 +10,14 @@
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
+import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.lucene.BytesRefs;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.xpack.esql.core.InvalidArgumentException;
import org.elasticsearch.xpack.esql.core.QlIllegalArgumentException;
import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.expression.Expressions;
import org.elasticsearch.xpack.esql.core.tree.Source;
import org.elasticsearch.xpack.esql.core.type.Converter;
import org.elasticsearch.xpack.esql.core.type.DataType;
@@ -26,6 +28,7 @@
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToBoolean;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToCartesianPoint;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToCartesianShape;
+import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDatePeriod;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDatetime;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToDouble;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToGeoPoint;
@@ -34,6 +37,7 @@
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToInteger;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToLong;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToString;
+import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToTimeDuration;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToUnsignedLong;
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ToVersion;
import org.elasticsearch.xpack.esql.parser.ParsingException;
@@ -48,6 +52,7 @@
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalAmount;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.BiFunction;
@@ -110,9 +115,83 @@ public class EsqlDataTypeConverter {
entry(KEYWORD, ToString::new),
entry(TEXT, ToString::new),
entry(UNSIGNED_LONG, ToUnsignedLong::new),
- entry(VERSION, ToVersion::new)
+ entry(VERSION, ToVersion::new),
+ entry(DATE_PERIOD, ToDatePeriod::new),
+ entry(TIME_DURATION, ToTimeDuration::new)
);
+ public enum INTERVALS {
+ // TIME_DURATION,
+ MILLISECOND,
+ MILLISECONDS,
+ MS,
+ SECOND,
+ SECONDS,
+ SEC,
+ S,
+ MINUTE,
+ MINUTES,
+ MIN,
+ HOUR,
+ HOURS,
+ H,
+ // DATE_PERIOD
+ DAY,
+ DAYS,
+ D,
+ WEEK,
+ WEEKS,
+ W,
+ MONTH,
+ MONTHS,
+ MO,
+ QUARTER,
+ QUARTERS,
+ Q,
+ YEAR,
+ YEARS,
+ YR,
+ Y;
+ }
+
+ public static List TIME_DURATIONS = List.of(
+ INTERVALS.MILLISECOND,
+ INTERVALS.MILLISECONDS,
+ INTERVALS.MS,
+ INTERVALS.SECOND,
+ INTERVALS.SECONDS,
+ INTERVALS.SEC,
+ INTERVALS.S,
+ INTERVALS.MINUTE,
+ INTERVALS.MINUTES,
+ INTERVALS.MIN,
+ INTERVALS.HOUR,
+ INTERVALS.HOURS,
+ INTERVALS.H
+ );
+
+ public static List DATE_PERIODS = List.of(
+ INTERVALS.DAY,
+ INTERVALS.DAYS,
+ INTERVALS.D,
+ INTERVALS.WEEK,
+ INTERVALS.WEEKS,
+ INTERVALS.W,
+ INTERVALS.MONTH,
+ INTERVALS.MONTHS,
+ INTERVALS.MO,
+ INTERVALS.QUARTER,
+ INTERVALS.QUARTERS,
+ INTERVALS.Q,
+ INTERVALS.YEAR,
+ INTERVALS.YEARS,
+ INTERVALS.YR,
+ INTERVALS.Y
+ );
+
+ public static final String INVALID_INTERVAL_ERROR =
+ "Invalid interval value in [{}], expected integer followed by one of {} but got [{}]";
+
public static Converter converterFor(DataType from, DataType to) {
// TODO move EXPRESSION_TO_LONG here if there is no regression
if (isString(from)) {
@@ -154,6 +233,38 @@ public static Converter converterFor(DataType from, DataType to) {
return null;
}
+ public static TemporalAmount foldToTemporalAmount(Expression field, String sourceText, DataType expectedType) {
+ if (field.foldable()) {
+ Object v = field.fold();
+ if (v instanceof BytesRef b) {
+ try {
+ return EsqlDataTypeConverter.parseTemporalAmount(b.utf8ToString(), expectedType);
+ } catch (ParsingException e) {
+ throw new IllegalArgumentException(
+ LoggerMessageFormat.format(
+ null,
+ INVALID_INTERVAL_ERROR,
+ sourceText,
+ expectedType == DATE_PERIOD ? DATE_PERIODS : TIME_DURATIONS,
+ b.utf8ToString()
+ )
+ );
+ }
+ } else if (v instanceof TemporalAmount t) {
+ return t;
+ }
+ }
+
+ throw new IllegalArgumentException(
+ LoggerMessageFormat.format(
+ null,
+ "argument of [{}] must be a constant, received [{}]",
+ field.sourceText(),
+ Expressions.name(field)
+ )
+ );
+ }
+
public static TemporalAmount parseTemporalAmount(Object val, DataType expectedType) {
String errorMessage = "Cannot parse [{}] to {}";
String str = String.valueOf(val);
@@ -181,7 +292,7 @@ public static TemporalAmount parseTemporalAmount(Object val, DataType expectedTy
if ((value.isEmpty() || qualifier.isEmpty()) == false) {
try {
- TemporalAmount result = parseTemporalAmout(Integer.parseInt(value.toString()), qualifier.toString(), Source.EMPTY);
+ TemporalAmount result = parseTemporalAmount(Integer.parseInt(value.toString()), qualifier.toString(), Source.EMPTY);
if (DataType.DATE_PERIOD == expectedType && result instanceof Period
|| DataType.TIME_DURATION == expectedType && result instanceof Duration) {
return result;
@@ -196,7 +307,6 @@ public static TemporalAmount parseTemporalAmount(Object val, DataType expectedTy
// wrong pattern
}
}
-
throw new ParsingException(Source.EMPTY, errorMessage, val, expectedType);
}
@@ -284,22 +394,24 @@ public static DataType commonType(DataType left, DataType right) {
}
// generally supporting abbreviations from https://en.wikipedia.org/wiki/Unit_of_time
- public static TemporalAmount parseTemporalAmout(Number value, String qualifier, Source source) throws InvalidArgumentException,
+ public static TemporalAmount parseTemporalAmount(Number value, String qualifier, Source source) throws InvalidArgumentException,
ArithmeticException, ParsingException {
- return switch (qualifier) {
- case "millisecond", "milliseconds", "ms" -> Duration.ofMillis(safeToLong(value));
- case "second", "seconds", "sec", "s" -> Duration.ofSeconds(safeToLong(value));
- case "minute", "minutes", "min" -> Duration.ofMinutes(safeToLong(value));
- case "hour", "hours", "h" -> Duration.ofHours(safeToLong(value));
-
- case "day", "days", "d" -> Period.ofDays(safeToInt(safeToLong(value)));
- case "week", "weeks", "w" -> Period.ofWeeks(safeToInt(safeToLong(value)));
- case "month", "months", "mo" -> Period.ofMonths(safeToInt(safeToLong(value)));
- case "quarter", "quarters", "q" -> Period.ofMonths(safeToInt(Math.multiplyExact(3L, safeToLong(value))));
- case "year", "years", "yr", "y" -> Period.ofYears(safeToInt(safeToLong(value)));
-
- default -> throw new ParsingException(source, "Unexpected time interval qualifier: '{}'", qualifier);
- };
+ try {
+ return switch (INTERVALS.valueOf(qualifier.toUpperCase(Locale.ROOT))) {
+ case MILLISECOND, MILLISECONDS, MS -> Duration.ofMillis(safeToLong(value));
+ case SECOND, SECONDS, SEC, S -> Duration.ofSeconds(safeToLong(value));
+ case MINUTE, MINUTES, MIN -> Duration.ofMinutes(safeToLong(value));
+ case HOUR, HOURS, H -> Duration.ofHours(safeToLong(value));
+
+ case DAY, DAYS, D -> Period.ofDays(safeToInt(safeToLong(value)));
+ case WEEK, WEEKS, W -> Period.ofWeeks(safeToInt(safeToLong(value)));
+ case MONTH, MONTHS, MO -> Period.ofMonths(safeToInt(safeToLong(value)));
+ case QUARTER, QUARTERS, Q -> Period.ofMonths(safeToInt(Math.multiplyExact(3L, safeToLong(value))));
+ case YEAR, YEARS, YR, Y -> Period.ofYears(safeToInt(safeToLong(value)));
+ };
+ } catch (IllegalArgumentException e) {
+ throw new ParsingException(source, "Unexpected time interval qualifier: '{}'", qualifier);
+ }
}
/**
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java
index b50b801785a9f..4cf6ae2c3986b 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java
@@ -44,6 +44,9 @@ public class VerifierTests extends ESTestCase {
private final Analyzer defaultAnalyzer = AnalyzerTestUtils.expandedDefaultAnalyzer();
private final Analyzer tsdb = AnalyzerTestUtils.analyzer(AnalyzerTestUtils.tsdbIndexResolution());
+ private final List TIME_DURATIONS = List.of("millisecond", "second", "minute", "hour");
+ private final List DATE_PERIODS = List.of("day", "week", "month", "year");
+
public void testIncompatibleTypesInMathOperation() {
assertEquals(
"1:40: second argument of [a + c] must be [datetime or numeric], found value [c] type [keyword]",
@@ -677,42 +680,171 @@ public void testWrongInputParam() {
}
public void testPeriodAndDurationInRowAssignment() {
- for (var unit : List.of("millisecond", "second", "minute", "hour", "day", "week", "month", "year")) {
+ for (var unit : TIME_DURATIONS) {
assertEquals("1:5: cannot use [1 " + unit + "] directly in a row assignment", error("row a = 1 " + unit));
+ assertEquals(
+ "1:5: cannot use [1 " + unit + "::time_duration] directly in a row assignment",
+ error("row a = 1 " + unit + "::time_duration")
+ );
+ assertEquals(
+ "1:5: cannot use [\"1 " + unit + "\"::time_duration] directly in a row assignment",
+ error("row a = \"1 " + unit + "\"::time_duration")
+ );
+ assertEquals(
+ "1:5: cannot use [to_timeduration(1 " + unit + ")] directly in a row assignment",
+ error("row a = to_timeduration(1 " + unit + ")")
+ );
+ assertEquals(
+ "1:5: cannot use [to_timeduration(\"1 " + unit + "\")] directly in a row assignment",
+ error("row a = to_timeduration(\"1 " + unit + "\")")
+ );
+ }
+ for (var unit : DATE_PERIODS) {
+ assertEquals("1:5: cannot use [1 " + unit + "] directly in a row assignment", error("row a = 1 " + unit));
+ assertEquals(
+ "1:5: cannot use [1 " + unit + "::date_period] directly in a row assignment",
+ error("row a = 1 " + unit + "::date_period")
+ );
+ assertEquals(
+ "1:5: cannot use [\"1 " + unit + "\"::date_period] directly in a row assignment",
+ error("row a = \"1 " + unit + "\"::date_period")
+ );
+ assertEquals(
+ "1:5: cannot use [to_dateperiod(1 " + unit + ")] directly in a row assignment",
+ error("row a = to_dateperiod(1 " + unit + ")")
+ );
+ assertEquals(
+ "1:5: cannot use [to_dateperiod(\"1 " + unit + "\")] directly in a row assignment",
+ error("row a = to_dateperiod(\"1 " + unit + "\")")
+ );
}
}
public void testSubtractDateTimeFromTemporal() {
- for (var unit : List.of("millisecond", "second", "minute", "hour")) {
+ for (var unit : TIME_DURATIONS) {
assertEquals(
- "1:5: [-] arguments are in unsupported order: cannot subtract a [DATETIME] value [now()] from a [TIME_DURATION] amount [1 "
+ "1:5: [-] arguments are in unsupported order: cannot subtract a [DATETIME] value [now()] "
+ + "from a [TIME_DURATION] amount [1 "
+ unit
+ "]",
error("row 1 " + unit + " - now() ")
);
+ assertEquals(
+ "1:5: [-] arguments are in unsupported order: cannot subtract a [DATETIME] value [now()] "
+ + "from a [TIME_DURATION] amount [1 "
+ + unit
+ + "::time_duration]",
+ error("row 1 " + unit + "::time_duration" + " - now() ")
+ );
+ assertEquals(
+ "1:5: [-] arguments are in unsupported order: cannot subtract a [DATETIME] value [now()] "
+ + "from a [TIME_DURATION] amount [\"1 "
+ + unit
+ + "\"::time_duration]",
+ error("row \"1 " + unit + "\"::time_duration" + " - now() ")
+ );
+ assertEquals(
+ "1:5: [-] arguments are in unsupported order: cannot subtract a [DATETIME] value [now()] "
+ + "from a [TIME_DURATION] amount [to_timeduration(1 "
+ + unit
+ + ")]",
+ error("row to_timeduration(1 " + unit + ") - now() ")
+ );
+ assertEquals(
+ "1:5: [-] arguments are in unsupported order: cannot subtract a [DATETIME] value [now()] "
+ + "from a [TIME_DURATION] amount [to_timeduration(\"1 "
+ + unit
+ + "\")]",
+ error("row to_timeduration(\"1 " + unit + "\") - now() ")
+ );
}
- for (var unit : List.of("day", "week", "month", "year")) {
+ for (var unit : DATE_PERIODS) {
assertEquals(
- "1:5: [-] arguments are in unsupported order: cannot subtract a [DATETIME] value [now()] from a [DATE_PERIOD] amount [1 "
+ "1:5: [-] arguments are in unsupported order: cannot subtract a [DATETIME] value [now()] "
+ + "from a [DATE_PERIOD] amount [1 "
+ unit
+ "]",
error("row 1 " + unit + " - now() ")
);
+ assertEquals(
+ "1:5: [-] arguments are in unsupported order: cannot subtract a [DATETIME] value [now()] "
+ + "from a [DATE_PERIOD] amount [1 "
+ + unit
+ + "::date_period]",
+ error("row 1 " + unit + "::date_period" + " - now() ")
+ );
+ assertEquals(
+ "1:5: [-] arguments are in unsupported order: cannot subtract a [DATETIME] value [now()] "
+ + "from a [DATE_PERIOD] amount [\"1 "
+ + unit
+ + "\"::date_period]",
+ error("row \"1 " + unit + "\"::date_period" + " - now() ")
+ );
+ assertEquals(
+ "1:5: [-] arguments are in unsupported order: cannot subtract a [DATETIME] value [now()] "
+ + "from a [DATE_PERIOD] amount [to_dateperiod(1 "
+ + unit
+ + ")]",
+ error("row to_dateperiod(1 " + unit + ") - now() ")
+ );
+ assertEquals(
+ "1:5: [-] arguments are in unsupported order: cannot subtract a [DATETIME] value [now()] "
+ + "from a [DATE_PERIOD] amount [to_dateperiod(\"1 "
+ + unit
+ + "\")]",
+ error("row to_dateperiod(\"1 " + unit + "\") - now() ")
+ );
}
}
public void testPeriodAndDurationInEval() {
- for (var unit : List.of("millisecond", "second", "minute", "hour")) {
+ for (var unit : TIME_DURATIONS) {
assertEquals(
- "1:18: EVAL does not support type [time_duration] in expression [1 " + unit + "]",
+ "1:18: EVAL does not support type [time_duration] as the return data type of expression [1 " + unit + "]",
error("row x = 1 | eval y = 1 " + unit)
);
+ assertEquals(
+ "1:18: EVAL does not support type [time_duration] as the return data type of expression [1 " + unit + "::time_duration]",
+ error("row x = 1 | eval y = 1 " + unit + "::time_duration")
+ );
+ assertEquals(
+ "1:18: EVAL does not support type [time_duration] as the return data type of expression [\"1 "
+ + unit
+ + "\"::time_duration]",
+ error("row x = 1 | eval y = \"1 " + unit + "\"::time_duration")
+ );
+ assertEquals(
+ "1:18: EVAL does not support type [time_duration] as the return data type of expression [to_timeduration(1 " + unit + ")]",
+ error("row x = 1 | eval y = to_timeduration(1 " + unit + ")")
+ );
+ assertEquals(
+ "1:18: EVAL does not support type [time_duration] as the return data type of expression [to_timeduration(\"1 "
+ + unit
+ + "\")]",
+ error("row x = 1 | eval y = to_timeduration(\"1 " + unit + "\")")
+ );
}
- for (var unit : List.of("day", "week", "month", "year")) {
+ for (var unit : DATE_PERIODS) {
assertEquals(
- "1:18: EVAL does not support type [date_period] in expression [1 " + unit + "]",
+ "1:18: EVAL does not support type [date_period] as the return data type of expression [1 " + unit + "]",
error("row x = 1 | eval y = 1 " + unit)
);
+ assertEquals(
+ "1:18: EVAL does not support type [date_period] as the return data type of expression [1 " + unit + "::date_period]",
+ error("row x = 1 | eval y = 1 " + unit + "::date_period")
+ );
+ assertEquals(
+ "1:18: EVAL does not support type [date_period] as the return data type of expression [\"1 " + unit + "\"::date_period]",
+ error("row x = 1 | eval y = \"1 " + unit + "\"::date_period")
+ );
+ assertEquals(
+ "1:18: EVAL does not support type [date_period] as the return data type of expression [to_dateperiod(1 " + unit + ")]",
+ error("row x = 1 | eval y = to_dateperiod(1 " + unit + ")")
+ );
+ assertEquals(
+ "1:18: EVAL does not support type [date_period] as the return data type of expression [to_dateperiod(\"1 " + unit + "\")]",
+ error("row x = 1 | eval y = to_dateperiod(\"1 " + unit + "\")")
+ );
}
}
@@ -722,6 +854,14 @@ public void testFilterNonBoolField() {
public void testFilterDateConstant() {
assertEquals("1:19: Condition expression needs to be boolean, found [DATE_PERIOD]", error("from test | where 1 year"));
+ assertEquals(
+ "1:19: Condition expression needs to be boolean, found [DATE_PERIOD]",
+ error("from test | where \"1 year\"::date_period")
+ );
+ assertEquals(
+ "1:19: Condition expression needs to be boolean, found [DATE_PERIOD]",
+ error("from test | where to_dateperiod(\"1 year\")")
+ );
}
public void testNestedAggField() {
@@ -1055,10 +1195,91 @@ public void testCoalesceWithMixedNumericTypes() {
);
}
- public void test() {
+ public void testToDatePeriodTimeDurationInInvalidPosition() {
+ // arithmetic operations in eval
assertEquals(
- "1:23: second argument of [coalesce(network.bytes_in, 0)] must be [counter_long], found value [0] type [integer]",
- error("FROM tests | eval x = coalesce(network.bytes_in, 0)", tsdb)
+ "1:39: EVAL does not support type [date_period] as the return data type of expression [3 months + 5 days]",
+ error("row x = \"2024-01-01\"::datetime | eval y = 3 months + 5 days")
+ );
+
+ assertEquals(
+ "1:39: EVAL does not support type [date_period] as the return data type of expression "
+ + "[\"3 months\"::date_period + \"5 days\"::date_period]",
+ error("row x = \"2024-01-01\"::datetime | eval y = \"3 months\"::date_period + \"5 days\"::date_period")
+ );
+
+ assertEquals(
+ "1:39: EVAL does not support type [time_duration] as the return data type of expression [3 hours + 5 minutes]",
+ error("row x = \"2024-01-01\"::datetime | eval y = 3 hours + 5 minutes")
+ );
+
+ assertEquals(
+ "1:39: EVAL does not support type [time_duration] as the return data type of expression "
+ + "[\"3 hours\"::time_duration + \"5 minutes\"::time_duration]",
+ error("row x = \"2024-01-01\"::datetime | eval y = \"3 hours\"::time_duration + \"5 minutes\"::time_duration")
+ );
+
+ // where
+ assertEquals(
+ "1:26: first argument of [\"3 days\"::date_period == to_dateperiod(\"3 days\")] must be "
+ + "[boolean, cartesian_point, cartesian_shape, date_nanos, datetime, double, geo_point, geo_shape, integer, ip, keyword, "
+ + "long, text, unsigned_long or version], found value [\"3 days\"::date_period] type [date_period]",
+ error("row x = \"3 days\" | where \"3 days\"::date_period == to_dateperiod(\"3 days\")")
+ );
+
+ assertEquals(
+ "1:26: first argument of [\"3 hours\"::time_duration <= to_timeduration(\"3 hours\")] must be "
+ + "[date_nanos, datetime, double, integer, ip, keyword, long, text, unsigned_long or version], "
+ + "found value [\"3 hours\"::time_duration] type [time_duration]",
+ error("row x = \"3 days\" | where \"3 hours\"::time_duration <= to_timeduration(\"3 hours\")")
+ );
+
+ assertEquals(
+ "1:19: second argument of [first_name <= to_timeduration(\"3 hours\")] must be "
+ + "[date_nanos, datetime, double, integer, ip, keyword, long, text, unsigned_long or version], "
+ + "found value [to_timeduration(\"3 hours\")] type [time_duration]",
+ error("from test | where first_name <= to_timeduration(\"3 hours\")")
+ );
+
+ assertEquals(
+ "1:19: 1st argument of [first_name IN ( to_timeduration(\"3 hours\"), \"3 days\"::date_period)] must be [keyword], "
+ + "found value [to_timeduration(\"3 hours\")] type [time_duration]",
+ error("from test | where first_name IN ( to_timeduration(\"3 hours\"), \"3 days\"::date_period)")
+ );
+ }
+
+ public void testToDatePeriodToTimeDurationWithInvalidType() {
+ assertEquals(
+ "1:36: argument of [1.5::date_period] must be [date_period or string], found value [1.5] type [double]",
+ error("from types | EVAL x = birth_date + 1.5::date_period")
+ );
+ assertEquals(
+ "1:37: argument of [to_timeduration(1)] must be [time_duration or string], found value [1] type [integer]",
+ error("from types | EVAL x = birth_date - to_timeduration(1)")
+ );
+ assertEquals(
+ "1:45: argument of [x::date_period] must be [date_period or string], found value [x] type [double]",
+ error("from types | EVAL x = 1.5, y = birth_date + x::date_period")
+ );
+ assertEquals(
+ "1:44: argument of [to_timeduration(x)] must be [time_duration or string], found value [x] type [integer]",
+ error("from types | EVAL x = 1, y = birth_date - to_timeduration(x)")
+ );
+ assertEquals(
+ "1:64: argument of [x::date_period] must be [date_period or string], found value [x] type [datetime]",
+ error("from types | EVAL x = \"2024-09-08\"::datetime, y = birth_date + x::date_period")
+ );
+ assertEquals(
+ "1:65: argument of [to_timeduration(x)] must be [time_duration or string], found value [x] type [datetime]",
+ error("from types | EVAL x = \"2024-09-08\"::datetime, y = birth_date - to_timeduration(x)")
+ );
+ assertEquals(
+ "1:58: argument of [x::date_period] must be [date_period or string], found value [x] type [ip]",
+ error("from types | EVAL x = \"2024-09-08\"::ip, y = birth_date + x::date_period")
+ );
+ assertEquals(
+ "1:59: argument of [to_timeduration(x)] must be [time_duration or string], found value [x] type [ip]",
+ error("from types | EVAL x = \"2024-09-08\"::ip, y = birth_date - to_timeduration(x)")
);
}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatePeriodTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatePeriodTests.java
new file mode 100644
index 0000000000000..c7e18e453df0c
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatePeriodTests.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.convert;
+
+import com.carrotsearch.randomizedtesting.annotations.Name;
+import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
+
+import org.apache.lucene.util.BytesRef;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.core.type.DataType;
+import org.elasticsearch.xpack.esql.expression.function.AbstractScalarFunctionTestCase;
+import org.elasticsearch.xpack.esql.expression.function.FunctionName;
+import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier;
+import org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter;
+
+import java.time.Period;
+import java.time.temporal.TemporalAmount;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Supplier;
+
+import static org.elasticsearch.xpack.esql.EsqlTestUtils.randomLiteral;
+import static org.elasticsearch.xpack.esql.core.type.DataType.DATE_PERIOD;
+import static org.elasticsearch.xpack.esql.core.type.DataType.KEYWORD;
+import static org.elasticsearch.xpack.esql.core.type.DataType.TEXT;
+import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.DATE_PERIODS;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.matchesPattern;
+
+@FunctionName("to_dateperiod")
+public class ToDatePeriodTests extends AbstractScalarFunctionTestCase {
+ public ToDatePeriodTests(@Name("TestCase") Supplier testCaseSupplier) {
+ this.testCase = testCaseSupplier.get();
+ }
+
+ @ParametersFactory
+ public static Iterable parameters() {
+ List suppliers = new ArrayList<>();
+
+ suppliers.add(new TestCaseSupplier(List.of(DATE_PERIOD), () -> {
+ Period field = (Period) randomLiteral(DATE_PERIOD).value();
+ return new TestCaseSupplier.TestCase(
+ List.of(new TestCaseSupplier.TypedData(field, DATE_PERIOD, "field").forceLiteral()),
+ matchesPattern("LiteralsEvaluator.*"),
+ DATE_PERIOD,
+ equalTo(field)
+ );
+ }));
+
+ for (EsqlDataTypeConverter.INTERVALS interval : DATE_PERIODS) {
+ for (DataType inputType : List.of(KEYWORD, TEXT)) {
+ suppliers.add(new TestCaseSupplier(List.of(inputType), () -> {
+ BytesRef field = new BytesRef(
+ " ".repeat(randomIntBetween(0, 10)) + (randomBoolean() ? "" : "-") + randomIntBetween(0, 36500000) + " ".repeat(
+ randomIntBetween(1, 10)
+ ) + interval.toString() + " ".repeat(randomIntBetween(0, 10))
+ );
+ TemporalAmount result = EsqlDataTypeConverter.parseTemporalAmount(field.utf8ToString(), DATE_PERIOD);
+ return new TestCaseSupplier.TestCase(
+ List.of(new TestCaseSupplier.TypedData(field, inputType, "field").forceLiteral()),
+ matchesPattern("LiteralsEvaluator.*"),
+ DATE_PERIOD,
+ equalTo(result)
+ );
+ }));
+ }
+ }
+ return parameterSuppliersFromTypedData(
+ errorsForCasesWithoutExamples(anyNullIsNull(true, suppliers), (v, p) -> "date_period or string")
+ );
+ }
+
+ @Override
+ protected Expression build(Source source, List args) {
+ return new ToDatePeriod(source, args.get(0));
+ }
+
+ @Override
+ public void testSerializationOfSimple() {
+ assertTrue("Serialization test does not apply", true);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToTimeDurationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToTimeDurationTests.java
new file mode 100644
index 0000000000000..b3f666ec6c5c2
--- /dev/null
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToTimeDurationTests.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.esql.expression.function.scalar.convert;
+
+import com.carrotsearch.randomizedtesting.annotations.Name;
+import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
+
+import org.apache.lucene.util.BytesRef;
+import org.elasticsearch.xpack.esql.core.expression.Expression;
+import org.elasticsearch.xpack.esql.core.tree.Source;
+import org.elasticsearch.xpack.esql.core.type.DataType;
+import org.elasticsearch.xpack.esql.expression.function.AbstractScalarFunctionTestCase;
+import org.elasticsearch.xpack.esql.expression.function.FunctionName;
+import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier;
+import org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter;
+
+import java.time.Duration;
+import java.time.temporal.TemporalAmount;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Supplier;
+
+import static org.elasticsearch.xpack.esql.EsqlTestUtils.randomLiteral;
+import static org.elasticsearch.xpack.esql.core.type.DataType.KEYWORD;
+import static org.elasticsearch.xpack.esql.core.type.DataType.TEXT;
+import static org.elasticsearch.xpack.esql.core.type.DataType.TIME_DURATION;
+import static org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter.TIME_DURATIONS;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.matchesPattern;
+
+@FunctionName("to_timeduration")
+public class ToTimeDurationTests extends AbstractScalarFunctionTestCase {
+ public ToTimeDurationTests(@Name("TestCase") Supplier testCaseSupplier) {
+ this.testCase = testCaseSupplier.get();
+ }
+
+ @ParametersFactory
+ public static Iterable parameters() {
+ List suppliers = new ArrayList<>();
+
+ suppliers.add(new TestCaseSupplier(List.of(TIME_DURATION), () -> {
+ Duration field = (Duration) randomLiteral(TIME_DURATION).value();
+ return new TestCaseSupplier.TestCase(
+ List.of(new TestCaseSupplier.TypedData(field, TIME_DURATION, "field").forceLiteral()),
+ matchesPattern("LiteralsEvaluator.*"),
+ TIME_DURATION,
+ equalTo(field)
+ );
+ }));
+
+ for (EsqlDataTypeConverter.INTERVALS interval : TIME_DURATIONS) {
+ for (DataType inputType : List.of(KEYWORD, TEXT)) {
+ suppliers.add(new TestCaseSupplier(List.of(inputType), () -> {
+ BytesRef field = new BytesRef(
+ " ".repeat(randomIntBetween(0, 10)) + (randomBoolean() ? "" : "-") + randomIntBetween(0, Integer.MAX_VALUE) + " "
+ .repeat(randomIntBetween(1, 10)) + interval.toString() + " ".repeat(randomIntBetween(0, 10))
+ );
+ TemporalAmount result = EsqlDataTypeConverter.parseTemporalAmount(field.utf8ToString(), TIME_DURATION);
+ return new TestCaseSupplier.TestCase(
+ List.of(new TestCaseSupplier.TypedData(field, inputType, "field").forceLiteral()),
+ matchesPattern("LiteralsEvaluator.*"),
+ TIME_DURATION,
+ equalTo(result)
+ );
+ }));
+ }
+ }
+ return parameterSuppliersFromTypedData(
+ errorsForCasesWithoutExamples(anyNullIsNull(true, suppliers), (v, p) -> "time_duration or string")
+ );
+ }
+
+ @Override
+ protected Expression build(Source source, List args) {
+ return new ToTimeDuration(source, args.get(0));
+ }
+
+ @Override
+ public void testSerializationOfSimple() {
+ assertTrue("Serialization test does not apply", true);
+ }
+}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java
index 3cd9221d90c81..22a4b410a6d7a 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java
@@ -5419,6 +5419,147 @@ public void testMvSortInvalidOrder() {
assertEquals("Invalid order value in [mv_sort(v, o)], expected one of [ASC, DESC] but got [dsc]", iae.getMessage());
}
+ public void testToDatePeriodTimeDurationInvalidIntervals() {
+ IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ from types | EVAL interval = "3 dys", x = date + interval::date_period"""));
+ assertEquals(
+ "Invalid interval value in [interval::date_period], expected integer followed by one of "
+ + "[DAY, DAYS, D, WEEK, WEEKS, W, MONTH, MONTHS, MO, QUARTER, QUARTERS, Q, YEAR, YEARS, YR, Y] but got [3 dys]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ from types | EVAL interval = "- 3 days", x = date + interval::date_period"""));
+ assertEquals(
+ "Invalid interval value in [interval::date_period], expected integer followed by one of "
+ + "[DAY, DAYS, D, WEEK, WEEKS, W, MONTH, MONTHS, MO, QUARTER, QUARTERS, Q, YEAR, YEARS, YR, Y] but got [- 3 days]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ from types | EVAL interval = "3 dys", x = date - to_dateperiod(interval)"""));
+ assertEquals(
+ "Invalid interval value in [to_dateperiod(interval)], expected integer followed by one of "
+ + "[DAY, DAYS, D, WEEK, WEEKS, W, MONTH, MONTHS, MO, QUARTER, QUARTERS, Q, YEAR, YEARS, YR, Y] but got [3 dys]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ from types | EVAL interval = "- 3 days", x = date - to_dateperiod(interval)"""));
+ assertEquals(
+ "Invalid interval value in [to_dateperiod(interval)], expected integer followed by one of "
+ + "[DAY, DAYS, D, WEEK, WEEKS, W, MONTH, MONTHS, MO, QUARTER, QUARTERS, Q, YEAR, YEARS, YR, Y] but got [- 3 days]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ from types | EVAL interval = "3 ours", x = date + interval::time_duration"""));
+ assertEquals(
+ "Invalid interval value in [interval::time_duration], expected integer followed by one of "
+ + "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3 ours]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ from types | EVAL interval = "- 3 hours", x = date + interval::time_duration"""));
+ assertEquals(
+ "Invalid interval value in [interval::time_duration], expected integer followed by one of "
+ + "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [- 3 hours]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ from types | EVAL interval = "3 ours", x = date - to_timeduration(interval)"""));
+ assertEquals(
+ "Invalid interval value in [to_timeduration(interval)], expected integer followed by one of "
+ + "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3 ours]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ from types | EVAL interval = "- 3 hours", x = date - to_timeduration(interval)"""));
+ assertEquals(
+ "Invalid interval value in [to_timeduration(interval)], expected integer followed by one of "
+ + "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [- 3 hours]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ from types | EVAL interval = "3.5 hours", x = date - to_timeduration(interval)"""));
+ assertEquals(
+ "Invalid interval value in [to_timeduration(interval)], expected integer followed by one of "
+ + "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3.5 hours]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ row x = "2024-01-01"::datetime | eval y = x + "3 dys"::date_period"""));
+ assertEquals(
+ "Invalid interval value in [\"3 dys\"::date_period], expected integer followed by one of "
+ + "[DAY, DAYS, D, WEEK, WEEKS, W, MONTH, MONTHS, MO, QUARTER, QUARTERS, Q, YEAR, YEARS, YR, Y] but got [3 dys]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ row x = "2024-01-01"::datetime | eval y = x - to_dateperiod("3 dys")"""));
+ assertEquals(
+ "Invalid interval value in [to_dateperiod(\"3 dys\")], expected integer followed by one of "
+ + "[DAY, DAYS, D, WEEK, WEEKS, W, MONTH, MONTHS, MO, QUARTER, QUARTERS, Q, YEAR, YEARS, YR, Y] but got [3 dys]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ row x = "2024-01-01"::datetime | eval y = x + "3 ours"::time_duration"""));
+ assertEquals(
+ "Invalid interval value in [\"3 ours\"::time_duration], expected integer followed by one of "
+ + "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3 ours]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ row x = "2024-01-01"::datetime | eval y = x - to_timeduration("3 ours")"""));
+ assertEquals(
+ "Invalid interval value in [to_timeduration(\"3 ours\")], expected integer followed by one of "
+ + "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3 ours]",
+ e.getMessage()
+ );
+
+ e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
+ row x = "2024-01-01"::datetime | eval y = x - to_timeduration("3.5 hours")"""));
+ assertEquals(
+ "Invalid interval value in [to_timeduration(\"3.5 hours\")], expected integer followed by one of "
+ + "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3.5 hours]",
+ e.getMessage()
+ );
+ }
+
+ public void testToDatePeriodToTimeDurationWithField() {
+ final String header = "Found 1 problem\nline ";
+ VerificationException e = expectThrows(VerificationException.class, () -> planTypes("""
+ from types | EVAL x = date + keyword::date_period"""));
+ assertTrue(e.getMessage().startsWith("Found "));
+ assertEquals(
+ "1:30: argument of [keyword::date_period] must be a constant, received [keyword]",
+ e.getMessage().substring(header.length())
+ );
+
+ e = expectThrows(VerificationException.class, () -> planTypes("""
+ from types | EVAL x = date - to_timeduration(keyword)"""));
+ assertEquals(
+ "1:47: argument of [to_timeduration(keyword)] must be a constant, received [keyword]",
+ e.getMessage().substring(header.length())
+ );
+
+ e = expectThrows(VerificationException.class, () -> planTypes("""
+ from types | EVAL x = keyword, y = date + x::date_period"""));
+ assertTrue(e.getMessage().startsWith("Found "));
+ assertEquals("1:43: argument of [x::date_period] must be a constant, received [x]", e.getMessage().substring(header.length()));
+
+ e = expectThrows(VerificationException.class, () -> planTypes("""
+ from types | EVAL x = keyword, y = date - to_timeduration(x)"""));
+ assertEquals("1:60: argument of [to_timeduration(x)] must be a constant, received [x]", e.getMessage().substring(header.length()));
+ }
+
private Literal nullOf(DataType dataType) {
return new Literal(Source.EMPTY, null, dataType);
}
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java
index 35a22fd542a1e..9af152116e1e1 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java
@@ -1413,6 +1413,22 @@ public void testParamMixed() {
);
}
+ public void testIntervalParam() {
+ LogicalPlan stm = statement(
+ "row x = ?1::datetime | eval y = ?1::datetime + ?2::date_period",
+ new QueryParams(List.of(new QueryParam("datetime", "2024-01-01", KEYWORD), new QueryParam("date_period", "3 days", KEYWORD)))
+ );
+ assertThat(stm, instanceOf(Eval.class));
+ Eval eval = (Eval) stm;
+ assertThat(eval.fields().size(), is(1));
+
+ NamedExpression field = eval.fields().get(0);
+ assertThat(field.name(), is("y"));
+ assertThat(field, instanceOf(Alias.class));
+ assertThat(((Literal) ((Add) eval.fields().get(0).child()).left().children().get(0)).value(), equalTo("2024-01-01"));
+ assertThat(((Literal) ((Add) eval.fields().get(0).child()).right().children().get(0)).value(), equalTo("3 days"));
+ }
+
public void testFieldContainingDotsAndNumbers() {
LogicalPlan where = processingCommand("where `a.b.1m.4321`");
assertThat(where, instanceOf(Filter.class));
diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/10_basic.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/10_basic.yml
index e168fc589d11f..132d54fa9ac1e 100644
--- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/10_basic.yml
+++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/10_basic.yml
@@ -393,6 +393,35 @@ setup:
- match: {values.1: ["1",2.0,null,true,123,1674835275193]}
- match: {values.2: ["1",2.0,null,true,123,1674835275193]}
+---
+"Test Interval in Input Params":
+ - requires:
+ test_runner_features: [ capabilities ]
+ capabilities:
+ - method: POST
+ path: /_query
+ parameters: [ ]
+ capabilities: [ cast_string_literal_to_temporal_amount ]
+ reason: "interval in parameters"
+
+ - do:
+ allowed_warnings_regex:
+ - "No limit defined, adding default limit of \\[.*\\]"
+ esql.query:
+ body:
+ query: 'row x = ?n1::datetime | eval y = x - ?n2::date_period, z = x + ?n3::time_duration'
+ params: [{"n1" : "2024-08-06"}, {"n2" : "3 days"}, {"n3" : "3 hours"}]
+
+ - length: {columns: 3}
+ - match: {columns.0.name: "x"}
+ - match: {columns.0.type: "date"}
+ - match: {columns.1.name: "y"}
+ - match: {columns.1.type: "date"}
+ - match: {columns.2.name: "z"}
+ - match: {columns.2.type: "date"}
+ - length: {values: 1}
+ - match: {values.0: ["2024-08-06T00:00:00.000Z","2024-08-03T00:00:00.000Z","2024-08-06T03:00:00.000Z"]}
+
---
version is not allowed:
- requires:
From 18b187cfb0874810c49727bdfe5456c33a3d1a7a Mon Sep 17 00:00:00 2001
From: Patrick Doyle <810052+prdoyle@users.noreply.github.com>
Date: Mon, 9 Sep 2024 16:20:38 -0400
Subject: [PATCH 12/31] Unmute test for issue 109315 (#112671)
---
muted-tests.yml | 3 ---
1 file changed, 3 deletions(-)
diff --git a/muted-tests.yml b/muted-tests.yml
index 0391504eeac6e..72ca5e4d95660 100644
--- a/muted-tests.yml
+++ b/muted-tests.yml
@@ -5,9 +5,6 @@ tests:
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
method: test {yaml=reference/esql/esql-async-query-api/line_17}
issue: https://github.com/elastic/elasticsearch/issues/109260
-- class: "org.elasticsearch.index.engine.frozen.FrozenIndexIT"
- issue: "https://github.com/elastic/elasticsearch/issues/109315"
- method: "testTimestampFieldTypeExposedByAllIndicesServices"
- class: "org.elasticsearch.analysis.common.CommonAnalysisClientYamlTestSuiteIT"
issue: "https://github.com/elastic/elasticsearch/issues/109318"
method: "test {yaml=analysis-common/50_char_filters/pattern_replace error handling (too complex pattern)}"
From f367d2799fa8f02e6d8ca904aad189770d4d7cc3 Mon Sep 17 00:00:00 2001
From: Keith Massey
Date: Mon, 9 Sep 2024 17:01:57 -0500
Subject: [PATCH 13/31] Unmuting simulate ingest yaml rest test (#112684)
---
muted-tests.yml | 3 ---
1 file changed, 3 deletions(-)
diff --git a/muted-tests.yml b/muted-tests.yml
index 72ca5e4d95660..23ad0588aa561 100644
--- a/muted-tests.yml
+++ b/muted-tests.yml
@@ -178,9 +178,6 @@ tests:
- class: org.elasticsearch.xpack.esql.EsqlAsyncSecurityIT
method: testIndexPatternErrorMessageComparison_ESQL_SearchDSL
issue: https://github.com/elastic/elasticsearch/issues/112630
-- class: org.elasticsearch.test.rest.ClientYamlTestSuiteIT
- method: test {yaml=simulate.ingest/10_basic/Test mapping validation from templates}
- issue: https://github.com/elastic/elasticsearch/issues/112633
- class: org.elasticsearch.compute.aggregation.blockhash.BlockHashTests
method: testBytesRefLongHashHugeCombinatorialExplosion {forcePackedHash=false}
issue: https://github.com/elastic/elasticsearch/issues/112442
From b633fe1ccb67f7dbf460cdc087eb60ae212a472a Mon Sep 17 00:00:00 2001
From: Ignacio Vera
Date: Tue, 10 Sep 2024 07:46:55 +0200
Subject: [PATCH 14/31] Replace TopBucketBuilder with a BucketPriorityQueue
(#112602)
BucketPriorityQueue is a much better option nowadays
---
.../search/aggregations/BucketOrder.java | 2 +-
.../search/aggregations/DelayedBucket.java | 2 +-
.../search/aggregations/InternalOrder.java | 6 +-
.../search/aggregations/TopBucketBuilder.java | 210 ------------------
.../bucket/terms/AbstractInternalTerms.java | 35 ++-
.../aggregations/TopBucketBuilderTests.java | 164 --------------
6 files changed, 30 insertions(+), 389 deletions(-)
delete mode 100644 server/src/main/java/org/elasticsearch/search/aggregations/TopBucketBuilder.java
delete mode 100644 server/src/test/java/org/elasticsearch/search/aggregations/TopBucketBuilderTests.java
diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/BucketOrder.java b/server/src/main/java/org/elasticsearch/search/aggregations/BucketOrder.java
index 79516de4184ba..924ea5093bafe 100644
--- a/server/src/main/java/org/elasticsearch/search/aggregations/BucketOrder.java
+++ b/server/src/main/java/org/elasticsearch/search/aggregations/BucketOrder.java
@@ -133,7 +133,7 @@ public final void validate(Aggregator aggregator) throws AggregationExecutionExc
* The comparator might need to reduce the {@link DelayedBucket} and therefore we need to provide the
* reducer and the reduce context.The context must be on the final reduce phase.
*/
- abstract Comparator> delayedBucketComparator(
+ public abstract Comparator> delayedBucketComparator(
BiFunction, AggregationReduceContext, B> reduce,
AggregationReduceContext reduceContext
);
diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/DelayedBucket.java b/server/src/main/java/org/elasticsearch/search/aggregations/DelayedBucket.java
index 19aef60b913af..2a45f174390eb 100644
--- a/server/src/main/java/org/elasticsearch/search/aggregations/DelayedBucket.java
+++ b/server/src/main/java/org/elasticsearch/search/aggregations/DelayedBucket.java
@@ -92,7 +92,7 @@ public String toString() {
* Called to mark a bucket as non-competitive so it can release it can release
* any sub-buckets from the breaker.
*/
- void nonCompetitive(AggregationReduceContext reduceContext) {
+ public void nonCompetitive(AggregationReduceContext reduceContext) {
if (reduced != null) {
// -1 for itself, -countInnerBucket for all the sub-buckets.
reduceContext.consumeBucketsAndMaybeBreak(-1 - InternalMultiBucketAggregation.countInnerBucket(reduced));
diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java b/server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java
index 08e64f687569a..482d915560d04 100644
--- a/server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java
+++ b/server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java
@@ -81,7 +81,7 @@ public Comparator comparator() {
}
@Override
- Comparator> delayedBucketComparator(
+ public Comparator> delayedBucketComparator(
BiFunction, AggregationReduceContext, B> reduce,
AggregationReduceContext reduceContext
) {
@@ -216,7 +216,7 @@ public Comparator comparator() {
}
@Override
- Comparator> delayedBucketComparator(
+ public Comparator> delayedBucketComparator(
BiFunction, AggregationReduceContext, B> reduce,
AggregationReduceContext reduceContext
) {
@@ -284,7 +284,7 @@ public Comparator comparator() {
}
@Override
- Comparator> delayedBucketComparator(
+ public Comparator> delayedBucketComparator(
BiFunction, AggregationReduceContext, B> reduce,
AggregationReduceContext reduceContext
) {
diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/TopBucketBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/TopBucketBuilder.java
deleted file mode 100644
index 8b94f5e37949e..0000000000000
--- a/server/src/main/java/org/elasticsearch/search/aggregations/TopBucketBuilder.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-package org.elasticsearch.search.aggregations;
-
-import org.apache.lucene.util.ArrayUtil;
-import org.apache.lucene.util.PriorityQueue;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.function.BiFunction;
-import java.util.function.Consumer;
-
-/**
- * Merges many buckets into the "top" buckets as sorted by {@link BucketOrder}.
- */
-public abstract class TopBucketBuilder {
- /**
- * The number of buckets required before we switch to the
- * {@link BufferingTopBucketBuilder}. If we need fewer buckets we use
- * {@link PriorityQueueTopBucketBuilder}.
- *
- * The value we picked for this boundary is fairly arbitrary, but it
- * is important that its bigger than the default size of the terms
- * aggregation. It's basically the amount of memory you are willing to
- * waste when reduce small terms aggregations so it shouldn't be too
- * large either. The value we have, {@code 1024}, preallocates about
- * 32k for the priority queue.
- */
- static final int USE_BUFFERING_BUILDER = 1024;
-
- /**
- * Create a {@link TopBucketBuilder} to build a list of the top buckets.
- *
- * If there are few required results we use a {@link PriorityQueueTopBucketBuilder}
- * which is simpler and when the priority queue is full but allocates {@code size + 1}
- * slots in an array. If there are many required results we prefer a
- * {@link BufferingTopBucketBuilder} which doesn't preallocate and is faster for the
- * first {@code size} results. But it's a little slower when the priority queue is full.
- *
- * It's important for this not to preallocate a bunch of memory when
- * {@code size} is very very large because this backs the reduction of the {@code terms}
- * aggregation and folks often set the {@code size} of that to something quite large.
- * The choice in the paragraph above handles this case.
- *
- * @param size the requested size of the list
- * @param order the sort order of the buckets
- * @param nonCompetitive called with non-competitive buckets
- * @param reduce function to reduce a list of buckets
- * @param reduceContext the reduce context
- */
- public static TopBucketBuilder build(
- int size,
- BucketOrder order,
- Consumer> nonCompetitive,
- BiFunction, AggregationReduceContext, B> reduce,
- AggregationReduceContext reduceContext
- ) {
- if (size < USE_BUFFERING_BUILDER) {
- return new PriorityQueueTopBucketBuilder<>(size, order, nonCompetitive, reduce, reduceContext);
- }
- return new BufferingTopBucketBuilder<>(size, order, nonCompetitive, reduce, reduceContext);
- }
-
- protected final Consumer> nonCompetitive;
-
- private TopBucketBuilder(Consumer> nonCompetitive) {
- this.nonCompetitive = nonCompetitive;
- }
-
- /**
- * Add a bucket if it is competitive. If there isn't space but the
- * bucket is competitive then this will drop the least competitive bucket
- * to make room for the new bucket.
- *
- * Instead of operating on complete buckets we this operates on a
- * wrapper containing what we need to merge the buckets called
- * {@link DelayedBucket}. We can evaluate some common sort criteria
- * directly on the {@linkplain DelayedBucket}s so we only need to
- * merge exactly the sub-buckets we need.
- */
- public abstract void add(DelayedBucket bucket);
-
- /**
- * Return the most competitive buckets sorted by the comparator.
- */
- public abstract List build();
-
- /**
- * Collects the "top" buckets by adding them directly to a {@link PriorityQueue}.
- * This is always going to be faster than {@link BufferingTopBucketBuilder}
- * but it requires allocating an array of {@code size + 1}.
- */
- static class PriorityQueueTopBucketBuilder extends TopBucketBuilder {
- private final PriorityQueue> queue;
- private final BiFunction, AggregationReduceContext, B> reduce;
- private final AggregationReduceContext reduceContext;
-
- PriorityQueueTopBucketBuilder(
- int size,
- BucketOrder order,
- Consumer> nonCompetitive,
- BiFunction, AggregationReduceContext, B> reduce,
- AggregationReduceContext reduceContext
- ) {
- super(nonCompetitive);
- if (size >= ArrayUtil.MAX_ARRAY_LENGTH) {
- throw new IllegalArgumentException("can't reduce more than [" + ArrayUtil.MAX_ARRAY_LENGTH + "] buckets");
- }
- this.reduce = reduce;
- this.reduceContext = reduceContext;
- queue = new PriorityQueue<>(size) {
- private final Comparator> comparator = order.delayedBucketComparator(reduce, reduceContext);
-
- @Override
- protected boolean lessThan(DelayedBucket a, DelayedBucket b) {
- return comparator.compare(a, b) > 0;
- }
- };
- }
-
- @Override
- public void add(DelayedBucket bucket) {
- DelayedBucket removed = queue.insertWithOverflow(bucket);
- if (removed != null) {
- nonCompetitive.accept(removed);
- removed.nonCompetitive(reduceContext);
- }
- }
-
- @Override
- public List build() {
- List result = new ArrayList<>(queue.size());
- for (int i = queue.size() - 1; i >= 0; i--) {
- result.add(queue.pop().reduced(reduce, reduceContext));
- }
- Collections.reverse(result);
- return result;
- }
- }
-
- /**
- * Collects the "top" buckets by adding them to a {@link List} that grows
- * as more buckets arrive and is converting into a
- * {@link PriorityQueueTopBucketBuilder} when {@code size} buckets arrive.
- */
- private static class BufferingTopBucketBuilder extends TopBucketBuilder {
- private final int size;
- private final BucketOrder order;
- private final BiFunction, AggregationReduceContext, B> reduce;
- private final AggregationReduceContext reduceContext;
-
- private List> buffer;
- private PriorityQueueTopBucketBuilder next;
-
- BufferingTopBucketBuilder(
- int size,
- BucketOrder order,
- Consumer> nonCompetitive,
- BiFunction, AggregationReduceContext, B> reduce,
- AggregationReduceContext reduceContext
- ) {
- super(nonCompetitive);
- this.reduce = reduce;
- this.reduceContext = reduceContext;
- this.size = size;
- this.order = order;
- buffer = new ArrayList<>();
- }
-
- @Override
- public void add(DelayedBucket bucket) {
- if (next != null) {
- assert buffer == null;
- next.add(bucket);
- return;
- }
- buffer.add(bucket);
- if (buffer.size() < size) {
- return;
- }
- next = new PriorityQueueTopBucketBuilder<>(size, order, nonCompetitive, reduce, reduceContext);
- for (DelayedBucket b : buffer) {
- next.queue.add(b);
- }
- buffer = null;
- }
-
- @Override
- public List build() {
- if (next != null) {
- assert buffer == null;
- return next.build();
- }
- List result = new ArrayList<>(buffer.size());
- for (DelayedBucket b : buffer) {
- result.add(b.reduced(reduce, reduceContext));
- }
- result.sort(order.comparator());
- return result;
- }
- }
-}
diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/AbstractInternalTerms.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/AbstractInternalTerms.java
index 4091a16d8ad4c..e4b4dbbac48ca 100644
--- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/AbstractInternalTerms.java
+++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/AbstractInternalTerms.java
@@ -20,13 +20,13 @@
import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation;
import org.elasticsearch.search.aggregations.InternalOrder;
import org.elasticsearch.search.aggregations.KeyComparable;
-import org.elasticsearch.search.aggregations.TopBucketBuilder;
import org.elasticsearch.search.aggregations.bucket.IteratorAndCurrent;
import org.elasticsearch.search.aggregations.support.SamplingContext;
import org.elasticsearch.xcontent.XContentBuilder;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
@@ -295,19 +295,34 @@ public InternalAggregation get() {
}
});
} else if (reduceContext.isFinalReduce()) {
- TopBucketBuilder top = TopBucketBuilder.build(
- getRequiredSize(),
- getOrder(),
- removed -> otherDocCount[0] += removed.getDocCount(),
+ final Comparator> comparator = getOrder().delayedBucketComparator(
AbstractInternalTerms.this::reduceBucket,
reduceContext
);
- thisReduceOrder = reduceBuckets(bucketsList, getThisReduceOrder(), bucket -> {
- if (bucket.getDocCount() >= getMinDocCount()) {
- top.add(bucket);
+ try (
+ BucketPriorityQueue> top = new BucketPriorityQueue<>(
+ getRequiredSize(),
+ reduceContext.bigArrays(),
+ comparator
+ )
+ ) {
+ thisReduceOrder = reduceBuckets(bucketsList, getThisReduceOrder(), bucket -> {
+ if (bucket.getDocCount() >= getMinDocCount()) {
+ final DelayedBucket removed = top.insertWithOverflow(bucket);
+ if (removed != null) {
+ otherDocCount[0] += removed.getDocCount();
+ removed.nonCompetitive(reduceContext);
+ }
+ }
+ });
+ // size is an integer as it should be <= getRequiredSize()
+ final int size = (int) top.size();
+ result = new ArrayList<>(size);
+ for (int i = 0; i < size; i++) {
+ result.add(top.pop().reduced(AbstractInternalTerms.this::reduceBucket, reduceContext));
}
- });
- result = top.build();
+ Collections.reverse(result);
+ }
} else {
result = new ArrayList<>();
thisReduceOrder = reduceBuckets(
diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/TopBucketBuilderTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/TopBucketBuilderTests.java
deleted file mode 100644
index 58d97b488d667..0000000000000
--- a/server/src/test/java/org/elasticsearch/search/aggregations/TopBucketBuilderTests.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-package org.elasticsearch.search.aggregations;
-
-import org.apache.lucene.util.ArrayUtil;
-import org.apache.lucene.util.BytesRef;
-import org.elasticsearch.core.Strings;
-import org.elasticsearch.search.DocValueFormat;
-import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation.InternalBucket;
-import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
-import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.test.InternalAggregationTestCase;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.function.BiFunction;
-
-import static org.elasticsearch.search.aggregations.DelayedBucketTests.mockReduce;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasSize;
-
-public class TopBucketBuilderTests extends ESTestCase {
- public void testSizeOne() {
- int count = between(1, 1000);
- AggregationReduceContext context = InternalAggregationTestCase.emptyReduceContextBuilder().forFinalReduction();
- BiFunction, AggregationReduceContext, InternalBucket> reduce = mockReduce(context);
- List nonCompetitive = new ArrayList<>();
- TopBucketBuilder builder = TopBucketBuilder.build(
- 1,
- BucketOrder.key(true),
- b -> nonCompetitive.add(b.toString()),
- reduce,
- context
- );
-
- for (int i = 0; i < count; i++) {
- builder.add(new DelayedBucket<>(List.of(bucket(i))));
- }
-
- List top = builder.build();
- assertThat(top, hasSize(1));
- assertThat(top.get(0).getKeyAsString(), equalTo("000000"));
- assertThat(top.get(0).getDocCount(), equalTo(1L));
- for (int i = 1; i < count; i++) {
- assertThat(nonCompetitive.get(i - 1), equalTo("Delayed[" + bucketKey(i) + "]"));
- }
- }
-
- public void testAllCompetitive() {
- int size = between(3, 1000);
- int count = between(1, size);
- AggregationReduceContext context = InternalAggregationTestCase.emptyReduceContextBuilder().forFinalReduction();
- BiFunction, AggregationReduceContext, InternalBucket> reduce = mockReduce(context);
- TopBucketBuilder builder = TopBucketBuilder.build(
- size,
- BucketOrder.key(true),
- b -> fail("unexpected uncompetitive bucket " + b),
- reduce,
- context
- );
-
- for (int i = 0; i < count; i++) {
- builder.add(new DelayedBucket<>(List.of(bucket(i))));
- }
-
- List top = builder.build();
- assertThat(top, hasSize(count));
- for (int i = 0; i < count; i++) {
- assertThat(top.get(i).getKeyAsString(), equalTo(bucketKey(i)));
- assertThat(top.get(i).getDocCount(), equalTo(1L));
- }
- }
-
- public void someNonCompetitiveTestCase(int size) {
- int count = between(size + 1, size * 30);
- AggregationReduceContext context = InternalAggregationTestCase.emptyReduceContextBuilder().forFinalReduction();
- BiFunction, AggregationReduceContext, InternalBucket> reduce = mockReduce(context);
- List nonCompetitive = new ArrayList<>();
- TopBucketBuilder builder = TopBucketBuilder.build(
- size,
- BucketOrder.key(true),
- b -> nonCompetitive.add(b.toString()),
- reduce,
- context
- );
-
- for (int i = 0; i < count; i++) {
- builder.add(new DelayedBucket<>(List.of(bucket(i))));
- }
-
- List top = builder.build();
- assertThat(top, hasSize(size));
- for (int i = 0; i < count; i++) {
- if (i < size) {
- assertThat(top.get(i).getKeyAsString(), equalTo(bucketKey(i)));
- assertThat(top.get(i).getDocCount(), equalTo(1L));
- } else {
- assertThat(nonCompetitive.get(i - size), equalTo("Delayed[" + bucketKey(i) + "]"));
- }
- }
- }
-
- public void testSomeNonCompetitiveSmall() {
- someNonCompetitiveTestCase(between(2, TopBucketBuilder.USE_BUFFERING_BUILDER - 1));
- }
-
- public void testSomeNonCompetitiveLarge() {
- someNonCompetitiveTestCase(between(TopBucketBuilder.USE_BUFFERING_BUILDER, TopBucketBuilder.USE_BUFFERING_BUILDER * 5));
- }
-
- public void testHuge() {
- int count = between(1, 1000);
- AggregationReduceContext context = InternalAggregationTestCase.emptyReduceContextBuilder().forFinalReduction();
- BiFunction, AggregationReduceContext, InternalBucket> reduce = mockReduce(context);
- TopBucketBuilder builder = TopBucketBuilder.build(
- Integer.MAX_VALUE,
- BucketOrder.key(true),
- b -> fail("unexpected uncompetitive bucket " + b),
- reduce,
- context
- );
-
- for (int i = 0; i < count; i++) {
- builder.add(new DelayedBucket<>(List.of(bucket(i))));
- }
-
- List top = builder.build();
- assertThat(top, hasSize(count));
- assertThat(top.get(0).getKeyAsString(), equalTo("000000"));
- assertThat(top.get(0).getDocCount(), equalTo(1L));
- for (int i = 0; i < count; i++) {
- assertThat(top.get(i).getKeyAsString(), equalTo(bucketKey(i)));
- assertThat(top.get(i).getDocCount(), equalTo(1L));
- }
- }
-
- public void testHugeQueueError() {
- Exception e = expectThrows(
- IllegalArgumentException.class,
- () -> new TopBucketBuilder.PriorityQueueTopBucketBuilder<>(
- ArrayUtil.MAX_ARRAY_LENGTH,
- BucketOrder.key(true),
- b -> fail("unexpected uncompetitive bucket " + b),
- null,
- null
- )
- );
- assertThat(e.getMessage(), equalTo("can't reduce more than [" + ArrayUtil.MAX_ARRAY_LENGTH + "] buckets"));
- }
-
- private String bucketKey(int index) {
- return Strings.format("%06d", index);
- }
-
- private InternalBucket bucket(int index) {
- return new StringTerms.Bucket(new BytesRef(bucketKey(index)), 1, InternalAggregations.EMPTY, false, 0, DocValueFormat.RAW);
- }
-}
From 8f07d60c2cf0cc7ece801faee46acba2f4e0344f Mon Sep 17 00:00:00 2001
From: David Turner
Date: Tue, 10 Sep 2024 08:17:09 +0100
Subject: [PATCH 15/31] Fix trappy timeouts in `o.e.a.a.cluster.*` (#112674)
Removes all usages of `TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT` in
cluster-related APIs in `:server`.
Relates #107984
---
.../datastreams/DataStreamIT.java | 10 +-
.../ResolveClusterDataStreamIT.java | 2 +-
.../DataStreamLifecycleServiceIT.java | 4 +-
.../datastreams/DataStreamsStatsTests.java | 5 +-
.../datastreams/LookAHeadTimeTests.java | 4 +-
.../action/CrossClusterPainlessExecuteIT.java | 2 +-
.../migration/FeatureMigrationIT.java | 38 ++--
.../migration/MultiFeatureMigrationIT.java | 6 +-
.../migration/SystemIndexMigrationIT.java | 6 +-
.../azure/classic/AzureSimpleTests.java | 4 +-
.../classic/AzureTwoStartedNodesTests.java | 4 +-
.../ec2/Ec2DiscoveryUpdateSettingsTests.java | 2 +-
.../discovery/gce/GceDiscoverTests.java | 8 +-
.../repositories/hdfs/HdfsTests.java | 2 +-
.../common/logging/LoggersTests.java | 2 +-
.../action/IndicesRequestIT.java | 4 +-
.../ClusterAllocationExplainIT.java | 8 +-
.../TransportGetDesiredBalanceActionIT.java | 12 +-
.../TransportDesiredNodesActionsIT.java | 16 +-
.../admin/cluster/node/tasks/TasksIT.java | 4 +-
...ansportClusterStateActionDisruptionIT.java | 23 ++-
.../admin/cluster/stats/ClusterStatsIT.java | 3 +-
.../admin/indices/create/CreateIndexIT.java | 4 +-
.../admin/indices/create/ShrinkIndexIT.java | 31 ++--
.../admin/indices/create/SplitIndexIT.java | 7 +-
.../admin/indices/rollover/RolloverIT.java | 50 ++++--
.../shards/IndicesShardStoreRequestIT.java | 8 +-
.../bulk/BulkProcessorClusterSettingsIT.java | 2 +-
.../bulk/TransportSimulateBulkActionIT.java | 2 +-
.../support/ActiveShardsObserverIT.java | 4 +-
.../support/WaitActiveShardCountIT.java | 4 +-
.../master/TransportMasterNodeActionIT.java | 8 +-
.../elasticsearch/aliases/IndexAliasesIT.java | 22 ++-
.../elasticsearch/blocks/SimpleBlocksIT.java | 6 +-
.../cluster/ClusterHealthIT.java | 56 +++---
.../cluster/ClusterInfoServiceIT.java | 9 +-
.../cluster/DesiredNodesSnapshotsIT.java | 6 +-
.../cluster/DesiredNodesStatusIT.java | 28 ++-
.../cluster/MinimumMasterNodesIT.java | 65 ++++---
.../elasticsearch/cluster/NoMasterNodeIT.java | 28 ++-
.../cluster/PrevalidateNodeRemovalIT.java | 13 +-
.../cluster/SimpleClusterStateIT.java | 67 ++++---
.../cluster/SimpleDataNodesIT.java | 24 ++-
.../cluster/SpecificMasterNodesIT.java | 131 ++++++++++++--
.../cluster/UpdateSettingsValidationIT.java | 7 +-
.../allocation/AwarenessAllocationIT.java | 39 +++--
.../cluster/allocation/ClusterRerouteIT.java | 38 ++--
.../allocation/FilteringAllocationIT.java | 25 +--
.../allocation/SimpleAllocationIT.java | 6 +-
.../coordination/InitialClusterStateIT.java | 8 +-
.../coordination/RareClusterStateIT.java | 2 +-
.../coordination/RemoveCustomsCommandIT.java | 15 +-
.../coordination/RemoveSettingsCommandIT.java | 6 +-
.../UnsafeBootstrapAndDetachCommandIT.java | 30 +++-
.../coordination/VotingConfigurationIT.java | 15 +-
.../cluster/coordination/ZenDiscoveryIT.java | 2 +-
.../cluster/routing/AllocationIdIT.java | 17 +-
.../cluster/routing/DelayedAllocationIT.java | 29 ++--
.../cluster/routing/PrimaryAllocationIT.java | 100 ++++++++---
.../routing/RemoveReplicaPriorityIT.java | 12 +-
.../cluster/routing/ShardRoutingRoleIT.java | 6 +-
.../allocation/AllocationFailuresResetIT.java | 4 +-
.../allocation/DiskThresholdMonitorIT.java | 8 +-
.../routing/allocation/ShardStateIT.java | 11 +-
.../decider/DiskThresholdDeciderIT.java | 4 +-
.../allocation/decider/MockDiskUsagesIT.java | 14 +-
.../UpdateShardAllocationSettingsIT.java | 4 +-
.../cluster/settings/ClusterSettingsIT.java | 114 +++++++-----
...usterSettingsUpdateWithFaultyMasterIT.java | 2 +-
.../cluster/shards/ClusterSearchShardsIT.java | 2 +-
.../cluster/shards/ClusterShardLimitIT.java | 45 ++---
.../discovery/ClusterDisruptionIT.java | 13 +-
.../discovery/DiscoveryDisruptionIT.java | 2 +-
.../discovery/StableMasterDisruptionIT.java | 8 +-
.../elasticsearch/document/ShardInfoIT.java | 6 +-
.../elasticsearch/env/NodeEnvironmentIT.java | 4 +-
.../features/ClusterFeaturesIT.java | 2 +-
.../gateway/GatewayIndexStateIT.java | 58 ++++---
.../gateway/MetadataNodesIT.java | 4 +-
.../gateway/QuorumGatewayIT.java | 2 +-
.../gateway/RecoverAfterNodesIT.java | 56 +++++-
.../gateway/RecoveryFromGatewayIT.java | 19 +-
.../gateway/ReplicaShardAllocatorIT.java | 2 +-
.../health/HealthMetadataServiceIT.java | 2 +-
.../elasticsearch/health/HealthServiceIT.java | 2 +-
.../health/UpdateHealthInfoCacheIT.java | 13 +-
.../index/IndexingPressureIT.java | 12 +-
.../index/seqno/GlobalCheckpointSyncIT.java | 4 +-
.../index/seqno/RetentionLeaseIT.java | 2 +-
.../RemoveCorruptedShardDataCommandIT.java | 8 +-
.../index/store/CorruptedFileIT.java | 30 ++--
.../index/suggest/stats/SuggestStatsIT.java | 4 +-
.../IndexLifecycleActionIT.java | 24 +--
...DateMathIndexExpressionsIntegrationIT.java | 2 +-
.../indices/IndicesLifecycleListenerIT.java | 10 +-
.../indices/cluster/ResolveClusterIT.java | 4 +-
.../indices/cluster/ShardLockFailureIT.java | 4 +-
.../indices/mapping/SimpleGetMappingsIT.java | 2 +-
.../mapping/UpdateMappingIntegrationIT.java | 10 +-
.../breaker/CircuitBreakerServiceIT.java | 2 +-
.../HierarchyCircuitBreakerTelemetryIT.java | 7 +-
.../indices/recovery/DanglingIndicesIT.java | 2 +-
.../recovery/IndexPrimaryRelocationIT.java | 6 +-
.../indices/recovery/IndexRecoveryIT.java | 16 +-
.../recovery/ReplicaToPrimaryPromotionIT.java | 8 +-
.../plan/ShardSnapshotsServiceIT.java | 2 +-
.../settings/UpdateNumberOfReplicasIT.java | 87 ++++++----
.../indices/settings/UpdateSettingsIT.java | 128 ++++++++++----
.../state/CloseIndexDisableCloseAllIT.java | 2 +-
.../indices/state/CloseIndexIT.java | 14 +-
.../indices/state/OpenCloseIndexIT.java | 22 +--
.../indices/state/ReopenWhileClosingIT.java | 2 +-
.../indices/state/SimpleIndexStateIT.java | 10 +-
.../indices/stats/IndexStatsIT.java | 2 +-
.../store/IndicesStoreIntegrationIT.java | 34 ++--
.../template/SimpleIndexTemplateIT.java | 11 +-
.../ingest/IngestFileSettingsIT.java | 2 +-
.../SimpleNodesCapabilitiesIT.java | 5 +-
.../nodesinfo/SimpleNodesInfoIT.java | 15 +-
.../DestructiveOperationsIT.java | 6 +-
.../decider/EnableAssignmentDeciderIT.java | 2 +-
.../IndexFoldersDeletionListenerIT.java | 6 +-
.../readiness/ReadinessClusterIT.java | 7 +-
.../recovery/FullRollingRestartIT.java | 16 +-
.../recovery/RecoveryWhileUnderLoadIT.java | 14 +-
.../elasticsearch/recovery/RelocationIT.java | 26 +--
...rtInactiveAutoExpandReplicaNotStaleIT.java | 2 +-
.../repositories/IndexSnapshotsServiceIT.java | 2 +-
.../BlobStoreRepositoryCleanupIT.java | 5 +-
.../ComponentTemplatesFileSettingsIT.java | 7 +-
.../service/FileSettingsServiceIT.java | 13 +-
.../service/RepositoriesFileSettingsIT.java | 5 +-
.../service/SnapshotsAndFileSettingsIT.java | 11 +-
.../rest/discovery/Zen2RestApiIT.java | 9 +-
.../routing/AliasResolveRoutingIT.java | 4 +-
.../routing/PartitionedRoutingIT.java | 9 +-
.../routing/SimpleRoutingIT.java | 2 +-
.../SearchServiceCleanupOnLostMasterIT.java | 2 +-
.../aggregations/bucket/GeoDistanceIT.java | 2 +-
.../search/aggregations/bucket/RangeIT.java | 2 +-
.../search/basic/SearchRedStateIndexIT.java | 8 +-
.../basic/SearchWhileCreatingIndexIT.java | 4 +-
.../search/basic/SearchWhileRelocatingIT.java | 2 +-
.../basic/SearchWithRandomIOExceptionsIT.java | 2 +-
.../basic/TransportSearchFailuresIT.java | 4 +-
.../search/ccs/CCSUsageTelemetryIT.java | 2 +-
.../search/ccs/CrossClusterIT.java | 2 +-
.../search/ccs/CrossClusterSearchIT.java | 2 +-
.../search/ccs/CrossClusterSearchLeakIT.java | 8 +-
.../functionscore/FunctionScorePluginIT.java | 2 +-
.../retriever/MinimalCompoundRetrieverIT.java | 2 +-
.../search/retriever/RetrieverRewriteIT.java | 2 +-
.../search/routing/SearchPreferenceIT.java | 2 +-
.../routing/SearchReplicaSelectionIT.java | 2 +-
.../search/scroll/SearchScrollIT.java | 26 +--
.../search/stats/SearchStatsIT.java | 4 +-
.../snapshots/ConcurrentSnapshotsIT.java | 2 +-
.../snapshots/CustomMetadataContextIT.java | 6 +-
.../DedicatedClusterSnapshotRestoreIT.java | 10 +-
.../snapshots/MultiClusterRepoAccessIT.java | 2 +-
.../snapshots/RepositoriesIT.java | 11 +-
.../snapshots/RestoreSnapshotIT.java | 21 ++-
.../SharedClusterSnapshotRestoreIT.java | 21 ++-
.../snapshots/SnapshotBrokenSettingsIT.java | 4 +-
.../snapshots/SnapshotShutdownIT.java | 11 +-
.../snapshots/SnapshotStatusApisIT.java | 2 +-
.../snapshots/SnapshotStressTestsIT.java | 21 ++-
.../snapshots/SystemIndicesSnapshotIT.java | 6 +-
.../AddVotingConfigExclusionsRequest.java | 22 ++-
.../ClearVotingConfigExclusionsRequest.java | 4 +-
.../desirednodes/GetDesiredNodesAction.java | 5 +-
.../TransportDeleteDesiredNodesAction.java | 11 +-
.../UpdateDesiredNodesRequest.java | 24 ++-
.../cluster/health/ClusterHealthRequest.java | 8 +-
.../health/ClusterHealthRequestBuilder.java | 4 +-
.../GetFeatureUpgradeStatusRequest.java | 5 +-
.../migration/PostFeatureUpgradeRequest.java | 5 +-
.../PrevalidateNodeRemovalRequest.java | 8 +-
.../settings/ClusterGetSettingsAction.java | 5 +-
.../ClusterUpdateSettingsRequest.java | 18 +-
.../ClusterUpdateSettingsRequestBuilder.java | 5 +-
.../cluster/state/ClusterStateRequest.java | 4 +-
.../state/ClusterStateRequestBuilder.java | 4 +-
.../tasks/PendingClusterTasksRequest.java | 5 +-
.../client/internal/ClusterAdminClient.java | 12 +-
.../action/ReservedClusterSettingsAction.java | 7 +-
.../RestAddVotingConfigExclusionAction.java | 5 +-
...RestClearVotingConfigExclusionsAction.java | 3 +-
.../cluster/RestClusterGetSettingsAction.java | 5 +-
.../cluster/RestClusterHealthAction.java | 14 +-
.../admin/cluster/RestClusterStateAction.java | 3 +-
.../RestClusterUpdateSettingsAction.java | 7 +-
.../cluster/RestGetDesiredNodesAction.java | 3 +-
.../RestGetFeatureUpgradeStatusAction.java | 7 +-
.../RestPendingClusterTasksAction.java | 3 +-
.../cluster/RestPostFeatureUpgradeAction.java | 7 +-
.../RestPrevalidateNodeRemovalAction.java | 12 +-
.../cluster/RestUpdateDesiredNodesAction.java | 11 +-
.../rest/action/cat/RestAllocationAction.java | 3 +-
.../cat/RestCatComponentTemplateAction.java | 3 +-
.../rest/action/cat/RestHealthAction.java | 5 +-
.../rest/action/cat/RestIndicesAction.java | 3 +-
.../rest/action/cat/RestMasterAction.java | 3 +-
.../rest/action/cat/RestNodeAttrsAction.java | 3 +-
.../rest/action/cat/RestNodesAction.java | 3 +-
.../cat/RestPendingClusterTasksAction.java | 3 +-
.../rest/action/cat/RestPluginsAction.java | 3 +-
.../rest/action/cat/RestSegmentsAction.java | 3 +-
.../rest/action/cat/RestShardsAction.java | 3 +-
.../rest/action/cat/RestThreadPoolAction.java | 3 +-
.../transport/RemoteClusterConnection.java | 5 +-
.../transport/SniffConnectionStrategy.java | 5 +-
...AddVotingConfigExclusionsRequestTests.java | 73 ++++++--
...earVotingConfigExclusionsRequestTests.java | 2 +-
...tAddVotingConfigExclusionsActionTests.java | 58 +++++--
...learVotingConfigExclusionsActionTests.java | 12 +-
...ransportUpdateDesiredNodesActionTests.java | 15 +-
...DesiredNodesRequestSerializationTests.java | 9 +-
.../UpdateDesiredNodesRequestTests.java | 2 +
.../health/ClusterHealthRequestTests.java | 4 +-
.../TransportClusterHealthActionTests.java | 4 +-
...eNodeRemovalRequestSerializationTests.java | 8 +-
.../PrevalidateNodeRemovalRequestTests.java | 16 +-
...portPrevalidateNodeRemovalActionTests.java | 18 +-
.../ClusterUpdateSettingsRequestTests.java | 12 +-
.../cluster/state/ClusterStateApiTests.java | 8 +-
.../state/ClusterStateRequestTests.java | 30 ++--
...StateAwareHandledTransportActionTests.java | 12 +-
.../TransportMasterNodeActionTests.java | 12 +-
.../ParentTaskAssigningClientTests.java | 6 +-
.../health/ClusterStateHealthTests.java | 2 +-
.../metadata/DesiredNodesTestCase.java | 2 +
.../MetadataIndexTemplateServiceTests.java | 8 +-
.../discovery/AbstractDisruptionTestCase.java | 2 +-
.../index/IndexServiceTests.java | 4 +-
.../search/SearchServiceTests.java | 8 +-
.../snapshots/SnapshotResiliencyTests.java | 7 +-
.../transport/RemoteClusterClientTests.java | 12 +-
.../test/disruption/NetworkDisruptionIT.java | 2 +-
.../AbstractIndexRecoveryIntegTestCase.java | 10 +-
.../search/geo/BaseShapeIntegTestCase.java | 4 +-
.../AbstractSnapshotIntegTestCase.java | 2 +-
.../test/AbstractMultiClustersTestCase.java | 8 +-
.../elasticsearch/test/ESIntegTestCase.java | 163 ++++++++++--------
.../test/ESSingleNodeTestCase.java | 17 +-
.../test/InternalTestCluster.java | 14 +-
.../org/elasticsearch/test/TestCluster.java | 7 +-
.../test/disruption/SingleNodeDisruption.java | 3 +-
.../search/AsyncSearchIntegTestCase.java | 2 +-
.../CCSUsageTelemetryAsyncSearchIT.java | 2 +-
.../search/CrossClusterAsyncSearchIT.java | 2 +-
.../AutoscalingFileSettingsIT.java | 2 +-
...nsportDeleteAutoscalingPolicyActionIT.java | 2 +-
...TransportPutAutoscalingPolicyActionIT.java | 4 +-
.../existence/FrozenExistenceDeciderIT.java | 2 +-
.../storage/ReactiveStorageIT.java | 8 +-
.../elasticsearch/xpack/ccr/AutoFollowIT.java | 11 +-
.../elasticsearch/xpack/ccr/CcrAliasesIT.java | 2 +-
.../xpack/ccr/CcrRepositoryIT.java | 10 +-
.../xpack/ccr/CcrRetentionLeaseIT.java | 60 +++++--
.../xpack/ccr/CloseFollowerIndexIT.java | 4 +-
.../xpack/ccr/IndexFollowingIT.java | 28 +--
.../ccr/PrimaryFollowerAllocationIT.java | 6 +-
.../xpack/ccr/RestartIndexFollowingIT.java | 6 +-
.../ccr/action/AutoFollowCoordinator.java | 2 +-
.../xpack/ccr/action/CcrRequests.java | 2 +-
.../TransportPutAutoFollowPatternAction.java | 2 +-
.../xpack/ccr/repository/CcrRepository.java | 2 +-
.../elasticsearch/xpack/CcrIntegTestCase.java | 10 +-
.../xpack/CcrSingleNodeTestCase.java | 4 +-
.../ComponentVersionsNodesInfoIT.java | 5 +-
.../sourceonly/SourceOnlySnapshotIT.java | 16 +-
.../DataTierAllocationDeciderIT.java | 16 +-
...ierShardAvailabilityHealthIndicatorIT.java | 2 +-
.../core/ml/annotations/AnnotationIndex.java | 3 +-
.../persistence/AnomalyDetectorsIndex.java | 7 +-
.../xpack/core/ml/utils/MlIndexAndAlias.java | 5 +-
.../xpack/core/ClientHelperTests.java | 10 +-
.../async/AsyncSearchIndexServiceTests.java | 10 +-
.../DownsampleActionSingleNodeTests.java | 6 +-
.../xpack/enrich/EnrichMultiNodeIT.java | 4 +-
.../xpack/enrich/EnrichPolicyRunner.java | 6 +-
...ransportDeleteEnrichPolicyActionTests.java | 4 +-
.../action/AbstractEsqlIntegTestCase.java | 4 +-
.../esql/action/CrossClustersQueryIT.java | 2 +-
.../xpack/esql/action/EsqlActionIT.java | 10 +-
.../index/engine/frozen/FrozenIndexIT.java | 16 +-
.../index/engine/frozen/FrozenIndexTests.java | 40 +++--
.../IndexLifecycleInitialisationTests.java | 8 +-
.../xpack/ml/integration/DatafeedJobsIT.java | 6 +-
...NativeDataFrameAnalyticsIntegTestCase.java | 2 +-
.../ml/integration/MlNativeIntegTestCase.java | 2 +-
.../ml/integration/SetUpgradeModeIT.java | 6 +-
.../ml/integration/TestFeatureResetIT.java | 6 +-
.../license/MachineLearningLicensingIT.java | 8 +-
.../integration/BasicDistributedJobsIT.java | 10 +-
.../xpack/ml/integration/DatafeedCcsIT.java | 4 +-
.../integration/MlDistributedFailureIT.java | 7 +-
.../xpack/ml/integration/TooManyJobsIT.java | 9 +-
.../ml/job/persistence/MockClientBuilder.java | 2 +-
.../xpack/ml/support/BaseMlIntegTestCase.java | 2 +-
.../exporter/http/HttpExporterSslIT.java | 2 +-
.../monitoring/integration/MonitoringIT.java | 6 +-
...ransportMonitoringMigrateAlertsAction.java | 6 +-
.../monitoring/MultiNodesStatsTests.java | 2 +-
.../local/LocalExporterIntegTests.java | 2 +-
.../lucene/bwc/ArchiveLicenseIntegTests.java | 2 +-
.../profiling/action/ProfilingTestCase.java | 4 +-
.../BaseSearchableSnapshotsIntegTestCase.java | 2 +-
.../FrozenSearchableSnapshotsIntegTests.java | 10 +-
...movalWithSearchableSnapshotIntegTests.java | 5 +-
...pshotsCanMatchOnCoordinatorIntegTests.java | 9 +-
.../SearchableSnapshotsIntegTests.java | 16 +-
.../SearchableSnapshotsLicenseIntegTests.java | 2 +-
...earchableSnapshotAllocationIntegTests.java | 4 +-
...chableSnapshotDiskThresholdIntegTests.java | 12 +-
...shotEnableAllocationDeciderIntegTests.java | 3 +-
.../SearchableSnapshotShutdownIntegTests.java | 12 +-
...archableSnapshotsRelocationIntegTests.java | 11 +-
...bleSnapshotsPersistentCacheIntegTests.java | 15 +-
.../shared/NodesCachesStatsIntegTests.java | 2 +-
...tiallyCachedShardAllocationIntegTests.java | 25 ++-
...SnapshotRecoveryStateIntegrationTests.java | 4 +-
.../ClusterPrivilegeIntegrationTests.java | 2 +-
.../integration/IndexPrivilegeIntegTests.java | 4 +-
.../RoleMappingFileSettingsIT.java | 13 +-
.../SecurityFeatureStateIntegTests.java | 2 +-
.../ShrinkIndexWithSecurityTests.java | 2 +-
.../elasticsearch/license/LicensingTests.java | 4 +-
.../FileSettingsRoleMappingsRestartIT.java | 8 +-
.../AuditTrailSettingsUpdateTests.java | 4 +-
.../security/authc/ApiKeyIntegTests.java | 2 +-
.../security/authc/TokenAuthIntegTests.java | 2 +-
.../authc/apikey/ApiKeySingleNodeTests.java | 2 +-
.../authc/esnative/NativeRealmIntegTests.java | 70 ++++++--
...ervedRealmElasticAutoconfigIntegTests.java | 22 ++-
.../esnative/ReservedRealmIntegTests.java | 16 +-
.../store/NativePrivilegeStoreCacheTests.java | 9 +-
.../NativePrivilegeStoreSingleNodeTests.java | 4 +-
.../OperatorPrivilegesSingleNodeTests.java | 23 ++-
.../profile/SecurityDomainIntegTests.java | 6 +-
.../filter/IpFilteringUpdateTests.java | 8 +-
.../test/SecurityIntegTestCase.java | 2 +-
.../authz/AuthorizationServiceTests.java | 18 +-
.../NodeShutdownDelayedAllocationIT.java | 16 +-
.../xpack/shutdown/NodeShutdownShardsIT.java | 6 +-
.../xpack/slm/SnapshotLifecycleRestIT.java | 6 +-
.../xpack/slm/SLMFileSettingsIT.java | 11 +-
.../slm/SLMSnapshotBlockingIntegTests.java | 2 +-
.../xpack/slm/SLMStatDisruptionIT.java | 10 +-
.../SnapshotBasedIndexRecoveryIT.java | 14 +-
.../persistence/TransformInternalIndex.java | 6 +-
.../votingonly/VotingOnlyNodePluginTests.java | 42 +++--
.../AbstractWatcherIntegrationTestCase.java | 6 +-
.../test/integration/SingleNodeTests.java | 2 +-
.../WatcherExecutorServiceBenchmark.java | 3 +-
.../bench/WatcherScheduleEngineBenchmark.java | 7 +-
357 files changed, 2640 insertions(+), 1479 deletions(-)
diff --git a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java
index e3da69b7b2f0b..ebe5546c0907f 100644
--- a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java
+++ b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java
@@ -597,8 +597,8 @@ public void testResolvabilityOfDataStreamsInAPIs() throws Exception {
false
);
verifyResolvability(dataStreamName, indicesAdmin().prepareGetSettings(dataStreamName), false);
- verifyResolvability(dataStreamName, clusterAdmin().prepareHealth(dataStreamName), false);
- verifyResolvability(dataStreamName, clusterAdmin().prepareState().setIndices(dataStreamName), false);
+ verifyResolvability(dataStreamName, clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, dataStreamName), false);
+ verifyResolvability(dataStreamName, clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setIndices(dataStreamName), false);
verifyResolvability(dataStreamName, client().prepareFieldCaps(dataStreamName).setFields("*"), false);
verifyResolvability(dataStreamName, indicesAdmin().prepareGetIndex().addIndices(dataStreamName), false);
verifyResolvability(dataStreamName, indicesAdmin().prepareOpen(dataStreamName), false);
@@ -644,8 +644,8 @@ public void testResolvabilityOfDataStreamsInAPIs() throws Exception {
indicesAdmin().prepareUpdateSettings(wildcardExpression).setSettings(Settings.builder().put("index.number_of_replicas", 0)),
false
);
- verifyResolvability(wildcardExpression, clusterAdmin().prepareHealth(wildcardExpression), false);
- verifyResolvability(wildcardExpression, clusterAdmin().prepareState().setIndices(wildcardExpression), false);
+ verifyResolvability(wildcardExpression, clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, wildcardExpression), false);
+ verifyResolvability(wildcardExpression, clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setIndices(wildcardExpression), false);
verifyResolvability(wildcardExpression, client().prepareFieldCaps(wildcardExpression).setFields("*"), false);
verifyResolvability(wildcardExpression, indicesAdmin().prepareGetIndex().addIndices(wildcardExpression), false);
verifyResolvability(wildcardExpression, indicesAdmin().prepareOpen(wildcardExpression), false);
@@ -1594,7 +1594,7 @@ public void testClusterStateIncludeDataStream() throws Exception {
client().execute(CreateDataStreamAction.INSTANCE, createDataStreamRequest).get();
// when querying a backing index then the data stream should be included as well.
- ClusterStateRequest request = new ClusterStateRequest().indices(".ds-metrics-foo-*000001");
+ ClusterStateRequest request = new ClusterStateRequest(TEST_REQUEST_TIMEOUT).indices(".ds-metrics-foo-*000001");
ClusterState state = clusterAdmin().state(request).get().getState();
assertThat(state.metadata().dataStreams().size(), equalTo(1));
assertThat(state.metadata().dataStreams().get("metrics-foo").getName(), equalTo("metrics-foo"));
diff --git a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/ResolveClusterDataStreamIT.java b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/ResolveClusterDataStreamIT.java
index ef785086a0ef4..7fdc3b660433d 100644
--- a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/ResolveClusterDataStreamIT.java
+++ b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/ResolveClusterDataStreamIT.java
@@ -405,7 +405,7 @@ private Map setupThreeClusters(boolean useAlias) throws IOExcept
assertFalse(
client(REMOTE_CLUSTER_2).admin()
.cluster()
- .prepareHealth(remoteIndex2)
+ .prepareHealth(TEST_REQUEST_TIMEOUT, remoteIndex2)
.setWaitForYellowStatus()
.setTimeout(TimeValue.timeValueSeconds(10))
.get()
diff --git a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceIT.java b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceIT.java
index ee17521ad757d..65f911d27bf65 100644
--- a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceIT.java
+++ b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceIT.java
@@ -917,7 +917,7 @@ public void testDataLifecycleServiceConfiguresTheMergePolicy() throws Exception
String firstGenerationIndex = getBackingIndices(dataStreamName).get(0);
ClusterGetSettingsAction.Response response = client().execute(
ClusterGetSettingsAction.INSTANCE,
- new ClusterGetSettingsAction.Request()
+ new ClusterGetSettingsAction.Request(TEST_REQUEST_TIMEOUT)
).get();
Settings clusterSettings = response.persistentSettings();
@@ -1093,7 +1093,7 @@ public void testLifecycleAppliedToFailureStore() throws Exception {
// Let's verify the merge settings
ClusterGetSettingsAction.Response response = client().execute(
ClusterGetSettingsAction.INSTANCE,
- new ClusterGetSettingsAction.Request()
+ new ClusterGetSettingsAction.Request(TEST_REQUEST_TIMEOUT)
).get();
Settings clusterSettings = response.persistentSettings();
diff --git a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamsStatsTests.java b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamsStatsTests.java
index bc313d145c17e..b2ddab164b31b 100644
--- a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamsStatsTests.java
+++ b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamsStatsTests.java
@@ -131,7 +131,10 @@ public void testStatsClosedBackingIndexDataStream() throws Exception {
assertTrue(indicesAdmin().close(new CloseIndexRequest(".ds-" + dataStreamName + "-*-000001")).actionGet().isAcknowledged());
assertBusy(
- () -> assertNotEquals(ClusterHealthStatus.RED, clusterAdmin().health(new ClusterHealthRequest()).actionGet().getStatus())
+ () -> assertNotEquals(
+ ClusterHealthStatus.RED,
+ clusterAdmin().health(new ClusterHealthRequest(TEST_REQUEST_TIMEOUT)).actionGet().getStatus()
+ )
);
DataStreamsStatsAction.Response stats = getDataStreamsStats();
diff --git a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/LookAHeadTimeTests.java b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/LookAHeadTimeTests.java
index a612587262463..e3d5ad0d63e84 100644
--- a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/LookAHeadTimeTests.java
+++ b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/LookAHeadTimeTests.java
@@ -118,7 +118,9 @@ public void testLookAheadTimeSettingHigherThanTimeSeriesPollIntervalSetting() {
}
private void updateClusterSettings(Settings settings) {
- clusterAdmin().updateSettings(new ClusterUpdateSettingsRequest().persistentSettings(settings)).actionGet();
+ clusterAdmin().updateSettings(
+ new ClusterUpdateSettingsRequest(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT).persistentSettings(settings)
+ ).actionGet();
}
private void updateIndexSettings(Settings settings) {
diff --git a/modules/lang-painless/src/internalClusterTest/java/org/elasticsearch/painless/action/CrossClusterPainlessExecuteIT.java b/modules/lang-painless/src/internalClusterTest/java/org/elasticsearch/painless/action/CrossClusterPainlessExecuteIT.java
index 1bd6468c562f8..99fb0edd4334f 100644
--- a/modules/lang-painless/src/internalClusterTest/java/org/elasticsearch/painless/action/CrossClusterPainlessExecuteIT.java
+++ b/modules/lang-painless/src/internalClusterTest/java/org/elasticsearch/painless/action/CrossClusterPainlessExecuteIT.java
@@ -175,7 +175,7 @@ private void setupTwoClusters() throws Exception {
assertFalse(
client(REMOTE_CLUSTER).admin()
.cluster()
- .prepareHealth(REMOTE_INDEX)
+ .prepareHealth(TEST_REQUEST_TIMEOUT, REMOTE_INDEX)
.setWaitForYellowStatus()
.setTimeout(TimeValue.timeValueSeconds(10))
.get()
diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java
index ac850e991296c..bf34c322c1a95 100644
--- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java
+++ b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java
@@ -88,8 +88,8 @@ public void testStartMigrationAndImmediatelyCheckStatus() throws Exception {
ensureGreen();
- PostFeatureUpgradeRequest migrationRequest = new PostFeatureUpgradeRequest();
- GetFeatureUpgradeStatusRequest getStatusRequest = new GetFeatureUpgradeStatusRequest();
+ PostFeatureUpgradeRequest migrationRequest = new PostFeatureUpgradeRequest(TEST_REQUEST_TIMEOUT);
+ GetFeatureUpgradeStatusRequest getStatusRequest = new GetFeatureUpgradeStatusRequest(TEST_REQUEST_TIMEOUT);
// Start the migration and *immediately* request the status. We're trying to detect a race condition with this test, so we need to
// do this as fast as possible, but not before the request to start the migration completes.
@@ -170,7 +170,7 @@ public void testMigrateInternalManagedSystemIndex() throws Exception {
postUpgradeHookCalled.set(true);
});
- PostFeatureUpgradeRequest migrationRequest = new PostFeatureUpgradeRequest();
+ PostFeatureUpgradeRequest migrationRequest = new PostFeatureUpgradeRequest(TEST_REQUEST_TIMEOUT);
PostFeatureUpgradeResponse migrationResponse = client().execute(PostFeatureUpgradeAction.INSTANCE, migrationRequest).get();
assertThat(migrationResponse.getReason(), nullValue());
assertThat(migrationResponse.getElasticsearchException(), nullValue());
@@ -180,7 +180,7 @@ public void testMigrateInternalManagedSystemIndex() throws Exception {
.collect(Collectors.toSet());
assertThat(migratingFeatures, hasItem(FEATURE_NAME));
- GetFeatureUpgradeStatusRequest getStatusRequest = new GetFeatureUpgradeStatusRequest();
+ GetFeatureUpgradeStatusRequest getStatusRequest = new GetFeatureUpgradeStatusRequest(TEST_REQUEST_TIMEOUT);
// The feature upgrade may take longer than ten seconds when tests are running
// in parallel, so we give assertBusy a sixty-second timeout.
assertBusy(() -> {
@@ -196,7 +196,7 @@ public void testMigrateInternalManagedSystemIndex() throws Exception {
assertTrue("the pre-migration hook wasn't actually called", preUpgradeHookCalled.get());
assertTrue("the post-migration hook wasn't actually called", postUpgradeHookCalled.get());
- Metadata finalMetadata = clusterAdmin().prepareState().get().getState().metadata();
+ Metadata finalMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata();
// Check that the results metadata is what we expect.
FeatureMigrationResults currentResults = finalMetadata.custom(FeatureMigrationResults.TYPE);
assertThat(currentResults, notNullValue());
@@ -246,12 +246,12 @@ public void testMigrateIndexWithWriteBlock() throws Exception {
updateIndexSettings(Settings.builder().put("index.blocks.write", true), indexName);
ensureGreen();
- client().execute(PostFeatureUpgradeAction.INSTANCE, new PostFeatureUpgradeRequest()).get();
+ client().execute(PostFeatureUpgradeAction.INSTANCE, new PostFeatureUpgradeRequest(TEST_REQUEST_TIMEOUT)).get();
assertBusy(() -> {
GetFeatureUpgradeStatusResponse statusResp = client().execute(
GetFeatureUpgradeStatusAction.INSTANCE,
- new GetFeatureUpgradeStatusRequest()
+ new GetFeatureUpgradeStatusRequest(TEST_REQUEST_TIMEOUT)
).get();
logger.info(Strings.toString(statusResp));
assertThat(statusResp.getUpgradeStatus(), equalTo(GetFeatureUpgradeStatusResponse.UpgradeStatus.NO_MIGRATION_NEEDED));
@@ -299,7 +299,7 @@ public void onFailure(Exception e) {
fail("cluster state update failed, see log for details");
}
- PostFeatureUpgradeRequest migrationRequest = new PostFeatureUpgradeRequest();
+ PostFeatureUpgradeRequest migrationRequest = new PostFeatureUpgradeRequest(TEST_REQUEST_TIMEOUT);
PostFeatureUpgradeResponse migrationResponse = client().execute(PostFeatureUpgradeAction.INSTANCE, migrationRequest).get();
// Make sure we actually started the migration
assertTrue(
@@ -309,7 +309,7 @@ public void onFailure(Exception e) {
// Now wait for the migration to finish (otherwise the test infra explodes)
assertBusy(() -> {
- GetFeatureUpgradeStatusRequest getStatusRequest = new GetFeatureUpgradeStatusRequest();
+ GetFeatureUpgradeStatusRequest getStatusRequest = new GetFeatureUpgradeStatusRequest(TEST_REQUEST_TIMEOUT);
GetFeatureUpgradeStatusResponse statusResp = client().execute(GetFeatureUpgradeStatusAction.INSTANCE, getStatusRequest).get();
logger.info(Strings.toString(statusResp));
assertThat(statusResp.getUpgradeStatus(), equalTo(GetFeatureUpgradeStatusResponse.UpgradeStatus.NO_MIGRATION_NEEDED));
@@ -337,8 +337,10 @@ private void migrateWithTemplatesV1(String templatePrefix, SystemIndexDescriptor
ensureGreen();
- PostFeatureUpgradeResponse migrationResponse = client().execute(PostFeatureUpgradeAction.INSTANCE, new PostFeatureUpgradeRequest())
- .get();
+ PostFeatureUpgradeResponse migrationResponse = client().execute(
+ PostFeatureUpgradeAction.INSTANCE,
+ new PostFeatureUpgradeRequest(TEST_REQUEST_TIMEOUT)
+ ).get();
assertTrue(migrationResponse.isAccepted());
}
@@ -349,7 +351,7 @@ public void testBailOnMigrateWithTemplatesV1() throws Exception {
assertBusy(() -> {
GetFeatureUpgradeStatusResponse statusResp = client().execute(
GetFeatureUpgradeStatusAction.INSTANCE,
- new GetFeatureUpgradeStatusRequest()
+ new GetFeatureUpgradeStatusRequest(TEST_REQUEST_TIMEOUT)
).get();
logger.info(Strings.toString(statusResp));
assertThat(statusResp.getUpgradeStatus(), equalTo(GetFeatureUpgradeStatusResponse.UpgradeStatus.ERROR));
@@ -364,7 +366,7 @@ public void testMigrateWithTemplatesV1() throws Exception {
assertBusy(() -> {
GetFeatureUpgradeStatusResponse statusResp = client().execute(
GetFeatureUpgradeStatusAction.INSTANCE,
- new GetFeatureUpgradeStatusRequest()
+ new GetFeatureUpgradeStatusRequest(TEST_REQUEST_TIMEOUT)
).get();
logger.info(Strings.toString(statusResp));
assertThat(statusResp.getUpgradeStatus(), equalTo(GetFeatureUpgradeStatusResponse.UpgradeStatus.NO_MIGRATION_NEEDED));
@@ -426,8 +428,10 @@ private void migrateWithTemplatesV2(String prefix, SystemIndexDescriptor... desc
ensureGreen();
- PostFeatureUpgradeResponse migrationResponse = client().execute(PostFeatureUpgradeAction.INSTANCE, new PostFeatureUpgradeRequest())
- .get();
+ PostFeatureUpgradeResponse migrationResponse = client().execute(
+ PostFeatureUpgradeAction.INSTANCE,
+ new PostFeatureUpgradeRequest(TEST_REQUEST_TIMEOUT)
+ ).get();
assertTrue(migrationResponse.isAccepted());
}
@@ -437,7 +441,7 @@ public void testBailOnMigrateWithTemplatesV2() throws Exception {
assertBusy(() -> {
GetFeatureUpgradeStatusResponse statusResp = client().execute(
GetFeatureUpgradeStatusAction.INSTANCE,
- new GetFeatureUpgradeStatusRequest()
+ new GetFeatureUpgradeStatusRequest(TEST_REQUEST_TIMEOUT)
).get();
logger.info(Strings.toString(statusResp));
assertThat(statusResp.getUpgradeStatus(), equalTo(GetFeatureUpgradeStatusResponse.UpgradeStatus.ERROR));
@@ -452,7 +456,7 @@ public void testMigrateWithTemplatesV2() throws Exception {
assertBusy(() -> {
GetFeatureUpgradeStatusResponse statusResp = client().execute(
GetFeatureUpgradeStatusAction.INSTANCE,
- new GetFeatureUpgradeStatusRequest()
+ new GetFeatureUpgradeStatusRequest(TEST_REQUEST_TIMEOUT)
).get();
logger.info(Strings.toString(statusResp));
assertThat(statusResp.getUpgradeStatus(), equalTo(GetFeatureUpgradeStatusResponse.UpgradeStatus.NO_MIGRATION_NEEDED));
diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java
index 8f9c2b7f34105..ebe4b1835b103 100644
--- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java
+++ b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java
@@ -176,7 +176,7 @@ public void testMultipleFeatureMigration() throws Exception {
hooksCalled.countDown();
});
- PostFeatureUpgradeRequest migrationRequest = new PostFeatureUpgradeRequest();
+ PostFeatureUpgradeRequest migrationRequest = new PostFeatureUpgradeRequest(TEST_REQUEST_TIMEOUT);
PostFeatureUpgradeResponse migrationResponse = client().execute(PostFeatureUpgradeAction.INSTANCE, migrationRequest).get();
assertThat(migrationResponse.getReason(), nullValue());
assertThat(migrationResponse.getElasticsearchException(), nullValue());
@@ -189,7 +189,7 @@ public void testMultipleFeatureMigration() throws Exception {
// wait for all the plugin methods to have been called before assertBusy since that will exponentially backoff
assertThat(hooksCalled.await(30, TimeUnit.SECONDS), is(true));
- GetFeatureUpgradeStatusRequest getStatusRequest = new GetFeatureUpgradeStatusRequest();
+ GetFeatureUpgradeStatusRequest getStatusRequest = new GetFeatureUpgradeStatusRequest(TEST_REQUEST_TIMEOUT);
assertBusy(() -> {
GetFeatureUpgradeStatusResponse statusResponse = client().execute(GetFeatureUpgradeStatusAction.INSTANCE, getStatusRequest)
.get();
@@ -203,7 +203,7 @@ public void testMultipleFeatureMigration() throws Exception {
assertTrue("the second plugin's pre-migration hook wasn't actually called", secondPluginPreMigrationHookCalled.get());
assertTrue("the second plugin's post-migration hook wasn't actually called", secondPluginPostMigrationHookCalled.get());
- Metadata finalMetadata = clusterAdmin().prepareState().get().getState().metadata();
+ Metadata finalMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata();
// Check that the results metadata is what we expect
FeatureMigrationResults currentResults = finalMetadata.custom(FeatureMigrationResults.TYPE);
assertThat(currentResults, notNullValue());
diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/SystemIndexMigrationIT.java b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/SystemIndexMigrationIT.java
index 47c6e8faf15bf..6484d483bbcd8 100644
--- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/SystemIndexMigrationIT.java
+++ b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/SystemIndexMigrationIT.java
@@ -85,7 +85,7 @@ public void testSystemIndexMigrationCanBeInterruptedWithShutdown() throws Except
clusterService.addListener(clusterStateListener);
// create task by calling API
- final PostFeatureUpgradeRequest req = new PostFeatureUpgradeRequest();
+ final PostFeatureUpgradeRequest req = new PostFeatureUpgradeRequest(TEST_REQUEST_TIMEOUT);
client().execute(PostFeatureUpgradeAction.INSTANCE, req);
logger.info("migrate feature api called");
@@ -101,12 +101,12 @@ public Settings onNodeStopped(String nodeName) throws Exception {
assertBusy(() -> {
// Wait for the node we restarted to completely rejoin the cluster
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat("expected restarted node to rejoin cluster", clusterState.getNodes().size(), equalTo(2));
GetFeatureUpgradeStatusResponse statusResponse = client().execute(
GetFeatureUpgradeStatusAction.INSTANCE,
- new GetFeatureUpgradeStatusRequest()
+ new GetFeatureUpgradeStatusRequest(TEST_REQUEST_TIMEOUT)
).get();
assertThat(
"expected migration to fail due to restarting only data node",
diff --git a/plugins/discovery-azure-classic/src/internalClusterTest/java/org/elasticsearch/discovery/azure/classic/AzureSimpleTests.java b/plugins/discovery-azure-classic/src/internalClusterTest/java/org/elasticsearch/discovery/azure/classic/AzureSimpleTests.java
index 9a55bfde38b3c..a3e8a3a02f93b 100644
--- a/plugins/discovery-azure-classic/src/internalClusterTest/java/org/elasticsearch/discovery/azure/classic/AzureSimpleTests.java
+++ b/plugins/discovery-azure-classic/src/internalClusterTest/java/org/elasticsearch/discovery/azure/classic/AzureSimpleTests.java
@@ -30,7 +30,7 @@ public void testOneNodeShouldRunUsingPrivateIp() {
assertNotNull(
client().admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.setMasterNodeTimeout(TimeValue.timeValueSeconds(1))
.get()
.getState()
@@ -52,7 +52,7 @@ public void testOneNodeShouldRunUsingPublicIp() {
assertNotNull(
client().admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.setMasterNodeTimeout(TimeValue.timeValueSeconds(1))
.get()
.getState()
diff --git a/plugins/discovery-azure-classic/src/internalClusterTest/java/org/elasticsearch/discovery/azure/classic/AzureTwoStartedNodesTests.java b/plugins/discovery-azure-classic/src/internalClusterTest/java/org/elasticsearch/discovery/azure/classic/AzureTwoStartedNodesTests.java
index b8d0a1ef7bdd5..6c07670266278 100644
--- a/plugins/discovery-azure-classic/src/internalClusterTest/java/org/elasticsearch/discovery/azure/classic/AzureTwoStartedNodesTests.java
+++ b/plugins/discovery-azure-classic/src/internalClusterTest/java/org/elasticsearch/discovery/azure/classic/AzureTwoStartedNodesTests.java
@@ -33,7 +33,7 @@ public void testTwoNodesShouldRunUsingPrivateOrPublicIp() {
assertNotNull(
client().admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.setMasterNodeTimeout(TimeValue.timeValueSeconds(1))
.get()
.getState()
@@ -47,7 +47,7 @@ public void testTwoNodesShouldRunUsingPrivateOrPublicIp() {
assertNotNull(
client().admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.setMasterNodeTimeout(TimeValue.timeValueSeconds(1))
.get()
.getState()
diff --git a/plugins/discovery-ec2/src/internalClusterTest/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java b/plugins/discovery-ec2/src/internalClusterTest/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java
index 033e0e3823536..0ed530c9ee3de 100644
--- a/plugins/discovery-ec2/src/internalClusterTest/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java
+++ b/plugins/discovery-ec2/src/internalClusterTest/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java
@@ -31,7 +31,7 @@ public void testMinimumMasterNodesStart() {
// We try to update a setting now
final String expectedValue = UUIDs.randomBase64UUID(random());
final String settingName = "cluster.routing.allocation.exclude.any_attribute";
- final ClusterUpdateSettingsResponse response = clusterAdmin().prepareUpdateSettings()
+ final ClusterUpdateSettingsResponse response = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().put(settingName, expectedValue))
.get();
diff --git a/plugins/discovery-gce/src/internalClusterTest/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java b/plugins/discovery-gce/src/internalClusterTest/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java
index 32be38ac7f813..ca8a4449c4d6d 100644
--- a/plugins/discovery-gce/src/internalClusterTest/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java
+++ b/plugins/discovery-gce/src/internalClusterTest/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java
@@ -67,7 +67,7 @@ public void testJoin() {
ClusterStateResponse clusterStateResponse = client(masterNode).admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.setMasterNodeTimeout(TimeValue.timeValueSeconds(1))
.clear()
.setNodes(true)
@@ -79,7 +79,7 @@ public void testJoin() {
registerGceNode(secondNode);
clusterStateResponse = client(secondNode).admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.setMasterNodeTimeout(TimeValue.timeValueSeconds(1))
.clear()
.setNodes(true)
@@ -88,13 +88,13 @@ public void testJoin() {
assertNotNull(clusterStateResponse.getState().nodes().getMasterNodeId());
// wait for the cluster to form
- assertNoTimeout(client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(2)).get());
+ assertNoTimeout(client().admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes(Integer.toString(2)).get());
assertNumberOfNodes(2);
// add one more node and wait for it to join
final String thirdNode = internalCluster().startDataOnlyNode();
registerGceNode(thirdNode);
- assertNoTimeout(client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(3)).get());
+ assertNoTimeout(client().admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes(Integer.toString(3)).get());
assertNumberOfNodes(3);
}
diff --git a/plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsTests.java b/plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsTests.java
index 081c6c26319ab..39bc59012ed09 100644
--- a/plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsTests.java
+++ b/plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsTests.java
@@ -141,7 +141,7 @@ public void testSimpleWorkflow() {
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
ensureGreen();
assertThat(count(client, "test-idx-1"), equalTo(100L));
- ClusterState clusterState = client.admin().cluster().prepareState().get().getState();
+ ClusterState clusterState = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(clusterState.getMetadata().hasIndex("test-idx-1"), equalTo(true));
assertThat(clusterState.getMetadata().hasIndex("test-idx-2"), equalTo(false));
final BlobStoreRepository repo = (BlobStoreRepository) getInstanceFromNode(RepositoriesService.class).repository("test-repo");
diff --git a/qa/restricted-loggers/src/test/java/org/elasticsearch/common/logging/LoggersTests.java b/qa/restricted-loggers/src/test/java/org/elasticsearch/common/logging/LoggersTests.java
index bd7e086d01f0d..5af036a9a0391 100644
--- a/qa/restricted-loggers/src/test/java/org/elasticsearch/common/logging/LoggersTests.java
+++ b/qa/restricted-loggers/src/test/java/org/elasticsearch/common/logging/LoggersTests.java
@@ -29,7 +29,7 @@ public class LoggersTests extends ESTestCase {
public void testClusterUpdateSettingsRequestValidationForLoggers() {
assertThat(Loggers.RESTRICTED_LOGGERS, hasSize(greaterThan(0)));
- ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest();
+ ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT);
for (String logger : Loggers.RESTRICTED_LOGGERS) {
var validation = request.persistentSettings(Map.of("logger." + logger, org.elasticsearch.logging.Level.DEBUG)).validate();
assertNotNull(validation);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java
index 920677e8c4b4a..27f8fc915cdd7 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java
@@ -395,7 +395,7 @@ public void testFlush() {
clearInterceptedActions();
String[] concreteIndexNames = TestIndexNameExpressionResolver.newInstance()
- .concreteIndexNames(clusterAdmin().prepareState().get().getState(), flushRequest);
+ .concreteIndexNames(clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState(), flushRequest);
assertIndicesSubset(Arrays.asList(concreteIndexNames), indexShardActions);
}
@@ -422,7 +422,7 @@ public void testRefresh() {
clearInterceptedActions();
String[] concreteIndexNames = TestIndexNameExpressionResolver.newInstance()
- .concreteIndexNames(clusterAdmin().prepareState().get().getState(), refreshRequest);
+ .concreteIndexNames(clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState(), refreshRequest);
assertIndicesSubset(Arrays.asList(concreteIndexNames), indexShardActions);
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainIT.java
index 897f10b031dcb..245e7cede4cf5 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainIT.java
@@ -1053,7 +1053,7 @@ public void testCannotAllocateStaleReplicaExplanation() throws Exception {
logger.info("--> close the index, now the replica is stale");
assertAcked(indicesAdmin().prepareClose("idx"));
- final ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth("idx")
+ final ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "idx")
.setTimeout(TimeValue.timeValueSeconds(30))
.setWaitForActiveShards(ActiveShardCount.ONE)
.setWaitForNoInitializingShards(true)
@@ -1254,7 +1254,7 @@ private void prepareIndex(
if (state == IndexMetadata.State.CLOSE) {
assertAcked(indicesAdmin().prepareClose("idx"));
- final ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth("idx")
+ final ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "idx")
.setTimeout(TimeValue.timeValueSeconds(30))
.setWaitForActiveShards(activeShardCount)
.setWaitForEvents(Priority.LANGUID)
@@ -1275,13 +1275,13 @@ private void indexData() {
}
private String primaryNodeName() {
- ClusterState clusterState = admin().cluster().prepareState().get().getState();
+ ClusterState clusterState = admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
String nodeId = clusterState.getRoutingTable().index("idx").shard(0).primaryShard().currentNodeId();
return clusterState.getRoutingNodes().node(nodeId).node().getName();
}
private DiscoveryNode replicaNode() {
- ClusterState clusterState = admin().cluster().prepareState().get().getState();
+ ClusterState clusterState = admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
String nodeId = clusterState.getRoutingTable().index("idx").shard(0).replicaShards().get(0).currentNodeId();
return clusterState.getRoutingNodes().node(nodeId).node();
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceActionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceActionIT.java
index d0e0543bcca03..54b1b08806a93 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceActionIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetDesiredBalanceActionIT.java
@@ -37,7 +37,9 @@ public void testDesiredBalanceOnMultiNodeCluster() throws Exception {
indexData(index);
- var clusterHealthResponse = clusterAdmin().health(new ClusterHealthRequest().waitForStatus(ClusterHealthStatus.GREEN)).get();
+ var clusterHealthResponse = clusterAdmin().health(
+ new ClusterHealthRequest(TEST_REQUEST_TIMEOUT).waitForStatus(ClusterHealthStatus.GREEN)
+ ).get();
assertEquals(RestStatus.OK, clusterHealthResponse.status());
final var desiredBalanceResponse = safeGet(
@@ -50,7 +52,7 @@ public void testDesiredBalanceOnMultiNodeCluster() throws Exception {
for (var entry : shardsMap.entrySet()) {
Integer shardId = entry.getKey();
DesiredBalanceResponse.DesiredShards desiredShards = entry.getValue();
- IndexShardRoutingTable shardRoutingTable = clusterAdmin().prepareState()
+ IndexShardRoutingTable shardRoutingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.routingTable()
@@ -73,7 +75,9 @@ public void testDesiredBalanceWithUnassignedShards() throws Exception {
int numberOfReplicas = 1;
createIndex(index, numberOfShards, numberOfReplicas);
indexData(index);
- var clusterHealthResponse = clusterAdmin().health(new ClusterHealthRequest(index).waitForStatus(ClusterHealthStatus.YELLOW)).get();
+ var clusterHealthResponse = clusterAdmin().health(
+ new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, index).waitForStatus(ClusterHealthStatus.YELLOW)
+ ).get();
assertEquals(RestStatus.OK, clusterHealthResponse.status());
final var desiredBalanceResponse = safeGet(
@@ -86,7 +90,7 @@ public void testDesiredBalanceWithUnassignedShards() throws Exception {
for (var entry : shardsMap.entrySet()) {
Integer shardId = entry.getKey();
DesiredBalanceResponse.DesiredShards desiredShards = entry.getValue();
- IndexShardRoutingTable shardRoutingTable = clusterAdmin().prepareState()
+ IndexShardRoutingTable shardRoutingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.routingTable()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDesiredNodesActionsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDesiredNodesActionsIT.java
index 63801f8c1e511..0fb8b450ffaff 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDesiredNodesActionsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDesiredNodesActionsIT.java
@@ -87,6 +87,8 @@ public void testUpdateDesiredNodesIsIdempotent() {
}
final var equivalentUpdateRequest = new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
updateDesiredNodesRequest.getHistoryID(),
updateDesiredNodesRequest.getVersion(),
desiredNodesList,
@@ -105,6 +107,8 @@ public void testGoingBackwardsWithinTheSameHistoryIsForbidden() {
updateDesiredNodes(updateDesiredNodesRequest);
final var backwardsUpdateDesiredNodesRequest = new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
updateDesiredNodesRequest.getHistoryID(),
updateDesiredNodesRequest.getVersion() - 1,
updateDesiredNodesRequest.getNodes(),
@@ -123,6 +127,8 @@ public void testSameVersionWithDifferentContentIsForbidden() {
updateDesiredNodes(updateDesiredNodesRequest);
final var updateDesiredNodesRequestWithSameHistoryIdAndVersionAndDifferentSpecs = new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
updateDesiredNodesRequest.getHistoryID(),
updateDesiredNodesRequest.getVersion(),
randomList(1, 10, DesiredNodesTestCase::randomDesiredNode),
@@ -192,6 +198,8 @@ public void testNodeProcessorsGetValidatedWithDesiredNodeProcessors() {
// This test verifies that the validation doesn't throw on desired nodes
// with a higher number of available processors than the node running the tests.
final var updateDesiredNodesRequest = new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
UUIDs.randomBase64UUID(),
randomIntBetween(1, 20),
randomList(
@@ -267,7 +275,7 @@ public void testDeleteDesiredNodesTasksAreBatchedCorrectly() throws Exception {
future.actionGet();
}
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final DesiredNodes latestDesiredNodes = DesiredNodes.latestFromClusterState(state);
assertThat(latestDesiredNodes, is(nullValue()));
}
@@ -309,6 +317,8 @@ private UpdateDesiredNodesRequest randomUpdateDesiredNodesRequest() {
private UpdateDesiredNodesRequest randomUpdateDesiredNodesRequest(Settings settings) {
return new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
UUIDs.randomBase64UUID(),
randomIntBetween(2, 20),
randomList(2, 10, () -> randomDesiredNode(settings)),
@@ -318,6 +328,8 @@ private UpdateDesiredNodesRequest randomUpdateDesiredNodesRequest(Settings setti
private UpdateDesiredNodesRequest randomDryRunUpdateDesiredNodesRequest(Settings settings) {
return new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
UUIDs.randomBase64UUID(),
randomIntBetween(2, 20),
randomList(2, 10, () -> randomDesiredNode(settings)),
@@ -331,7 +343,7 @@ private void deleteDesiredNodes() {
}
private DesiredNodes getLatestDesiredNodes() {
- final GetDesiredNodesAction.Request request = new GetDesiredNodesAction.Request();
+ final GetDesiredNodesAction.Request request = new GetDesiredNodesAction.Request(TEST_REQUEST_TIMEOUT);
final GetDesiredNodesAction.Response response = client().execute(GetDesiredNodesAction.INSTANCE, request).actionGet();
return response.getDesiredNodes();
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java
index 32d8be475dbbe..180bef7ea4098 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java
@@ -141,7 +141,7 @@ public void testMasterNodeOperationTasks() throws Exception {
registerTaskManagerListeners(TransportClusterHealthAction.NAME);
// First run the health on the master node - should produce only one task on the master node
- internalCluster().masterClient().admin().cluster().prepareHealth().get();
+ internalCluster().masterClient().admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).get();
assertEquals(1, numberOfEvents(TransportClusterHealthAction.NAME, Tuple::v1)); // counting only registration events
// counting only unregistration events
// When checking unregistration events there might be some delay since receiving the response from the cluster doesn't
@@ -151,7 +151,7 @@ public void testMasterNodeOperationTasks() throws Exception {
resetTaskManagerListeners(TransportClusterHealthAction.NAME);
// Now run the health on a non-master node - should produce one task on master and one task on another node
- internalCluster().nonMasterClient().admin().cluster().prepareHealth().get();
+ internalCluster().nonMasterClient().admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).get();
assertEquals(2, numberOfEvents(TransportClusterHealthAction.NAME, Tuple::v1)); // counting only registration events
// counting only unregistration events
assertBusy(() -> assertEquals(2, numberOfEvents(TransportClusterHealthAction.NAME, event -> event.v1() == false)));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateActionDisruptionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateActionDisruptionIT.java
index bb2c97ec9aa69..85dd1337204b2 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateActionDisruptionIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateActionDisruptionIT.java
@@ -49,7 +49,7 @@ protected Collection> nodePlugins() {
public void testNonLocalRequestAlwaysFindsMaster() throws Exception {
runRepeatedlyWhileChangingMaster(() -> {
- final ClusterStateRequestBuilder clusterStateRequestBuilder = clusterAdmin().prepareState()
+ final ClusterStateRequestBuilder clusterStateRequestBuilder = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setNodes(true)
.setBlocks(true)
@@ -69,7 +69,7 @@ public void testLocalRequestAlwaysSucceeds() throws Exception {
final String node = randomFrom(internalCluster().getNodeNames());
final DiscoveryNodes discoveryNodes = client(node).admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setLocal(true)
.setNodes(true)
@@ -98,7 +98,7 @@ public void testNonLocalRequestAlwaysFindsMasterAndWaitsForMetadata() throws Exc
final long waitForMetadataVersion = randomLongBetween(Math.max(1, metadataVersion - 3), metadataVersion + 5);
final ClusterStateRequestBuilder clusterStateRequestBuilder = client(node).admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setNodes(true)
.setMetadata(true)
@@ -131,7 +131,7 @@ public void testLocalRequestWaitsForMetadata() throws Exception {
final long waitForMetadataVersion = randomLongBetween(Math.max(1, metadataVersion - 3), metadataVersion + 5);
final ClusterStateResponse clusterStateResponse = client(node).admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setLocal(true)
.setMetadata(true)
@@ -156,7 +156,7 @@ public void runRepeatedlyWhileChangingMaster(Runnable runnable) throws Exception
assertBusy(
() -> assertThat(
- clusterAdmin().prepareState()
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setMetadata(true)
.setBlocks(true)
@@ -188,7 +188,7 @@ public void runRepeatedlyWhileChangingMaster(Runnable runnable) throws Exception
assertAcked(
client(nonMasterNode).admin()
.cluster()
- .prepareUpdateSettings()
+ .prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().put(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), value))
);
}
@@ -225,17 +225,22 @@ public void runRepeatedlyWhileChangingMaster(Runnable runnable) throws Exception
public void testFailsWithBlockExceptionIfBlockedAndBlocksNotRequested() {
internalCluster().startMasterOnlyNode(Settings.builder().put(GatewayService.RECOVER_AFTER_DATA_NODES_SETTING.getKey(), 1).build());
- final var state = safeGet(clusterAdmin().prepareState().clear().setBlocks(true).execute()).getState();
+ final var state = safeGet(clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).clear().setBlocks(true).execute()).getState();
assertTrue(state.blocks().hasGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK));
assertThat(
- safeAwaitFailure(SubscribableListener.newForked(l -> clusterAdmin().prepareState().clear().execute(l))),
+ safeAwaitFailure(
+ SubscribableListener.newForked(
+ l -> clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).clear().execute(l)
+ )
+ ),
instanceOf(ClusterBlockException.class)
);
internalCluster().startDataOnlyNode();
- final var recoveredState = safeGet(clusterAdmin().prepareState().clear().setBlocks(randomBoolean()).execute()).getState();
+ final var recoveredState = safeGet(clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).clear().setBlocks(randomBoolean()).execute())
+ .getState();
assertFalse(recoveredState.blocks().hasGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK));
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java
index 0c3dac0f99b6c..2385c42526d40 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java
@@ -64,7 +64,8 @@ private void assertCounts(ClusterStatsNodes.Counts counts, int total, Map dataNodes = clusterAdmin().prepareState().get().getState().nodes().getDataNodes();
+ Map dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getDataNodes();
assertTrue("at least 2 nodes but was: " + dataNodes.size(), dataNodes.size() >= 2);
DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode[]::new);
String mergeNode = discoveryNodes[0].getName();
@@ -158,7 +158,11 @@ public void testShrinkIndexPrimaryTerm() throws Exception {
internalCluster().ensureAtLeastNumDataNodes(2);
prepareCreate("source").setSettings(Settings.builder().put(indexSettings()).put("number_of_shards", numberOfShards)).get();
- final Map dataNodes = clusterAdmin().prepareState().get().getState().nodes().getDataNodes();
+ final Map dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getDataNodes();
assertThat(dataNodes.size(), greaterThanOrEqualTo(2));
final DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode[]::new);
final String mergeNode = discoveryNodes[0].getName();
@@ -222,7 +226,10 @@ public void testShrinkIndexPrimaryTerm() throws Exception {
}
private static IndexMetadata indexMetadata(final Client client, final String index) {
- final ClusterStateResponse clusterStateResponse = client.admin().cluster().state(new ClusterStateRequest()).actionGet();
+ final ClusterStateResponse clusterStateResponse = client.admin()
+ .cluster()
+ .state(new ClusterStateRequest(TEST_REQUEST_TIMEOUT))
+ .actionGet();
return clusterStateResponse.getState().metadata().index(index);
}
@@ -236,7 +243,7 @@ public void testCreateShrinkIndex() {
for (int i = 0; i < docs; i++) {
prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
- Map dataNodes = clusterAdmin().prepareState().get().getState().nodes().getDataNodes();
+ Map dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getDataNodes();
assertTrue("at least 2 nodes but was: " + dataNodes.size(), dataNodes.size() >= 2);
DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode[]::new);
// ensure all shards are allocated otherwise the ensure green below might not succeed since we require the merge node
@@ -272,7 +279,7 @@ public void testCreateShrinkIndex() {
assertNoResizeSourceIndexSettings("target");
// resolve true merge node - this is not always the node we required as all shards may be on another node
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
DiscoveryNode mergeNode = state.nodes().get(state.getRoutingTable().index("target").shard(0).primaryShard().currentNodeId());
logger.info("merge node {}", mergeNode);
@@ -342,7 +349,7 @@ public void testCreateShrinkIndexFails() throws Exception {
for (int i = 0; i < 20; i++) {
prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
- Map dataNodes = clusterAdmin().prepareState().get().getState().nodes().getDataNodes();
+ Map dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getDataNodes();
assertTrue("at least 2 nodes but was: " + dataNodes.size(), dataNodes.size() >= 2);
DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode[]::new);
String spareNode = discoveryNodes[0].getName();
@@ -369,7 +376,7 @@ public void testCreateShrinkIndexFails() throws Exception {
.build()
)
.get();
- clusterAdmin().prepareHealth("target").setWaitForEvents(Priority.LANGUID).get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "target").setWaitForEvents(Priority.LANGUID).get();
// now we move all shards away from the merge node
updateIndexSettings(
@@ -382,7 +389,7 @@ public void testCreateShrinkIndexFails() throws Exception {
updateIndexSettings(Settings.builder().putNull("index.routing.allocation.exclude._name"), "target");
// wait until it fails
assertBusy(() -> {
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
RoutingTable routingTables = clusterStateResponse.getState().routingTable();
assertTrue(routingTables.index("target").shard(0).shard(0).unassigned());
assertEquals(
@@ -427,7 +434,7 @@ public void testCreateShrinkWithIndexSort() throws Exception {
for (int i = 0; i < 20; i++) {
prepareIndex("source").setId(Integer.toString(i)).setSource("{\"foo\" : \"bar\", \"id\" : " + i + "}", XContentType.JSON).get();
}
- Map dataNodes = clusterAdmin().prepareState().get().getState().nodes().getDataNodes();
+ Map dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getDataNodes();
assertTrue("at least 2 nodes but was: " + dataNodes.size(), dataNodes.size() >= 2);
DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode[]::new);
String mergeNode = discoveryNodes[0].getName();
@@ -482,7 +489,7 @@ public void testShrinkCommitsMergeOnIdle() throws Exception {
prepareIndex("source").setSource("{\"foo\" : \"bar\", \"i\" : " + i + "}", XContentType.JSON).get();
}
indicesAdmin().prepareFlush("source").get();
- Map dataNodes = clusterAdmin().prepareState().get().getState().nodes().getDataNodes();
+ Map dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getDataNodes();
DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode[]::new);
// ensure all shards are allocated otherwise the ensure green below might not succeed since we require the merge node
// if we change the setting too quickly we will end up with one replica unassigned which can't be assigned anymore due
@@ -508,7 +515,7 @@ public void testShrinkCommitsMergeOnIdle() throws Exception {
ensureGreen();
assertNoResizeSourceIndexSettings("target");
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
IndexMetadata target = clusterStateResponse.getState().getMetadata().index("target");
indicesAdmin().prepareForceMerge("target").setMaxNumSegments(1).setFlush(false).get();
IndicesSegmentResponse targetSegStats = indicesAdmin().prepareSegments("target").get();
@@ -601,7 +608,7 @@ public void testShrinkThenSplitWithFailedNode() throws Exception {
}
static void assertNoResizeSourceIndexSettings(final String index) {
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState()
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.clear()
.setMetadata(true)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java
index 22549a1562dcd..41646496c59c4 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/SplitIndexIT.java
@@ -333,7 +333,10 @@ public void testSplitIndexPrimaryTerm() throws Exception {
}
private static IndexMetadata indexMetadata(final Client client, final String index) {
- final ClusterStateResponse clusterStateResponse = client.admin().cluster().state(new ClusterStateRequest()).actionGet();
+ final ClusterStateResponse clusterStateResponse = client.admin()
+ .cluster()
+ .state(new ClusterStateRequest(TEST_REQUEST_TIMEOUT))
+ .actionGet();
return clusterStateResponse.getState().metadata().index(index);
}
@@ -371,7 +374,7 @@ public void testCreateSplitIndex() throws Exception {
ensureGreen();
assertNoResizeSourceIndexSettings("target");
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
DiscoveryNode mergeNode = state.nodes().get(state.getRoutingTable().index("target").shard(0).primaryShard().currentNodeId());
logger.info("split node {}", mergeNode);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java
index 16f8f51cb8aae..becea454b7d58 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java
@@ -83,7 +83,7 @@ public void testRolloverOnEmptyIndex() throws Exception {
assertThat(response.isDryRun(), equalTo(false));
assertThat(response.isRolledOver(), equalTo(true));
assertThat(response.getConditionStatus().size(), equalTo(0));
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexMetadata oldIndex = state.metadata().index("test_index-1");
if (explicitWriteIndex) {
assertTrue(oldIndex.getAliases().containsKey("test_alias"));
@@ -106,7 +106,7 @@ public void testRollover() throws Exception {
assertThat(response.isDryRun(), equalTo(false));
assertThat(response.isRolledOver(), equalTo(true));
assertThat(response.getConditionStatus().size(), equalTo(0));
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexMetadata oldIndex = state.metadata().index("test_index-2");
assertFalse(oldIndex.getAliases().containsKey("test_alias"));
final IndexMetadata newIndex = state.metadata().index("test_index-000003");
@@ -139,7 +139,7 @@ public void testRolloverWithExplicitWriteIndex() throws Exception {
assertThat(response.isDryRun(), equalTo(false));
assertThat(response.isRolledOver(), equalTo(true));
assertThat(response.getConditionStatus().size(), equalTo(0));
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexMetadata oldIndex = state.metadata().index("test_index-2");
assertTrue(oldIndex.getAliases().containsKey("test_alias"));
assertFalse(oldIndex.getAliases().get("test_alias").writeIndex());
@@ -187,7 +187,7 @@ public void testRolloverWithIndexSettings() throws Exception {
assertThat(response.isDryRun(), equalTo(false));
assertThat(response.isRolledOver(), equalTo(true));
assertThat(response.getConditionStatus().size(), equalTo(0));
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexMetadata oldIndex = state.metadata().index("test_index-2");
final IndexMetadata newIndex = state.metadata().index("test_index-000003");
assertThat(newIndex.getNumberOfShards(), equalTo(1));
@@ -220,7 +220,7 @@ public void testRolloverWithIndexSettingsWithoutPrefix() throws Exception {
assertThat(response.isDryRun(), equalTo(false));
assertThat(response.isRolledOver(), equalTo(true));
assertThat(response.getConditionStatus().size(), equalTo(0));
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexMetadata oldIndex = state.metadata().index("test_index-2");
final IndexMetadata newIndex = state.metadata().index("test_index-000003");
assertThat(newIndex.getNumberOfShards(), equalTo(1));
@@ -268,7 +268,7 @@ public void testRolloverDryRun() throws Exception {
assertThat(response.isDryRun(), equalTo(true));
assertThat(response.isRolledOver(), equalTo(false));
assertThat(response.getConditionStatus().size(), equalTo(0));
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexMetadata oldIndex = state.metadata().index("test_index-1");
assertTrue(oldIndex.getAliases().containsKey("test_alias"));
final IndexMetadata newIndex = state.metadata().index("test_index-000002");
@@ -334,7 +334,7 @@ public void testRolloverConditionsNotMet() throws Exception {
)
);
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexMetadata oldIndex = state.metadata().index("test_index-0");
assertTrue(oldIndex.getAliases().containsKey("test_alias"));
if (explicitWriteIndex) {
@@ -361,7 +361,7 @@ public void testRolloverWithNewIndexName() throws Exception {
assertThat(response.isDryRun(), equalTo(false));
assertThat(response.isRolledOver(), equalTo(true));
assertThat(response.getConditionStatus().size(), equalTo(0));
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexMetadata oldIndex = state.metadata().index("test_index");
final IndexMetadata newIndex = state.metadata().index("test_new_index");
assertTrue(newIndex.getAliases().containsKey("test_alias"));
@@ -452,7 +452,7 @@ public void testRolloverMaxSize() throws Exception {
assertThat(response.getOldIndex(), equalTo("test-1"));
assertThat(response.getNewIndex(), equalTo("test-000002"));
assertThat("No rollover with a large max_size condition", response.isRolledOver(), equalTo(false));
- final IndexMetadata oldIndex = clusterAdmin().prepareState().get().getState().metadata().index("test-1");
+ final IndexMetadata oldIndex = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test-1");
assertThat(oldIndex.getRolloverInfos().size(), equalTo(0));
}
@@ -466,7 +466,7 @@ public void testRolloverMaxSize() throws Exception {
assertThat(response.getOldIndex(), equalTo("test-1"));
assertThat(response.getNewIndex(), equalTo("test-000002"));
assertThat("Should rollover with a small max_size condition", response.isRolledOver(), equalTo(true));
- final IndexMetadata oldIndex = clusterAdmin().prepareState().get().getState().metadata().index("test-1");
+ final IndexMetadata oldIndex = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test-1");
List> metConditions = oldIndex.getRolloverInfos().get("test_alias").getMetConditions();
assertThat(metConditions.size(), equalTo(1));
assertThat(metConditions.get(0).toString(), equalTo(new MaxSizeCondition(maxSizeValue).toString()));
@@ -488,7 +488,11 @@ public void testRolloverMaxSize() throws Exception {
assertThat(response.getOldIndex(), equalTo("test-000002"));
assertThat(response.getNewIndex(), equalTo("test-000003"));
assertThat("No rollover with an empty index", response.isRolledOver(), equalTo(false));
- final IndexMetadata oldIndex = clusterAdmin().prepareState().get().getState().metadata().index("test-000002");
+ final IndexMetadata oldIndex = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test-000002");
assertThat(oldIndex.getRolloverInfos().size(), equalTo(0));
}
}
@@ -513,7 +517,7 @@ public void testRolloverMaxPrimaryShardSize() throws Exception {
assertThat(response.getOldIndex(), equalTo("test-1"));
assertThat(response.getNewIndex(), equalTo("test-000002"));
assertThat("No rollover with a large max_primary_shard_size condition", response.isRolledOver(), equalTo(false));
- final IndexMetadata oldIndex = clusterAdmin().prepareState().get().getState().metadata().index("test-1");
+ final IndexMetadata oldIndex = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test-1");
assertThat(oldIndex.getRolloverInfos().size(), equalTo(0));
}
@@ -527,7 +531,7 @@ public void testRolloverMaxPrimaryShardSize() throws Exception {
assertThat(response.getOldIndex(), equalTo("test-1"));
assertThat(response.getNewIndex(), equalTo("test-000002"));
assertThat("Should rollover with a small max_primary_shard_size condition", response.isRolledOver(), equalTo(true));
- final IndexMetadata oldIndex = clusterAdmin().prepareState().get().getState().metadata().index("test-1");
+ final IndexMetadata oldIndex = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test-1");
List> metConditions = oldIndex.getRolloverInfos().get("test_alias").getMetConditions();
assertThat(metConditions.size(), equalTo(1));
assertThat(metConditions.get(0).toString(), equalTo(new MaxPrimaryShardSizeCondition(maxPrimaryShardSizeCondition).toString()));
@@ -549,7 +553,11 @@ public void testRolloverMaxPrimaryShardSize() throws Exception {
assertThat(response.getOldIndex(), equalTo("test-000002"));
assertThat(response.getNewIndex(), equalTo("test-000003"));
assertThat("No rollover with an empty index", response.isRolledOver(), equalTo(false));
- final IndexMetadata oldIndex = clusterAdmin().prepareState().get().getState().metadata().index("test-000002");
+ final IndexMetadata oldIndex = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test-000002");
assertThat(oldIndex.getRolloverInfos().size(), equalTo(0));
}
}
@@ -573,7 +581,7 @@ public void testRolloverMaxPrimaryShardDocs() throws Exception {
assertThat(response.getOldIndex(), equalTo("test-1"));
assertThat(response.getNewIndex(), equalTo("test-000002"));
assertThat("No rollover with a large max_primary_shard_docs condition", response.isRolledOver(), equalTo(false));
- final IndexMetadata oldIndex = clusterAdmin().prepareState().get().getState().metadata().index("test-1");
+ final IndexMetadata oldIndex = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test-1");
assertThat(oldIndex.getRolloverInfos().size(), equalTo(0));
}
@@ -587,7 +595,7 @@ public void testRolloverMaxPrimaryShardDocs() throws Exception {
assertThat(response.getOldIndex(), equalTo("test-1"));
assertThat(response.getNewIndex(), equalTo("test-000002"));
assertThat("Should rollover with a small max_primary_shard_docs condition", response.isRolledOver(), equalTo(true));
- final IndexMetadata oldIndex = clusterAdmin().prepareState().get().getState().metadata().index("test-1");
+ final IndexMetadata oldIndex = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test-1");
List> metConditions = oldIndex.getRolloverInfos().get("test_alias").getMetConditions();
assertThat(metConditions.size(), equalTo(1));
assertThat(
@@ -610,7 +618,11 @@ public void testRolloverMaxPrimaryShardDocs() throws Exception {
assertThat(response.getOldIndex(), equalTo("test-000002"));
assertThat(response.getNewIndex(), equalTo("test-000003"));
assertThat("No rollover with an empty index", response.isRolledOver(), equalTo(false));
- final IndexMetadata oldIndex = clusterAdmin().prepareState().get().getState().metadata().index("test-000002");
+ final IndexMetadata oldIndex = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test-000002");
assertThat(oldIndex.getRolloverInfos().size(), equalTo(0));
}
}
@@ -698,7 +710,7 @@ public void testRolloverWithHiddenAliasesAndExplicitWriteIndex() {
assertThat(response.isDryRun(), equalTo(false));
assertThat(response.isRolledOver(), equalTo(true));
assertThat(response.getConditionStatus().size(), equalTo(0));
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexMetadata oldIndex = state.metadata().index(firstIndexName);
assertTrue(oldIndex.getAliases().containsKey(aliasName));
assertTrue(oldIndex.getAliases().get(aliasName).isHidden());
@@ -732,7 +744,7 @@ public void testRolloverWithHiddenAliasesAndImplicitWriteIndex() {
assertThat(response.isDryRun(), equalTo(false));
assertThat(response.isRolledOver(), equalTo(true));
assertThat(response.getConditionStatus().size(), equalTo(0));
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexMetadata oldIndex = state.metadata().index(firstIndexName);
assertFalse(oldIndex.getAliases().containsKey(aliasName));
final IndexMetadata newIndex = state.metadata().index(secondIndexName);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java
index 1a070c8bd0de3..e6b042c059f41 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java
@@ -88,10 +88,10 @@ public void testBasic() throws Exception {
logger.info("--> disable allocation");
disableAllocation(index);
logger.info("--> stop random node");
- int num = clusterAdmin().prepareState().get().getState().nodes().getSize();
+ int num = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getSize();
internalCluster().stopNode(internalCluster().getNodeNameThat(new IndexNodePredicate(index)));
- assertNoTimeout(clusterAdmin().prepareHealth().setWaitForNodes("" + (num - 1)));
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ assertNoTimeout(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("" + (num - 1)));
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
List unassignedShards = clusterState.routingTable().index(index).shardsWithState(ShardRoutingState.UNASSIGNED);
response = execute(new IndicesShardStoresRequest(index));
assertThat(response.getStoreStatuses().containsKey(index), equalTo(true));
@@ -227,7 +227,7 @@ public boolean test(Settings settings) {
}
private Set findNodesWithShard(String index) {
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
IndexRoutingTable indexRoutingTable = state.routingTable().index(index);
List startedShards = indexRoutingTable.shardsWithState(ShardRoutingState.STARTED);
Set nodesNamesWithShard = new HashSet<>();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java
index 85b720a03478e..d8797f3c64575 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/BulkProcessorClusterSettingsIT.java
@@ -28,7 +28,7 @@ public void testBulkProcessorAutoCreateRestrictions() {
internalCluster().startNode(settings);
createIndex("willwork");
- clusterAdmin().prepareHealth("willwork").setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "willwork").setWaitForGreenStatus().get();
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
bulkRequestBuilder.add(prepareIndex("willwork").setId("1").setSource("{\"foo\":1}", XContentType.JSON));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/TransportSimulateBulkActionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/TransportSimulateBulkActionIT.java
index 4a56a6ce8ddb6..573d929ee30a9 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/TransportSimulateBulkActionIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/bulk/TransportSimulateBulkActionIT.java
@@ -80,7 +80,7 @@ public void testMappingValidationIndexExists() {
SearchResponse searchResponse = client().search(new SearchRequest(indexName)).actionGet();
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(0L));
searchResponse.decRef();
- ClusterStateResponse clusterStateResponse = admin().cluster().state(new ClusterStateRequest()).actionGet();
+ ClusterStateResponse clusterStateResponse = admin().cluster().state(new ClusterStateRequest(TEST_REQUEST_TIMEOUT)).actionGet();
Map indexMapping = clusterStateResponse.getState().metadata().index(indexName).mapping().sourceAsMap();
Map fields = (Map) indexMapping.get("properties");
assertThat(fields.size(), equalTo(1));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/support/ActiveShardsObserverIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/support/ActiveShardsObserverIT.java
index 39273e9d1712b..023fa54fef9ec 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/support/ActiveShardsObserverIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/support/ActiveShardsObserverIT.java
@@ -134,7 +134,7 @@ public void testCreateIndexStopsWaitingWhenIndexDeleted() throws Exception {
.execute();
logger.info("--> wait until the cluster state contains the new index");
- assertBusy(() -> assertTrue(clusterAdmin().prepareState().get().getState().metadata().hasIndex(indexName)));
+ assertBusy(() -> assertTrue(clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().hasIndex(indexName)));
logger.info("--> delete the index");
assertAcked(indicesAdmin().prepareDelete(indexName));
@@ -148,7 +148,7 @@ public void testCreateIndexStopsWaitingWhenIndexDeleted() throws Exception {
// only after the test cleanup does the index creation manifest in the cluster state. To take care of this problem
// and its potential ramifications, we wait here for the index creation cluster state update task to finish
private void waitForIndexCreationToComplete(final String indexName) {
- clusterAdmin().prepareHealth(indexName).setWaitForEvents(Priority.URGENT).get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, indexName).setWaitForEvents(Priority.URGENT).get();
}
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/support/WaitActiveShardCountIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/support/WaitActiveShardCountIT.java
index 6737d02434c0f..bb970f69ead18 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/support/WaitActiveShardCountIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/support/WaitActiveShardCountIT.java
@@ -53,7 +53,7 @@ public void testReplicationWaitsForActiveShardCount() throws Exception {
allowNodes("test", 2);
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForActiveShards(2)
.setWaitForYellowStatus()
@@ -90,7 +90,7 @@ public void testReplicationWaitsForActiveShardCount() throws Exception {
}
allowNodes("test", 3);
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForActiveShards(3)
.setWaitForGreenStatus()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/support/master/TransportMasterNodeActionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/support/master/TransportMasterNodeActionIT.java
index e568b51e43b2e..321c1c84d5cb1 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/action/support/master/TransportMasterNodeActionIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/action/support/master/TransportMasterNodeActionIT.java
@@ -79,7 +79,13 @@ public void testRoutingLoopProtection() {
try {
final var newMaster = ensureSufficientMasterEligibleNodes();
- final long originalTerm = internalCluster().masterClient().admin().cluster().prepareState().get().getState().term();
+ final long originalTerm = internalCluster().masterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .term();
final var previousMasterKnowsNewMasterIsElectedLatch = configureElectionLatch(newMaster, cleanupTasks);
final var newMasterReceivedReroutedMessageFuture = new PlainActionFuture<>();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java
index 2f10711db7371..91903fd700034 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java
@@ -202,7 +202,7 @@ public void testFilteringAliases() throws Exception {
// For now just making sure that filter was stored with the alias
logger.info("--> making sure that filter was stored with alias [alias1] and filter [user:kimchy]");
- ClusterState clusterState = admin().cluster().prepareState().get().getState();
+ ClusterState clusterState = admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
IndexMetadata indexMd = clusterState.metadata().index("test");
assertThat(indexMd.getAliases().get("alias1").filter().string(), equalTo("""
{"term":{"user":{"value":"kimchy"}}}"""));
@@ -1416,21 +1416,33 @@ private void assertAliasesVersionIncreases(final String index, final Runnable ru
private void assertAliasesVersionIncreases(final String[] indices, final Runnable runnable) {
final var beforeAliasesVersions = new HashMap(indices.length);
- final var beforeMetadata = admin().cluster().prepareState().get().getState().metadata();
+ final var beforeMetadata = admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata();
for (final var index : indices) {
beforeAliasesVersions.put(index, beforeMetadata.index(index).getAliasesVersion());
}
runnable.run();
- final var afterMetadata = admin().cluster().prepareState().get().getState().metadata();
+ final var afterMetadata = admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata();
for (final String index : indices) {
assertThat(afterMetadata.index(index).getAliasesVersion(), equalTo(1 + beforeAliasesVersions.get(index)));
}
}
private void assertAliasesVersionUnchanged(final String index, final Runnable runnable) {
- final long beforeAliasesVersion = admin().cluster().prepareState().get().getState().metadata().index(index).getAliasesVersion();
+ final long beforeAliasesVersion = admin().cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index(index)
+ .getAliasesVersion();
runnable.run();
- final long afterAliasesVersion = admin().cluster().prepareState().get().getState().metadata().index(index).getAliasesVersion();
+ final long afterAliasesVersion = admin().cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index(index)
+ .getAliasesVersion();
assertThat(afterAliasesVersion, equalTo(beforeAliasesVersion));
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/blocks/SimpleBlocksIT.java b/server/src/internalClusterTest/java/org/elasticsearch/blocks/SimpleBlocksIT.java
index c5c3e441363da..5173577827154 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/blocks/SimpleBlocksIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/blocks/SimpleBlocksIT.java
@@ -298,7 +298,7 @@ public void testAddBlockToUnassignedIndex() throws Exception {
.setSettings(Settings.builder().put("index.routing.allocation.include._name", "nothing").build())
);
- final ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ final ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(clusterState.metadata().indices().get(indexName).getState(), is(IndexMetadata.State.OPEN));
assertThat(clusterState.routingTable().allShards().allMatch(ShardRouting::unassigned), is(true));
@@ -393,7 +393,7 @@ public void testAddBlockWhileDeletingIndices() throws Exception {
}
indices[i] = indexName;
}
- assertThat(clusterAdmin().prepareState().get().getState().metadata().indices().size(), equalTo(indices.length));
+ assertThat(clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().indices().size(), equalTo(indices.length));
final List threads = new ArrayList<>();
final CountDownLatch latch = new CountDownLatch(1);
@@ -434,7 +434,7 @@ public void testAddBlockWhileDeletingIndices() throws Exception {
}
static void assertIndexHasBlock(APIBlock block, final String... indices) {
- final ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ final ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
for (String index : indices) {
final IndexMetadata indexMetadata = clusterState.metadata().indices().get(index);
final Settings indexSettings = indexMetadata.getSettings();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterHealthIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterHealthIT.java
index 65c0aa6548182..a190ac61bbe18 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterHealthIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterHealthIT.java
@@ -43,7 +43,7 @@ public void testSimpleLocalHealth() {
logger.info("--> getting cluster health on [{}]", node);
final ClusterHealthResponse health = client(node).admin()
.cluster()
- .prepareHealth()
+ .prepareHealth(TEST_REQUEST_TIMEOUT)
.setLocal(true)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueSeconds(30))
@@ -56,7 +56,7 @@ public void testSimpleLocalHealth() {
public void testHealth() {
logger.info("--> running cluster health on an index that does not exists");
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth("test1")
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test1")
.setWaitForYellowStatus()
.setTimeout(TimeValue.timeValueSeconds(1))
.get();
@@ -65,7 +65,10 @@ public void testHealth() {
assertThat(healthResponse.getIndices().isEmpty(), equalTo(true));
logger.info("--> running cluster wide health");
- healthResponse = clusterAdmin().prepareHealth().setWaitForGreenStatus().setTimeout(TimeValue.timeValueSeconds(10)).get();
+ healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForGreenStatus()
+ .setTimeout(TimeValue.timeValueSeconds(10))
+ .get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
assertThat(healthResponse.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(healthResponse.getIndices().isEmpty(), equalTo(true));
@@ -74,13 +77,16 @@ public void testHealth() {
createIndex("test1");
logger.info("--> running cluster health on an index that does exists");
- healthResponse = clusterAdmin().prepareHealth("test1").setWaitForGreenStatus().setTimeout(TimeValue.timeValueSeconds(10)).get();
+ healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test1")
+ .setWaitForGreenStatus()
+ .setTimeout(TimeValue.timeValueSeconds(10))
+ .get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
assertThat(healthResponse.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(healthResponse.getIndices().get("test1").getStatus(), equalTo(ClusterHealthStatus.GREEN));
logger.info("--> running cluster health on an index that does exists and an index that doesn't exists");
- healthResponse = clusterAdmin().prepareHealth("test1", "test2")
+ healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test1", "test2")
.setWaitForYellowStatus()
.setTimeout(TimeValue.timeValueSeconds(1))
.get();
@@ -93,7 +99,7 @@ public void testHealth() {
public void testHealthWithClosedIndices() {
createIndex("index-1");
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(response.isTimedOut(), equalTo(false));
assertThat(response.getIndices().get("index-1").getStatus(), equalTo(ClusterHealthStatus.GREEN));
@@ -103,7 +109,7 @@ public void testHealthWithClosedIndices() {
assertAcked(indicesAdmin().prepareClose("index-2"));
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(response.isTimedOut(), equalTo(false));
assertThat(response.getIndices().size(), equalTo(2));
@@ -111,21 +117,21 @@ public void testHealthWithClosedIndices() {
assertThat(response.getIndices().get("index-2").getStatus(), equalTo(ClusterHealthStatus.GREEN));
}
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth("index-1").get();
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index-1").get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(response.isTimedOut(), equalTo(false));
assertThat(response.getIndices().size(), equalTo(1));
assertThat(response.getIndices().get("index-1").getStatus(), equalTo(ClusterHealthStatus.GREEN));
}
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth("index-2").get();
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index-2").get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(response.isTimedOut(), equalTo(false));
assertThat(response.getIndices().size(), equalTo(1));
assertThat(response.getIndices().get("index-2").getStatus(), equalTo(ClusterHealthStatus.GREEN));
}
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth("index-*").get();
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index-*").get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(response.isTimedOut(), equalTo(false));
assertThat(response.getIndices().size(), equalTo(2));
@@ -133,7 +139,7 @@ public void testHealthWithClosedIndices() {
assertThat(response.getIndices().get("index-2").getStatus(), equalTo(ClusterHealthStatus.GREEN));
}
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth("index-*")
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index-*")
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
.get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.GREEN));
@@ -143,7 +149,7 @@ public void testHealthWithClosedIndices() {
assertThat(response.getIndices().get("index-2"), nullValue());
}
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth("index-*")
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index-*")
.setIndicesOptions(IndicesOptions.fromOptions(true, true, false, true))
.get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.GREEN));
@@ -157,7 +163,7 @@ public void testHealthWithClosedIndices() {
assertAcked(indicesAdmin().prepareClose("index-3"));
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth()
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForNoRelocatingShards(true)
.setWaitForNoInitializingShards(true)
.setWaitForYellowStatus()
@@ -170,28 +176,28 @@ public void testHealthWithClosedIndices() {
assertThat(response.getIndices().get("index-3").getStatus(), equalTo(ClusterHealthStatus.YELLOW));
}
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth("index-1").get();
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index-1").get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(response.isTimedOut(), equalTo(false));
assertThat(response.getIndices().size(), equalTo(1));
assertThat(response.getIndices().get("index-1").getStatus(), equalTo(ClusterHealthStatus.GREEN));
}
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth("index-2").get();
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index-2").get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(response.isTimedOut(), equalTo(false));
assertThat(response.getIndices().size(), equalTo(1));
assertThat(response.getIndices().get("index-2").getStatus(), equalTo(ClusterHealthStatus.GREEN));
}
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth("index-3").get();
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index-3").get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.YELLOW));
assertThat(response.isTimedOut(), equalTo(false));
assertThat(response.getIndices().size(), equalTo(1));
assertThat(response.getIndices().get("index-3").getStatus(), equalTo(ClusterHealthStatus.YELLOW));
}
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth("index-*").get();
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index-*").get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.YELLOW));
assertThat(response.isTimedOut(), equalTo(false));
assertThat(response.getIndices().size(), equalTo(3));
@@ -200,7 +206,7 @@ public void testHealthWithClosedIndices() {
assertThat(response.getIndices().get("index-3").getStatus(), equalTo(ClusterHealthStatus.YELLOW));
}
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth("index-*")
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index-*")
.setIndicesOptions(IndicesOptions.lenientExpandOpen())
.get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.GREEN));
@@ -211,7 +217,7 @@ public void testHealthWithClosedIndices() {
assertThat(response.getIndices().get("index-3"), nullValue());
}
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth("index-*")
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index-*")
.setIndicesOptions(IndicesOptions.fromOptions(true, true, false, true))
.get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.YELLOW));
@@ -224,7 +230,7 @@ public void testHealthWithClosedIndices() {
setReplicaCount(numberOfReplicas(), "index-3");
{
- ClusterHealthResponse response = clusterAdmin().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse response = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(response.isTimedOut(), equalTo(false));
assertThat(response.getIndices().size(), equalTo(3));
@@ -240,7 +246,7 @@ public void testHealthOnIndexCreation() throws Exception {
@Override
public void run() {
while (finished.get() == false) {
- ClusterHealthResponse health = clusterAdmin().prepareHealth().get();
+ ClusterHealthResponse health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).get();
assertThat(health.getStatus(), not(equalTo(ClusterHealthStatus.RED)));
}
}
@@ -254,7 +260,7 @@ public void run() {
}
public void testWaitForEventsRetriesIfOtherConditionsNotMet() {
- final ActionFuture healthResponseFuture = clusterAdmin().prepareHealth("index")
+ final ActionFuture healthResponseFuture = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index")
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.execute();
@@ -286,7 +292,7 @@ public void clusterStateProcessed(ClusterState oldState, ClusterState newState)
try {
createIndex("index");
- assertFalse(clusterAdmin().prepareHealth("index").setWaitForGreenStatus().get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index").setWaitForGreenStatus().get().isTimedOut());
// at this point the original health response should not have returned: there was never a point where the index was green AND
// the master had processed all pending tasks above LANGUID priority.
@@ -326,7 +332,7 @@ public void testHealthOnMasterFailover() throws Exception {
responseFutures.add(
client(node).admin()
.cluster()
- .prepareHealth()
+ .prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setMasterNodeTimeout(TimeValue.timeValueMinutes(timeoutMinutes))
@@ -369,7 +375,7 @@ public void clusterStateProcessed(ClusterState oldState, ClusterState newState)
});
try {
- final ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth()
+ final ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueSeconds(1))
.get(TimeValue.timeValueSeconds(30));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterInfoServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterInfoServiceIT.java
index cc930cdad5950..f0801d01a70d9 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterInfoServiceIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterInfoServiceIT.java
@@ -206,7 +206,7 @@ public void testClusterInfoServiceInformationClearOnError() {
prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)).get();
ensureGreen("test");
- final IndexShardRoutingTable indexShardRoutingTable = clusterAdmin().prepareState()
+ final IndexShardRoutingTable indexShardRoutingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setRoutingTable(true)
.get()
@@ -320,7 +320,12 @@ public void testClusterInfoServiceInformationClearOnError() {
assertThat("size for shard " + shardRouting + " found", originalInfo.getShardSize(shardRouting), notNullValue());
}
- RoutingTable routingTable = clusterAdmin().prepareState().clear().setRoutingTable(true).get().getState().routingTable();
+ RoutingTable routingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .clear()
+ .setRoutingTable(true)
+ .get()
+ .getState()
+ .routingTable();
for (ShardRouting shard : routingTable.allShardsIterator()) {
assertTrue(
infoAfterRecovery.getReservedSpace(shard.currentNodeId(), infoAfterRecovery.getDataPath(shard))
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/DesiredNodesSnapshotsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/DesiredNodesSnapshotsIT.java
index aaf663c8c5b24..382d7aa8eb647 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/DesiredNodesSnapshotsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/DesiredNodesSnapshotsIT.java
@@ -55,11 +55,15 @@ private UpdateDesiredNodesResponse updateDesiredNodes(UpdateDesiredNodesRequest
}
private DesiredNodes getLatestDesiredNodes() {
- return client().execute(GetDesiredNodesAction.INSTANCE, new GetDesiredNodesAction.Request()).actionGet().getDesiredNodes();
+ return client().execute(GetDesiredNodesAction.INSTANCE, new GetDesiredNodesAction.Request(TEST_REQUEST_TIMEOUT))
+ .actionGet()
+ .getDesiredNodes();
}
private UpdateDesiredNodesRequest randomUpdateDesiredNodesRequest() {
return new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
randomAlphaOfLength(10),
randomIntBetween(1, 10),
randomList(
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/DesiredNodesStatusIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/DesiredNodesStatusIT.java
index 77fcdb446baa7..08dbd800ede5e 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/DesiredNodesStatusIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/DesiredNodesStatusIT.java
@@ -35,6 +35,8 @@ public void testDesiredNodesStatusIsTracked() {
final var pendingDesiredNodes = randomList(0, 5, DesiredNodesTestCase::randomDesiredNode);
final var updateDesiredNodesRequest = new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
randomAlphaOfLength(10),
1,
concatLists(actualizedDesiredNodes, pendingDesiredNodes),
@@ -43,11 +45,13 @@ public void testDesiredNodesStatusIsTracked() {
updateDesiredNodes(updateDesiredNodesRequest);
{
- final var clusterState = clusterAdmin().prepareState().get().getState();
+ final var clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertDesiredNodesStatusIsCorrect(clusterState, actualizedDesiredNodes, pendingDesiredNodes);
}
final var newVersionUpdateDesiredNodesRequest = new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
updateDesiredNodesRequest.getHistoryID(),
updateDesiredNodesRequest.getVersion() + 1,
updateDesiredNodesRequest.getNodes(),
@@ -56,7 +60,7 @@ public void testDesiredNodesStatusIsTracked() {
updateDesiredNodes(newVersionUpdateDesiredNodesRequest);
{
- final var clusterState = clusterAdmin().prepareState().get().getState();
+ final var clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertDesiredNodesStatusIsCorrect(clusterState, actualizedDesiredNodes, pendingDesiredNodes);
}
}
@@ -70,6 +74,8 @@ public void testIdempotentUpdateWithUpdatedStatus() {
final var pendingDesiredNodes = randomList(0, 5, DesiredNodesTestCase::randomDesiredNode);
final var updateDesiredNodesRequest = new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
randomAlphaOfLength(10),
1,
concatLists(actualizedDesiredNodes, pendingDesiredNodes),
@@ -78,14 +84,14 @@ public void testIdempotentUpdateWithUpdatedStatus() {
updateDesiredNodes(updateDesiredNodesRequest);
{
- final var clusterState = clusterAdmin().prepareState().get().getState();
+ final var clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
DesiredNodesTestCase.assertDesiredNodesStatusIsCorrect(clusterState, actualizedDesiredNodes, pendingDesiredNodes);
}
updateDesiredNodes(updateDesiredNodesRequest);
{
- final var clusterState = clusterAdmin().prepareState().get().getState();
+ final var clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
DesiredNodesTestCase.assertDesiredNodesStatusIsCorrect(clusterState, actualizedDesiredNodes, pendingDesiredNodes);
}
}
@@ -99,6 +105,8 @@ public void testActualizedDesiredNodesAreKeptAsActualizedEvenIfNodesLeavesTempor
final var pendingDesiredNodes = randomList(0, 5, DesiredNodesTestCase::randomDesiredNode);
final var updateDesiredNodesRequest = new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
randomAlphaOfLength(10),
1,
concatLists(actualizedDesiredNodes, pendingDesiredNodes),
@@ -106,7 +114,7 @@ public void testActualizedDesiredNodesAreKeptAsActualizedEvenIfNodesLeavesTempor
);
updateDesiredNodes(updateDesiredNodesRequest);
- final var clusterState = clusterAdmin().prepareState().get().getState();
+ final var clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
DesiredNodesTestCase.assertDesiredNodesStatusIsCorrect(clusterState, actualizedDesiredNodes, pendingDesiredNodes);
final var leavingNodeNames = randomSubsetOf(nodeNames);
@@ -114,7 +122,7 @@ public void testActualizedDesiredNodesAreKeptAsActualizedEvenIfNodesLeavesTempor
internalCluster().stopNode(leavingNodeName);
}
- final var newClusterState = clusterAdmin().prepareState().get().getState();
+ final var newClusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final var latestDesiredNodes = DesiredNodes.latestFromClusterState(newClusterState);
for (String leavingNodeName : leavingNodeNames) {
@@ -132,6 +140,8 @@ public void testStatusInformationIsClearedAfterHistoryIdChanges() throws Excepti
final var pendingDesiredNodes = randomList(0, 5, DesiredNodesTestCase::randomDesiredNode);
final var updateDesiredNodesRequest = new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
randomAlphaOfLength(10),
1,
concatLists(actualizedDesiredNodes, pendingDesiredNodes),
@@ -139,7 +149,7 @@ public void testStatusInformationIsClearedAfterHistoryIdChanges() throws Excepti
);
updateDesiredNodes(updateDesiredNodesRequest);
- final var clusterState = clusterAdmin().prepareState().get().getState();
+ final var clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
DesiredNodesTestCase.assertDesiredNodesStatusIsCorrect(clusterState, actualizedDesiredNodes, pendingDesiredNodes);
// Stop some nodes, these shouldn't be actualized within the new desired node's history until they join back
@@ -149,6 +159,8 @@ public void testStatusInformationIsClearedAfterHistoryIdChanges() throws Excepti
}
final var updateDesiredNodesWithNewHistoryRequest = new UpdateDesiredNodesRequest(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT,
randomAlphaOfLength(10),
1,
updateDesiredNodesRequest.getNodes(),
@@ -157,7 +169,7 @@ public void testStatusInformationIsClearedAfterHistoryIdChanges() throws Excepti
final var response = updateDesiredNodes(updateDesiredNodesWithNewHistoryRequest);
assertThat(response.hasReplacedExistingHistoryId(), is(equalTo(true)));
- final var updatedClusterState = clusterAdmin().prepareState().get().getState();
+ final var updatedClusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final var latestDesiredNodes = DesiredNodes.latestFromClusterState(updatedClusterState);
for (String clusterNodeName : clusterNodeNames) {
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java
index d3cbab2760747..a3c7f8b77a444 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java
@@ -67,25 +67,25 @@ public void testTwoNodesNoMasterBlock() throws Exception {
String node1Name = internalCluster().startNode(settings);
logger.info("--> should be blocked, no master...");
- ClusterState state = clusterAdmin().prepareState().setLocal(true).get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertThat(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID), equalTo(true));
assertThat(state.nodes().getSize(), equalTo(1)); // verify that we still see the local node in the cluster state
logger.info("--> start second node, cluster should be formed");
String node2Name = internalCluster().startNode(settings);
- ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes("2")
.get();
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
- state = clusterAdmin().prepareState().setLocal(true).get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertThat(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID), equalTo(false));
- state = clusterAdmin().prepareState().setLocal(true).get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertThat(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID), equalTo(false));
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.nodes().getSize(), equalTo(2));
assertThat(state.metadata().indices().containsKey("test"), equalTo(false));
@@ -97,7 +97,10 @@ public void testTwoNodesNoMasterBlock() throws Exception {
}
// make sure that all shards recovered before trying to flush
assertThat(
- clusterAdmin().prepareHealth("test").setWaitForActiveShards(numShards.totalNumShards).get().getActiveShards(),
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test")
+ .setWaitForActiveShards(numShards.totalNumShards)
+ .get()
+ .getActiveShards(),
equalTo(numShards.totalNumShards)
);
// flush for simpler debugging
@@ -111,17 +114,20 @@ public void testTwoNodesNoMasterBlock() throws Exception {
String masterNode = internalCluster().getMasterName();
String otherNode = node1Name.equals(masterNode) ? node2Name : node1Name;
logger.info("--> add voting config exclusion for non-master node, to be sure it's not elected");
- client().execute(TransportAddVotingConfigExclusionsAction.TYPE, new AddVotingConfigExclusionsRequest(otherNode)).get();
+ client().execute(
+ TransportAddVotingConfigExclusionsAction.TYPE,
+ new AddVotingConfigExclusionsRequest(TEST_REQUEST_TIMEOUT, otherNode)
+ ).get();
logger.info("--> stop master node, no master block should appear");
Settings masterDataPathSettings = internalCluster().dataPathSettings(masterNode);
internalCluster().stopNode(masterNode);
assertBusy(() -> {
- ClusterState clusterState = clusterAdmin().prepareState().setLocal(true).get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertTrue(clusterState.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID));
});
- state = clusterAdmin().prepareState().setLocal(true).get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertThat(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID), equalTo(true));
// verify that both nodes are still in the cluster state but there is no master
assertThat(state.nodes().getSize(), equalTo(2));
@@ -130,19 +136,19 @@ public void testTwoNodesNoMasterBlock() throws Exception {
logger.info("--> starting the previous master node again...");
node2Name = internalCluster().startNode(Settings.builder().put(settings).put(masterDataPathSettings).build());
- clusterHealthResponse = clusterAdmin().prepareHealth()
+ clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForYellowStatus()
.setWaitForNodes("2")
.get();
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
- state = clusterAdmin().prepareState().setLocal(true).get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertThat(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID), equalTo(false));
- state = clusterAdmin().prepareState().setLocal(true).get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertThat(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID), equalTo(false));
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.nodes().getSize(), equalTo(2));
assertThat(state.metadata().indices().containsKey("test"), equalTo(true));
@@ -154,20 +160,23 @@ public void testTwoNodesNoMasterBlock() throws Exception {
}
logger.info("--> clearing voting config exclusions");
- ClearVotingConfigExclusionsRequest clearRequest = new ClearVotingConfigExclusionsRequest();
+ ClearVotingConfigExclusionsRequest clearRequest = new ClearVotingConfigExclusionsRequest(TEST_REQUEST_TIMEOUT);
clearRequest.setWaitForRemoval(false);
client().execute(TransportClearVotingConfigExclusionsAction.TYPE, clearRequest).get();
masterNode = internalCluster().getMasterName();
otherNode = node1Name.equals(masterNode) ? node2Name : node1Name;
logger.info("--> add voting config exclusion for master node, to be sure it's not elected");
- client().execute(TransportAddVotingConfigExclusionsAction.TYPE, new AddVotingConfigExclusionsRequest(masterNode)).get();
+ client().execute(
+ TransportAddVotingConfigExclusionsAction.TYPE,
+ new AddVotingConfigExclusionsRequest(TEST_REQUEST_TIMEOUT, masterNode)
+ ).get();
logger.info("--> stop non-master node, no master block should appear");
Settings otherNodeDataPathSettings = internalCluster().dataPathSettings(otherNode);
internalCluster().stopNode(otherNode);
assertBusy(() -> {
- ClusterState state1 = clusterAdmin().prepareState().setLocal(true).get().getState();
+ ClusterState state1 = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertThat(state1.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID), equalTo(true));
});
@@ -175,19 +184,19 @@ public void testTwoNodesNoMasterBlock() throws Exception {
internalCluster().startNode(Settings.builder().put(settings).put(otherNodeDataPathSettings).build());
ensureGreen();
- clusterHealthResponse = clusterAdmin().prepareHealth()
+ clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes("2")
.setWaitForGreenStatus()
.get();
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
- state = clusterAdmin().prepareState().setLocal(true).get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertThat(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID), equalTo(false));
- state = clusterAdmin().prepareState().setLocal(true).get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertThat(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID), equalTo(false));
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.nodes().getSize(), equalTo(2));
assertThat(state.metadata().indices().containsKey("test"), equalTo(true));
@@ -212,7 +221,7 @@ public void testThreeNodesNoMasterBlock() throws Exception {
assertBusy(() -> {
for (Client client : clients()) {
- ClusterState state1 = client.admin().cluster().prepareState().setLocal(true).get().getState();
+ ClusterState state1 = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertThat(state1.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID), equalTo(true));
}
});
@@ -221,13 +230,13 @@ public void testThreeNodesNoMasterBlock() throws Exception {
internalCluster().startNode(settings);
ensureGreen();
- ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes("3")
.get();
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.nodes().getSize(), equalTo(3));
createIndex("test");
@@ -239,7 +248,7 @@ public void testThreeNodesNoMasterBlock() throws Exception {
ensureGreen();
// make sure that all shards recovered before trying to flush
assertThat(
- clusterAdmin().prepareHealth("test").setWaitForActiveShards(numShards.totalNumShards).get().isTimedOut(),
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test").setWaitForActiveShards(numShards.totalNumShards).get().isTimedOut(),
equalTo(false)
);
// flush for simpler debugging
@@ -262,7 +271,7 @@ public void testThreeNodesNoMasterBlock() throws Exception {
logger.info("--> verify that there is no master anymore on remaining node");
// spin here to wait till the state is set
assertBusy(() -> {
- ClusterState st = clusterAdmin().prepareState().setLocal(true).get().getState();
+ ClusterState st = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertThat(st.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID), equalTo(true));
});
@@ -272,7 +281,7 @@ public void testThreeNodesNoMasterBlock() throws Exception {
internalCluster().validateClusterFormed();
ensureGreen();
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.nodes().getSize(), equalTo(3));
logger.info("--> verify we the data back");
@@ -338,7 +347,7 @@ public void onFailure(Exception e) {
DiscoveryNode masterNode = internalCluster().client(randomFrom(otherNodes))
.admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.nodes()
@@ -350,7 +359,7 @@ public void onFailure(Exception e) {
partition.stopDisrupting();
logger.debug("--> waiting for cluster to heal");
- assertNoTimeout(clusterAdmin().prepareHealth().setWaitForNodes("3").setWaitForEvents(Priority.LANGUID));
+ assertNoTimeout(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("3").setWaitForEvents(Priority.LANGUID));
for (String node : internalCluster().getNodeNames()) {
Settings nodeSetting = internalCluster().clusterService(node).state().metadata().settings();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/NoMasterNodeIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/NoMasterNodeIT.java
index d8c91d770437f..6b104291693e1 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/NoMasterNodeIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/NoMasterNodeIT.java
@@ -72,7 +72,7 @@ public void testNoMasterActions() throws Exception {
final List nodes = internalCluster().startNodes(3, settings);
createIndex("test");
- clusterAdmin().prepareHealth("test").setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test").setWaitForGreenStatus().get();
final NetworkDisruption disruptionScheme = new NetworkDisruption(
new IsolateAllNodes(new HashSet<>(nodes)),
@@ -84,7 +84,12 @@ public void testNoMasterActions() throws Exception {
final Client clientToMasterlessNode = client();
assertBusy(() -> {
- ClusterState state = clientToMasterlessNode.admin().cluster().prepareState().setLocal(true).get().getState();
+ ClusterState state = clientToMasterlessNode.admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .setLocal(true)
+ .get()
+ .getState();
assertTrue(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID));
});
@@ -223,14 +228,14 @@ public void testNoMasterActionsWriteMasterBlock() throws Exception {
prepareCreate("test1").setSettings(indexSettings(1, 2)).get();
prepareCreate("test2").setSettings(indexSettings(3, 0)).get();
- clusterAdmin().prepareHealth("_all").setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "_all").setWaitForGreenStatus().get();
prepareIndex("test1").setId("1").setSource("field", "value1").get();
prepareIndex("test2").setId("1").setSource("field", "value1").get();
refresh();
ensureSearchable("test1", "test2");
- ClusterStateResponse clusterState = clusterAdmin().prepareState().get();
+ ClusterStateResponse clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
logger.info("Cluster state:\n{}", clusterState.getState());
final NetworkDisruption disruptionScheme = new NetworkDisruption(
@@ -243,7 +248,12 @@ public void testNoMasterActionsWriteMasterBlock() throws Exception {
final Client clientToMasterlessNode = client();
assertBusy(() -> {
- ClusterState state = clientToMasterlessNode.admin().cluster().prepareState().setLocal(true).get().getState();
+ ClusterState state = clientToMasterlessNode.admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .setLocal(true)
+ .get()
+ .getState();
assertTrue(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID));
});
@@ -299,13 +309,13 @@ public void testNoMasterActionsMetadataWriteMasterBlock() throws Exception {
final List nodes = internalCluster().startNodes(3, settings);
prepareCreate("test1").setSettings(indexSettings(1, 1)).get();
- clusterAdmin().prepareHealth("_all").setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "_all").setWaitForGreenStatus().get();
prepareIndex("test1").setId("1").setSource("field", "value1").get();
refresh();
ensureGreen("test1");
- ClusterStateResponse clusterState = clusterAdmin().prepareState().get();
+ ClusterStateResponse clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
logger.info("Cluster state:\n{}", clusterState.getState());
final List nodesWithShards = clusterState.getState()
@@ -321,7 +331,7 @@ public void testNoMasterActionsMetadataWriteMasterBlock() throws Exception {
client().execute(
TransportAddVotingConfigExclusionsAction.TYPE,
- new AddVotingConfigExclusionsRequest(nodesWithShards.toArray(new String[0]))
+ new AddVotingConfigExclusionsRequest(TEST_REQUEST_TIMEOUT, nodesWithShards.toArray(new String[0]))
).get();
ensureGreen("test1");
@@ -336,7 +346,7 @@ public void testNoMasterActionsMetadataWriteMasterBlock() throws Exception {
assertBusy(() -> {
for (String node : nodesWithShards) {
- ClusterState state = client(node).admin().cluster().prepareState().setLocal(true).get().getState();
+ ClusterState state = client(node).admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertTrue(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID));
}
});
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/PrevalidateNodeRemovalIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/PrevalidateNodeRemovalIT.java
index 3135647adc9ab..6b5bb08f0f247 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/PrevalidateNodeRemovalIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/PrevalidateNodeRemovalIT.java
@@ -62,7 +62,8 @@ public void testNodeRemovalFromNonRedCluster() throws Exception {
case 2 -> req.setExternalIds(internalCluster().clusterService(nodeName).localNode().getExternalId());
default -> throw new IllegalStateException("Unexpected value");
}
- PrevalidateNodeRemovalResponse resp = client().execute(PrevalidateNodeRemovalAction.INSTANCE, req.build()).get();
+ PrevalidateNodeRemovalResponse resp = client().execute(PrevalidateNodeRemovalAction.INSTANCE, req.build(TEST_REQUEST_TIMEOUT))
+ .get();
assertTrue(resp.getPrevalidation().isSafe());
assertThat(resp.getPrevalidation().message(), equalTo("cluster status is not RED"));
assertThat(resp.getPrevalidation().nodes().size(), equalTo(1));
@@ -75,7 +76,7 @@ public void testNodeRemovalFromNonRedCluster() throws Exception {
// Enforce a replica to get unassigned
updateIndexSettings(Settings.builder().put("index.routing.allocation.require._name", node1), indexName);
ensureYellow();
- PrevalidateNodeRemovalRequest req2 = PrevalidateNodeRemovalRequest.builder().setNames(node2).build();
+ PrevalidateNodeRemovalRequest req2 = PrevalidateNodeRemovalRequest.builder().setNames(node2).build(TEST_REQUEST_TIMEOUT);
PrevalidateNodeRemovalResponse resp2 = client().execute(PrevalidateNodeRemovalAction.INSTANCE, req2).get();
assertTrue(resp2.getPrevalidation().isSafe());
assertThat(resp2.getPrevalidation().message(), equalTo("cluster status is not RED"));
@@ -107,7 +108,7 @@ public void testNodeRemovalFromRedClusterWithNoLocalShardCopy() throws Exception
internalCluster().stopNode(nodeWithIndex);
ensureRed(indexName);
String[] otherNodeNames = otherNodes.toArray(new String[otherNodes.size()]);
- PrevalidateNodeRemovalRequest req = PrevalidateNodeRemovalRequest.builder().setNames(otherNodeNames).build();
+ PrevalidateNodeRemovalRequest req = PrevalidateNodeRemovalRequest.builder().setNames(otherNodeNames).build(TEST_REQUEST_TIMEOUT);
PrevalidateNodeRemovalResponse resp = client().execute(PrevalidateNodeRemovalAction.INSTANCE, req).get();
assertTrue(resp.getPrevalidation().isSafe());
assertThat(resp.getPrevalidation().message(), equalTo(""));
@@ -154,7 +155,7 @@ public void testNodeRemovalFromRedClusterWithLocalShardCopy() throws Exception {
ShardPath shardPath = ShardPath.loadShardPath(logger, nodeEnv, new ShardId(index, 0), "");
assertNotNull("local index shards not found", shardPath);
// Prevalidate removal of node1
- PrevalidateNodeRemovalRequest req = PrevalidateNodeRemovalRequest.builder().setNames(node1).build();
+ PrevalidateNodeRemovalRequest req = PrevalidateNodeRemovalRequest.builder().setNames(node1).build(TEST_REQUEST_TIMEOUT);
PrevalidateNodeRemovalResponse resp = client().execute(PrevalidateNodeRemovalAction.INSTANCE, req).get();
String node1Id = getNodeId(node1);
assertFalse(resp.getPrevalidation().isSafe());
@@ -183,7 +184,7 @@ public void testNodeRemovalFromRedClusterWithTimeout() throws Exception {
});
PrevalidateNodeRemovalRequest req = PrevalidateNodeRemovalRequest.builder()
.setNames(node2)
- .build()
+ .build(TEST_REQUEST_TIMEOUT)
.masterNodeTimeout(TimeValue.timeValueSeconds(1))
.timeout(TimeValue.timeValueSeconds(1));
PrevalidateNodeRemovalResponse resp = client().execute(PrevalidateNodeRemovalAction.INSTANCE, req).get();
@@ -203,7 +204,7 @@ public void testNodeRemovalFromRedClusterWithTimeout() throws Exception {
private void ensureRed(String indexName) throws Exception {
assertBusy(() -> {
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(indexName)
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, indexName)
.setWaitForStatus(ClusterHealthStatus.RED)
.setWaitForEvents(Priority.LANGUID)
.get();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java
index 3dba41adec08b..1259650d37791 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java
@@ -76,13 +76,16 @@ public void indexData() throws Exception {
}
public void testRoutingTable() throws Exception {
- ClusterStateResponse clusterStateResponseUnfiltered = clusterAdmin().prepareState().clear().setRoutingTable(true).get();
+ ClusterStateResponse clusterStateResponseUnfiltered = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .clear()
+ .setRoutingTable(true)
+ .get();
assertThat(clusterStateResponseUnfiltered.getState().routingTable().hasIndex("foo"), is(true));
assertThat(clusterStateResponseUnfiltered.getState().routingTable().hasIndex("fuu"), is(true));
assertThat(clusterStateResponseUnfiltered.getState().routingTable().hasIndex("baz"), is(true));
assertThat(clusterStateResponseUnfiltered.getState().routingTable().hasIndex("non-existent"), is(false));
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().clear().get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).clear().get();
assertThat(clusterStateResponse.getState().routingTable().hasIndex("foo"), is(false));
assertThat(clusterStateResponse.getState().routingTable().hasIndex("fuu"), is(false));
assertThat(clusterStateResponse.getState().routingTable().hasIndex("baz"), is(false));
@@ -90,43 +93,49 @@ public void testRoutingTable() throws Exception {
}
public void testNodes() throws Exception {
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().clear().setNodes(true).get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).clear().setNodes(true).get();
assertThat(clusterStateResponse.getState().nodes().getNodes().size(), is(cluster().size()));
- ClusterStateResponse clusterStateResponseFiltered = clusterAdmin().prepareState().clear().get();
+ ClusterStateResponse clusterStateResponseFiltered = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).clear().get();
assertThat(clusterStateResponseFiltered.getState().nodes().getNodes().size(), is(0));
}
public void testMetadata() throws Exception {
- ClusterStateResponse clusterStateResponseUnfiltered = clusterAdmin().prepareState().clear().setMetadata(true).get();
+ ClusterStateResponse clusterStateResponseUnfiltered = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .clear()
+ .setMetadata(true)
+ .get();
assertThat(clusterStateResponseUnfiltered.getState().metadata().indices().size(), is(3));
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().clear().get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).clear().get();
assertThat(clusterStateResponse.getState().metadata().indices().size(), is(0));
}
public void testMetadataVersion() {
createIndex("index-1");
createIndex("index-2");
- long baselineVersion = clusterAdmin().prepareState().get().getState().metadata().version();
+ long baselineVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().version();
assertThat(baselineVersion, greaterThan(0L));
assertThat(
- clusterAdmin().prepareState().setIndices("index-1").get().getState().metadata().version(),
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setIndices("index-1").get().getState().metadata().version(),
greaterThanOrEqualTo(baselineVersion)
);
assertThat(
- clusterAdmin().prepareState().setIndices("index-2").get().getState().metadata().version(),
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setIndices("index-2").get().getState().metadata().version(),
greaterThanOrEqualTo(baselineVersion)
);
assertThat(
- clusterAdmin().prepareState().setIndices("*").get().getState().metadata().version(),
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setIndices("*").get().getState().metadata().version(),
greaterThanOrEqualTo(baselineVersion)
);
assertThat(
- clusterAdmin().prepareState().setIndices("not-found").get().getState().metadata().version(),
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setIndices("not-found").get().getState().metadata().version(),
greaterThanOrEqualTo(baselineVersion)
);
- assertThat(clusterAdmin().prepareState().clear().setMetadata(false).get().getState().metadata().version(), equalTo(0L));
+ assertThat(
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).clear().setMetadata(false).get().getState().metadata().version(),
+ equalTo(0L)
+ );
}
public void testIndexTemplates() throws Exception {
@@ -170,7 +179,7 @@ public void testIndexTemplates() throws Exception {
)
.get();
- ClusterStateResponse clusterStateResponseUnfiltered = clusterAdmin().prepareState().get();
+ ClusterStateResponse clusterStateResponseUnfiltered = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(clusterStateResponseUnfiltered.getState().metadata().templates().size(), is(greaterThanOrEqualTo(2)));
GetIndexTemplatesResponse getIndexTemplatesResponse = indicesAdmin().prepareGetTemplates("foo_template").get();
@@ -198,7 +207,7 @@ public void testThatFilteringByIndexWorksForMetadataAndRoutingTable() throws Exc
* that the cluster state returns coherent data for both routing table and metadata.
*/
private void testFilteringByIndexWorks(String[] indices, String[] expected) {
- ClusterStateResponse clusterState = clusterAdmin().prepareState()
+ ClusterStateResponse clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setMetadata(true)
.setRoutingTable(true)
@@ -262,19 +271,23 @@ public void testLargeClusterStatePublishing() throws Exception {
}
public void testIndicesOptions() throws Exception {
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().clear().setMetadata(true).setIndices("f*").get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .clear()
+ .setMetadata(true)
+ .setIndices("f*")
+ .get();
assertThat(clusterStateResponse.getState().metadata().indices().size(), is(2));
ensureGreen("fuu");
// close one index
assertAcked(indicesAdmin().close(new CloseIndexRequest("fuu")).get());
- clusterStateResponse = clusterAdmin().prepareState().clear().setMetadata(true).setIndices("f*").get();
+ clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).clear().setMetadata(true).setIndices("f*").get();
assertThat(clusterStateResponse.getState().metadata().indices().size(), is(1));
assertThat(clusterStateResponse.getState().metadata().index("foo").getState(), equalTo(IndexMetadata.State.OPEN));
// expand_wildcards_closed should toggle return only closed index fuu
IndicesOptions expandCloseOptions = IndicesOptions.fromOptions(false, true, false, true);
- clusterStateResponse = clusterAdmin().prepareState()
+ clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setMetadata(true)
.setIndices("f*")
@@ -285,7 +298,7 @@ public void testIndicesOptions() throws Exception {
// ignore_unavailable set to true should not raise exception on fzzbzz
IndicesOptions ignoreUnavailabe = IndicesOptions.fromOptions(true, true, true, false);
- clusterStateResponse = clusterAdmin().prepareState()
+ clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setMetadata(true)
.setIndices("fzzbzz")
@@ -296,7 +309,7 @@ public void testIndicesOptions() throws Exception {
// empty wildcard expansion result should work when allowNoIndices is
// turned on
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, true, true, false);
- clusterStateResponse = clusterAdmin().prepareState()
+ clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setMetadata(true)
.setIndices("a*")
@@ -309,7 +322,12 @@ public void testIndicesOptionsOnAllowNoIndicesFalse() throws Exception {
// empty wildcard expansion throws exception when allowNoIndices is turned off
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, false, true, false);
try {
- clusterAdmin().prepareState().clear().setMetadata(true).setIndices("a*").setIndicesOptions(allowNoIndices).get();
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .clear()
+ .setMetadata(true)
+ .setIndices("a*")
+ .setIndicesOptions(allowNoIndices)
+ .get();
fail("Expected IndexNotFoundException");
} catch (IndexNotFoundException e) {
assertThat(e.getMessage(), is("no such index [a*]"));
@@ -320,7 +338,12 @@ public void testIndicesIgnoreUnavailableFalse() throws Exception {
// ignore_unavailable set to false throws exception when allowNoIndices is turned off
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, true, true, false);
try {
- clusterAdmin().prepareState().clear().setMetadata(true).setIndices("fzzbzz").setIndicesOptions(allowNoIndices).get();
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .clear()
+ .setMetadata(true)
+ .setIndices("fzzbzz")
+ .setIndicesOptions(allowNoIndices)
+ .get();
fail("Expected IndexNotFoundException");
} catch (IndexNotFoundException e) {
assertThat(e.getMessage(), is("no such index [fzzbzz]"));
@@ -330,7 +353,7 @@ public void testIndicesIgnoreUnavailableFalse() throws Exception {
public void testPrivateCustomsAreExcluded() throws Exception {
// ensure that the custom is injected into the cluster state
assertBusy(() -> assertTrue(clusterService().state().customs().containsKey("test")));
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().setCustoms(true).get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setCustoms(true).get();
assertFalse(clusterStateResponse.getState().customs().containsKey("test"));
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleDataNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleDataNodesIT.java
index 8a239f7293e22..58daca22303cf 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleDataNodesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleDataNodesIT.java
@@ -47,7 +47,12 @@ public void testIndexingBeforeAndAfterDataNodesStart() {
internalCluster().startNode(nonDataNode());
assertThat(
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("2").setLocal(true).get().isTimedOut(),
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForEvents(Priority.LANGUID)
+ .setWaitForNodes("2")
+ .setLocal(true)
+ .get()
+ .isTimedOut(),
equalTo(false)
);
@@ -62,7 +67,12 @@ public void testIndexingBeforeAndAfterDataNodesStart() {
// now, start a node data, and see that it gets with shards
internalCluster().startNode(dataNode());
assertThat(
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("3").setLocal(true).get().isTimedOut(),
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForEvents(Priority.LANGUID)
+ .setWaitForNodes("3")
+ .setLocal(true)
+ .get()
+ .isTimedOut(),
equalTo(false)
);
@@ -76,7 +86,9 @@ public void testShardsAllocatedAfterDataNodesStart() {
new CreateIndexRequest("test").settings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0))
.waitForActiveShards(ActiveShardCount.NONE)
).actionGet();
- final ClusterHealthResponse healthResponse1 = clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).get();
+ final ClusterHealthResponse healthResponse1 = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForEvents(Priority.LANGUID)
+ .get();
assertThat(healthResponse1.isTimedOut(), equalTo(false));
assertThat(healthResponse1.getStatus(), equalTo(ClusterHealthStatus.RED));
assertThat(healthResponse1.getActiveShards(), equalTo(0));
@@ -84,7 +96,7 @@ public void testShardsAllocatedAfterDataNodesStart() {
internalCluster().startNode(dataNode());
assertThat(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes("2")
.setWaitForGreenStatus()
@@ -100,7 +112,9 @@ public void testAutoExpandReplicasAdjustedWhenDataNodeJoins() {
new CreateIndexRequest("test").settings(Settings.builder().put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-all"))
.waitForActiveShards(ActiveShardCount.NONE)
).actionGet();
- final ClusterHealthResponse healthResponse1 = clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).get();
+ final ClusterHealthResponse healthResponse1 = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForEvents(Priority.LANGUID)
+ .get();
assertThat(healthResponse1.isTimedOut(), equalTo(false));
assertThat(healthResponse1.getStatus(), equalTo(ClusterHealthStatus.RED));
assertThat(healthResponse1.getActiveShards(), equalTo(0));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java
index 538f5e7a1640d..8cdc49d3b12d5 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java
@@ -37,7 +37,7 @@ public void testSimpleOnlyMasterNodeElection() throws IOException {
internalCluster().startNode(Settings.builder().put(dataOnlyNode()).put("discovery.initial_state_timeout", "1s"));
try {
assertThat(
- clusterAdmin().prepareState()
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.setMasterNodeTimeout(TimeValue.timeValueMillis(100))
.get()
.getState()
@@ -52,11 +52,27 @@ public void testSimpleOnlyMasterNodeElection() throws IOException {
logger.info("--> start master node");
final String masterNodeName = internalCluster().startMasterOnlyNode();
assertThat(
- internalCluster().nonMasterClient().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(),
+ internalCluster().nonMasterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
+ .getName(),
equalTo(masterNodeName)
);
assertThat(
- internalCluster().masterClient().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(),
+ internalCluster().masterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
+ .getName(),
equalTo(masterNodeName)
);
@@ -66,7 +82,7 @@ public void testSimpleOnlyMasterNodeElection() throws IOException {
try {
assertThat(
- clusterAdmin().prepareState()
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.setMasterNodeTimeout(TimeValue.timeValueMillis(100))
.get()
.getState()
@@ -84,11 +100,27 @@ public void testSimpleOnlyMasterNodeElection() throws IOException {
Settings.builder().put(nonDataNode(masterNode())).put(masterDataPathSettings)
);
assertThat(
- internalCluster().nonMasterClient().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(),
+ internalCluster().nonMasterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
+ .getName(),
equalTo(nextMasterEligibleNodeName)
);
assertThat(
- internalCluster().masterClient().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(),
+ internalCluster().masterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
+ .getName(),
equalTo(nextMasterEligibleNodeName)
);
}
@@ -99,7 +131,7 @@ public void testElectOnlyBetweenMasterNodes() throws Exception {
internalCluster().startNode(Settings.builder().put(dataOnlyNode()).put("discovery.initial_state_timeout", "1s"));
try {
assertThat(
- clusterAdmin().prepareState()
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.setMasterNodeTimeout(TimeValue.timeValueMillis(100))
.get()
.getState()
@@ -114,45 +146,112 @@ public void testElectOnlyBetweenMasterNodes() throws Exception {
logger.info("--> start master node (1)");
final String masterNodeName = internalCluster().startMasterOnlyNode();
assertThat(
- internalCluster().nonMasterClient().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(),
+ internalCluster().nonMasterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
+ .getName(),
equalTo(masterNodeName)
);
assertThat(
- internalCluster().masterClient().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(),
+ internalCluster().masterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
+ .getName(),
equalTo(masterNodeName)
);
logger.info("--> start master node (2)");
final String nextMasterEligableNodeName = internalCluster().startMasterOnlyNode();
assertThat(
- internalCluster().nonMasterClient().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(),
+ internalCluster().nonMasterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
+ .getName(),
equalTo(masterNodeName)
);
assertThat(
- internalCluster().masterClient().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(),
+ internalCluster().masterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
+ .getName(),
equalTo(masterNodeName)
);
logger.info("--> closing master node (1)");
- client().execute(TransportAddVotingConfigExclusionsAction.TYPE, new AddVotingConfigExclusionsRequest(masterNodeName)).get();
+ client().execute(
+ TransportAddVotingConfigExclusionsAction.TYPE,
+ new AddVotingConfigExclusionsRequest(TEST_REQUEST_TIMEOUT, masterNodeName)
+ ).get();
// removing the master from the voting configuration immediately triggers the master to step down
assertBusy(() -> {
assertThat(
- internalCluster().nonMasterClient().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(),
+ internalCluster().nonMasterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
+ .getName(),
equalTo(nextMasterEligableNodeName)
);
assertThat(
- internalCluster().masterClient().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(),
+ internalCluster().masterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
+ .getName(),
equalTo(nextMasterEligableNodeName)
);
});
internalCluster().stopNode(masterNodeName);
assertThat(
- internalCluster().nonMasterClient().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(),
+ internalCluster().nonMasterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
+ .getName(),
equalTo(nextMasterEligableNodeName)
);
assertThat(
- internalCluster().masterClient().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(),
+ internalCluster().masterClient()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
+ .getName(),
equalTo(nextMasterEligableNodeName)
);
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/UpdateSettingsValidationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/UpdateSettingsValidationIT.java
index 64ac8318dce23..05b58ea2f8808 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/UpdateSettingsValidationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/UpdateSettingsValidationIT.java
@@ -27,7 +27,7 @@ public void testUpdateSettingsValidation() throws Exception {
createIndex("test");
NumShards test = getNumShards("test");
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth("test")
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test")
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes("3")
.setWaitForGreenStatus()
@@ -36,7 +36,10 @@ public void testUpdateSettingsValidation() throws Exception {
assertThat(healthResponse.getIndices().get("test").getActiveShards(), equalTo(test.totalNumShards));
setReplicaCount(0, "test");
- healthResponse = clusterAdmin().prepareHealth("test").setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test")
+ .setWaitForEvents(Priority.LANGUID)
+ .setWaitForGreenStatus()
+ .get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
assertThat(healthResponse.getIndices().get("test").getActiveShards(), equalTo(test.numPrimaries));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java
index 71418cb83debe..36d903205f05c 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/AwarenessAllocationIT.java
@@ -71,7 +71,7 @@ public void testSimpleAwareness() throws Exception {
// On slow machines the initial relocation might be delayed
assertBusy(() -> {
logger.info("--> waiting for no relocation");
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices("test1", "test2")
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
@@ -82,7 +82,7 @@ public void testSimpleAwareness() throws Exception {
assertThat("Cluster health request timed out", clusterHealth.isTimedOut(), equalTo(false));
logger.info("--> checking current state");
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
// check that closed indices are effectively closed
final List notClosedIndices = indicesToClose.stream()
@@ -115,7 +115,7 @@ public void testAwarenessZones() {
String A_1 = nodes.get(3);
logger.info("--> waiting for nodes to form a cluster");
- ClusterHealthResponse health = clusterAdmin().prepareHealth().setWaitForNodes("4").get();
+ ClusterHealthResponse health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("4").get();
assertThat(health.isTimedOut(), equalTo(false));
createIndex("test", 5, 1);
@@ -125,7 +125,7 @@ public void testAwarenessZones() {
}
logger.info("--> waiting for shards to be allocated");
- health = clusterAdmin().prepareHealth()
+ health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices("test")
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
@@ -133,7 +133,7 @@ public void testAwarenessZones() {
.get();
assertThat(health.isTimedOut(), equalTo(false));
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
Map counts = computeShardCounts(clusterState);
assertThat(counts.get(A_1), anyOf(equalTo(2), equalTo(3)));
@@ -162,7 +162,7 @@ public void testAwarenessZonesIncrementalNodes() {
assertAcked(indicesAdmin().prepareClose("test"));
}
- ClusterHealthResponse health = clusterAdmin().prepareHealth()
+ ClusterHealthResponse health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices("test")
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
@@ -170,7 +170,7 @@ public void testAwarenessZonesIncrementalNodes() {
.setWaitForNoRelocatingShards(true)
.get();
assertThat(health.isTimedOut(), equalTo(false));
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
Map counts = computeShardCounts(clusterState);
assertThat(counts.get(A_0), equalTo(5));
@@ -178,7 +178,7 @@ public void testAwarenessZonesIncrementalNodes() {
logger.info("--> starting another node in zone 'b'");
String B_1 = internalCluster().startNode(Settings.builder().put(commonSettings).put("node.attr.zone", "b").build());
- health = clusterAdmin().prepareHealth()
+ health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices("test")
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
@@ -186,7 +186,7 @@ public void testAwarenessZonesIncrementalNodes() {
.get();
assertThat(health.isTimedOut(), equalTo(false));
ClusterRerouteUtils.reroute(client());
- health = clusterAdmin().prepareHealth()
+ health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices("test")
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
@@ -196,7 +196,7 @@ public void testAwarenessZonesIncrementalNodes() {
.get();
assertThat(health.isTimedOut(), equalTo(false));
- clusterState = clusterAdmin().prepareState().get().getState();
+ clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
counts = computeShardCounts(clusterState);
assertThat(counts.get(A_0), equalTo(5));
@@ -204,7 +204,7 @@ public void testAwarenessZonesIncrementalNodes() {
assertThat(counts.get(B_1), equalTo(2));
String noZoneNode = internalCluster().startNode();
- health = clusterAdmin().prepareHealth()
+ health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices("test")
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
@@ -212,7 +212,7 @@ public void testAwarenessZonesIncrementalNodes() {
.get();
assertThat(health.isTimedOut(), equalTo(false));
ClusterRerouteUtils.reroute(client());
- health = clusterAdmin().prepareHealth()
+ health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices("test")
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
@@ -222,7 +222,7 @@ public void testAwarenessZonesIncrementalNodes() {
.get();
assertThat(health.isTimedOut(), equalTo(false));
- clusterState = clusterAdmin().prepareState().get().getState();
+ clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
counts = computeShardCounts(clusterState);
assertThat(counts.get(A_0), equalTo(5));
@@ -230,7 +230,7 @@ public void testAwarenessZonesIncrementalNodes() {
assertThat(counts.get(B_1), equalTo(2));
assertThat(counts.containsKey(noZoneNode), equalTo(false));
updateClusterSettings(Settings.builder().put("cluster.routing.allocation.awareness.attributes", ""));
- health = clusterAdmin().prepareHealth()
+ health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices("test")
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
@@ -240,7 +240,7 @@ public void testAwarenessZonesIncrementalNodes() {
.get();
assertThat(health.isTimedOut(), equalTo(false));
- clusterState = clusterAdmin().prepareState().get().getState();
+ clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
counts = computeShardCounts(clusterState);
assertThat(counts.get(A_0), equalTo(3));
@@ -254,7 +254,8 @@ public void testForceAwarenessSettingValidation() {
final IllegalArgumentException illegalArgumentException = expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings().setPersistentSettings(Settings.builder().put(prefix + "nonsense", "foo"))
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(Settings.builder().put(prefix + "nonsense", "foo"))
);
assertThat(illegalArgumentException.getMessage(), containsString("[cluster.routing.allocation.awareness.force.]"));
assertThat(illegalArgumentException.getCause(), instanceOf(SettingsException.class));
@@ -263,7 +264,8 @@ public void testForceAwarenessSettingValidation() {
assertThat(
expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings().setPersistentSettings(Settings.builder().put(prefix + "attr.not_values", "foo"))
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(Settings.builder().put(prefix + "attr.not_values", "foo"))
).getMessage(),
containsString("[cluster.routing.allocation.awareness.force.attr.not_values]")
);
@@ -271,7 +273,8 @@ public void testForceAwarenessSettingValidation() {
assertThat(
expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings().setPersistentSettings(Settings.builder().put(prefix + "attr.values.junk", "foo"))
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(Settings.builder().put(prefix + "attr.values.junk", "foo"))
).getMessage(),
containsString("[cluster.routing.allocation.awareness.force.attr.values.junk]")
);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java
index dc93aaa814018..da585d1bb67d4 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/ClusterRerouteIT.java
@@ -96,7 +96,7 @@ private void rerouteWithCommands(Settings commonSettings) throws Exception {
indicesAdmin().prepareClose("test").setWaitForActiveShards(ActiveShardCount.NONE).get();
}
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.getRoutingNodes().unassigned().size(), equalTo(2));
logger.info("--> explicitly allocate shard 1, *under dry_run*");
@@ -115,7 +115,7 @@ private void rerouteWithCommands(Settings commonSettings) throws Exception {
);
logger.info("--> get the state, verify nothing changed because of the dry run");
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.getRoutingNodes().unassigned().size(), equalTo(2));
logger.info("--> explicitly allocate shard 1, actually allocating, no dry run");
@@ -132,7 +132,7 @@ private void rerouteWithCommands(Settings commonSettings) throws Exception {
equalTo(ShardRoutingState.INITIALIZING)
);
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth()
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices("test")
.setWaitForEvents(Priority.LANGUID)
.setWaitForYellowStatus()
@@ -140,7 +140,7 @@ private void rerouteWithCommands(Settings commonSettings) throws Exception {
assertThat(healthResponse.isTimedOut(), equalTo(false));
logger.info("--> get the state, verify shard 1 primary allocated");
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.getRoutingNodes().unassigned().size(), equalTo(1));
assertThat(
state.getRoutingNodes().node(state.nodes().resolveNode(node_1).getId()).iterator().next().state(),
@@ -165,7 +165,7 @@ private void rerouteWithCommands(Settings commonSettings) throws Exception {
equalTo(ShardRoutingState.INITIALIZING)
);
- healthResponse = clusterAdmin().prepareHealth()
+ healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices("test")
.setWaitForEvents(Priority.LANGUID)
.setWaitForYellowStatus()
@@ -174,7 +174,7 @@ private void rerouteWithCommands(Settings commonSettings) throws Exception {
assertThat(healthResponse.isTimedOut(), equalTo(false));
logger.info("--> get the state, verify shard 1 primary moved from node1 to node2");
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.getRoutingNodes().unassigned().size(), equalTo(1));
assertThat(
state.getRoutingNodes().node(state.nodes().resolveNode(node_2).getId()).iterator().next().state(),
@@ -209,7 +209,7 @@ public void testDelayWithALargeAmountOfShards() throws Exception {
internalCluster().startNode(commonSettings);
assertThat(cluster().size(), equalTo(4));
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth().setWaitForNodes("4").get();
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("4").get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
logger.info("--> create indices");
@@ -239,7 +239,7 @@ private void rerouteWithAllocateLocalGateway(Settings commonSettings) throws Exc
String node_1 = internalCluster().startNode(commonSettings);
internalCluster().startNode(commonSettings);
assertThat(cluster().size(), equalTo(2));
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth().setWaitForNodes("2").get();
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("2").get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
logger.info("--> create an index with 1 shard, 1 replica, nothing should allocate");
@@ -253,7 +253,7 @@ private void rerouteWithAllocateLocalGateway(Settings commonSettings) throws Exc
indicesAdmin().prepareClose("test").setWaitForActiveShards(ActiveShardCount.NONE).get();
}
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.getRoutingNodes().unassigned().size(), equalTo(2));
logger.info("--> explicitly allocate shard 1, actually allocating, no dry run");
@@ -270,7 +270,7 @@ private void rerouteWithAllocateLocalGateway(Settings commonSettings) throws Exc
equalTo(ShardRoutingState.INITIALIZING)
);
- healthResponse = clusterAdmin().prepareHealth()
+ healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices("test")
.setWaitForEvents(Priority.LANGUID)
.setWaitForYellowStatus()
@@ -278,7 +278,7 @@ private void rerouteWithAllocateLocalGateway(Settings commonSettings) throws Exc
assertThat(healthResponse.isTimedOut(), equalTo(false));
logger.info("--> get the state, verify shard 1 primary allocated");
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.getRoutingNodes().unassigned().size(), equalTo(1));
assertThat(
state.getRoutingNodes().node(state.nodes().resolveNode(node_1).getId()).iterator().next().state(),
@@ -306,7 +306,7 @@ private void rerouteWithAllocateLocalGateway(Settings commonSettings) throws Exc
// TODO can we get around this? the cluster is RED, so what do we wait for?
ClusterRerouteUtils.reroute(client());
assertThat(
- clusterAdmin().prepareHealth().setIndices("test").setWaitForNodes("2").get().getStatus(),
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setIndices("test").setWaitForNodes("2").get().getStatus(),
equalTo(ClusterHealthStatus.RED)
);
logger.info("--> explicitly allocate primary");
@@ -326,7 +326,7 @@ private void rerouteWithAllocateLocalGateway(Settings commonSettings) throws Exc
logger.info("--> get the state, verify shard 1 primary allocated");
final String nodeToCheck = node_1;
assertBusy(() -> {
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
String nodeId = clusterState.nodes().resolveNode(nodeToCheck).getId();
assertThat(clusterState.getRoutingNodes().node(nodeId).iterator().next().state(), equalTo(ShardRoutingState.STARTED));
});
@@ -339,7 +339,7 @@ public void testRerouteExplain() {
String node_1 = internalCluster().startNode(commonSettings);
assertThat(cluster().size(), equalTo(1));
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth().setWaitForNodes("1").get();
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("1").get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
logger.info("--> create an index with 1 shard");
@@ -356,7 +356,7 @@ public void testRerouteExplain() {
logger.info("--> starting a second node");
String node_2 = internalCluster().startNode(commonSettings);
assertThat(cluster().size(), equalTo(2));
- healthResponse = clusterAdmin().prepareHealth().setWaitForNodes("2").get();
+ healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("2").get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
logger.info("--> try to move the shard from node1 to node2");
@@ -385,12 +385,12 @@ public void testMessageLogging() {
final String nodeName1 = internalCluster().startNode(settings);
assertThat(cluster().size(), equalTo(1));
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth().setWaitForNodes("1").get();
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("1").get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
final String nodeName2 = internalCluster().startNode(settings);
assertThat(cluster().size(), equalTo(2));
- healthResponse = clusterAdmin().prepareHealth().setWaitForNodes("2").get();
+ healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("2").get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
final String indexName = "test_index";
@@ -474,7 +474,7 @@ public void testClusterRerouteWithBlocks() {
ensureGreen("test-blocks");
logger.info("--> check that the index has 1 shard");
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
List shards = state.routingTable().allShards("test-blocks");
assertThat(shards, hasSize(1));
@@ -504,7 +504,7 @@ public void testClusterRerouteWithBlocks() {
new MoveAllocationCommand("test-blocks", 0, nodesIds.get(toggle % 2), nodesIds.get(++toggle % 2))
);
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth()
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices("test-blocks")
.setWaitForYellowStatus()
.setWaitForNoRelocatingShards(true)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java
index 5f54b32ab4a14..abce3ce30fbad 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java
@@ -66,7 +66,7 @@ public void testDecommissionNodeNoReplicas() {
ensureGreen("test");
logger.info("--> verify all are allocated on node1 now");
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) {
for (int shardId = 0; shardId < indexRoutingTable.size(); shardId++) {
final IndexShardRoutingTable indexShardRoutingTable = indexRoutingTable.shard(shardId);
@@ -93,7 +93,7 @@ public void testAutoExpandReplicasToFilteredNodes() {
logger.info("--> creating an index with auto-expand replicas");
createIndex("test", Settings.builder().put(AutoExpandReplicas.SETTING.getKey(), "0-all").build());
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(clusterState.metadata().index("test").getNumberOfReplicas(), equalTo(1));
ensureGreen("test");
@@ -106,7 +106,7 @@ public void testAutoExpandReplicasToFilteredNodes() {
ensureGreen("test");
logger.info("--> verify all are allocated on node1 now");
- clusterState = clusterAdmin().prepareState().get().getState();
+ clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(clusterState.metadata().index("test").getNumberOfReplicas(), equalTo(0));
for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) {
for (int shardId = 0; shardId < indexRoutingTable.size(); shardId++) {
@@ -142,7 +142,7 @@ public void testDisablingAllocationFiltering() {
ensureGreen("test");
}
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
IndexRoutingTable indexRoutingTable = clusterState.routingTable().index("test");
int numShardsOnNode1 = 0;
for (int shardId = 0; shardId < indexRoutingTable.size(); shardId++) {
@@ -165,7 +165,7 @@ public void testDisablingAllocationFiltering() {
ensureGreen("test");
logger.info("--> verify all shards are allocated on node_1 now");
- clusterState = clusterAdmin().prepareState().get().getState();
+ clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
indexRoutingTable = clusterState.routingTable().index("test");
for (int shardId = 0; shardId < indexRoutingTable.size(); shardId++) {
final IndexShardRoutingTable indexShardRoutingTable = indexRoutingTable.shard(shardId);
@@ -180,7 +180,7 @@ public void testDisablingAllocationFiltering() {
ensureGreen("test");
logger.info("--> verify that there are shards allocated on both nodes now");
- clusterState = clusterAdmin().prepareState().get().getState();
+ clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(clusterState.routingTable().index("test").numberOfNodesShardsAreAllocatedOn(), equalTo(2));
}
@@ -193,7 +193,7 @@ public void testInvalidIPFilterClusterSettings() {
);
IllegalArgumentException e = expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings()
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().put(filterSetting.getKey() + ipKey, "192.168.1.1."))
);
assertEquals("invalid IP address [192.168.1.1.] for [" + filterSetting.getKey() + ipKey + "]", e.getMessage());
@@ -221,12 +221,12 @@ public void testTransientSettingsStillApplied() {
.build();
logger.info("--> updating settings");
- clusterAdmin().prepareUpdateSettings().setTransientSettings(exclude).get();
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT).setTransientSettings(exclude).get();
logger.info("--> waiting for relocation");
waitForRelocation(ClusterHealthStatus.GREEN);
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
for (ShardRouting shard : RoutingNodesHelper.shardsWithState(state.getRoutingNodes(), ShardRoutingState.STARTED)) {
String node = state.getRoutingNodes().node(shard.currentNodeId()).node().getName();
@@ -243,12 +243,15 @@ public void testTransientSettingsStillApplied() {
Settings other = Settings.builder().put("cluster.info.update.interval", "45s").build();
logger.info("--> updating settings with random persistent setting");
- clusterAdmin().prepareUpdateSettings().setPersistentSettings(other).setTransientSettings(exclude).get();
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(other)
+ .setTransientSettings(exclude)
+ .get();
logger.info("--> waiting for relocation");
waitForRelocation(ClusterHealthStatus.GREEN);
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
// The transient settings still exist in the state
assertThat(state.metadata().transientSettings(), equalTo(exclude));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java
index f66430871c9d8..6a3d2f2fe5210 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java
@@ -33,7 +33,7 @@ public void testSaneAllocation() {
}
ensureGreen("test");
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.getRoutingNodes().unassigned().size(), equalTo(0));
for (RoutingNode node : state.getRoutingNodes()) {
if (node.isEmpty() == false) {
@@ -42,7 +42,7 @@ public void testSaneAllocation() {
}
setReplicaCount(0, "test");
ensureGreen("test");
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.getRoutingNodes().unassigned().size(), equalTo(0));
for (RoutingNode node : state.getRoutingNodes()) {
@@ -60,7 +60,7 @@ public void testSaneAllocation() {
setReplicaCount(1, "test");
ensureGreen("test");
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.getRoutingNodes().unassigned().size(), equalTo(0));
for (RoutingNode node : state.getRoutingNodes()) {
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/InitialClusterStateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/InitialClusterStateIT.java
index 97112b97cc130..eebd059ed13b5 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/InitialClusterStateIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/InitialClusterStateIT.java
@@ -33,7 +33,13 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
private static void assertClusterUuid(boolean expectCommitted, String expectedValue) {
for (String nodeName : internalCluster().getNodeNames()) {
- final Metadata metadata = client(nodeName).admin().cluster().prepareState().setLocal(true).get().getState().metadata();
+ final Metadata metadata = client(nodeName).admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .setLocal(true)
+ .get()
+ .getState()
+ .metadata();
assertEquals(expectCommitted, metadata.clusterUUIDCommitted());
assertEquals(expectedValue, metadata.clusterUUID());
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java
index a208656179339..bd12f570e136f 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java
@@ -135,7 +135,7 @@ public void testDeleteCreateInOneBulk() throws Exception {
final var dataNode = internalCluster().startDataOnlyNode();
final var dataNodeClusterService = internalCluster().clusterService(dataNode);
- assertFalse(clusterAdmin().prepareHealth().setWaitForNodes("2").get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("2").get().isTimedOut());
prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)).get();
ensureGreen("test");
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RemoveCustomsCommandIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RemoveCustomsCommandIT.java
index 65484066ee9b9..a9948367f2780 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RemoveCustomsCommandIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RemoveCustomsCommandIT.java
@@ -46,7 +46,10 @@ public void testRemoveCustomsSuccessful() throws Exception {
String node = internalCluster().startNode();
createIndex("test");
indicesAdmin().prepareDelete("test").get();
- assertEquals(1, clusterAdmin().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size());
+ assertEquals(
+ 1,
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().indexGraveyard().getTombstones().size()
+ );
Settings dataPathSettings = internalCluster().dataPathSettings(node);
ensureStableCluster(1);
internalCluster().stopRandomDataNode();
@@ -64,7 +67,10 @@ public void testRemoveCustomsSuccessful() throws Exception {
assertThat(terminal.getOutput(), containsString("index-graveyard"));
internalCluster().startNode(dataPathSettings);
- assertEquals(0, clusterAdmin().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size());
+ assertEquals(
+ 0,
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().indexGraveyard().getTombstones().size()
+ );
}
public void testCustomDoesNotMatch() throws Exception {
@@ -72,7 +78,10 @@ public void testCustomDoesNotMatch() throws Exception {
String node = internalCluster().startNode();
createIndex("test");
indicesAdmin().prepareDelete("test").get();
- assertEquals(1, clusterAdmin().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size());
+ assertEquals(
+ 1,
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().indexGraveyard().getTombstones().size()
+ );
Settings dataPathSettings = internalCluster().dataPathSettings(node);
ensureStableCluster(1);
internalCluster().stopRandomDataNode();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RemoveSettingsCommandIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RemoveSettingsCommandIT.java
index 560ca3e8a548d..527d8b0a62fe4 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RemoveSettingsCommandIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RemoveSettingsCommandIT.java
@@ -58,7 +58,7 @@ public void testRemoveSettingsSuccessful() throws Exception {
Settings.builder().put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), false)
);
assertThat(
- clusterAdmin().prepareState().get().getState().metadata().persistentSettings().keySet(),
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().persistentSettings().keySet(),
contains(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey())
);
Settings dataPathSettings = internalCluster().dataPathSettings(node);
@@ -84,7 +84,7 @@ public void testRemoveSettingsSuccessful() throws Exception {
internalCluster().startNode(dataPathSettings);
assertThat(
- clusterAdmin().prepareState().get().getState().metadata().persistentSettings().keySet(),
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().persistentSettings().keySet(),
not(contains(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey()))
);
}
@@ -96,7 +96,7 @@ public void testSettingDoesNotMatch() throws Exception {
Settings.builder().put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), false)
);
assertThat(
- clusterAdmin().prepareState().get().getState().metadata().persistentSettings().keySet(),
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().persistentSettings().keySet(),
contains(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey())
);
Settings dataPathSettings = internalCluster().dataPathSettings(node);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java
index 00e171a7a132a..2c1ca5866fa46 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java
@@ -137,7 +137,7 @@ public void testBootstrapNotBootstrappedCluster() throws Exception {
.build()
);
assertBusy(() -> {
- ClusterState state = clusterAdmin().prepareState().setLocal(true).get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertTrue(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID));
});
@@ -242,7 +242,13 @@ public void test3MasterNodes2Failed() throws Exception {
logger.info("--> ensure NO_MASTER_BLOCK on data-only node");
assertBusy(() -> {
- ClusterState state = internalCluster().client(dataNode).admin().cluster().prepareState().setLocal(true).get().getState();
+ ClusterState state = internalCluster().client(dataNode)
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .setLocal(true)
+ .get()
+ .getState();
assertTrue(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID));
});
@@ -288,7 +294,13 @@ public void test3MasterNodes2Failed() throws Exception {
logger.info("--> ensure there is no NO_MASTER_BLOCK and unsafe-bootstrap is reflected in cluster state");
assertBusy(() -> {
- ClusterState state = internalCluster().client(dataNode2).admin().cluster().prepareState().setLocal(true).get().getState();
+ ClusterState state = internalCluster().client(dataNode2)
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .setLocal(true)
+ .get()
+ .getState();
assertFalse(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID));
assertTrue(state.metadata().persistentSettings().getAsBoolean(UnsafeBootstrapMasterCommand.UNSAFE_BOOTSTRAP.getKey(), false));
});
@@ -333,7 +345,13 @@ public void testNoInitialBootstrapAfterDetach() throws Exception {
.build()
);
- ClusterState state = internalCluster().client().admin().cluster().prepareState().setLocal(true).get().getState();
+ ClusterState state = internalCluster().client()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .setLocal(true)
+ .get()
+ .getState();
assertTrue(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID));
internalCluster().stopNode(node);
@@ -345,7 +363,7 @@ public void testCanRunUnsafeBootstrapAfterErroneousDetachWithoutLoosingMetadata(
Settings masterNodeDataPathSettings = internalCluster().dataPathSettings(masterNode);
updateClusterSettings(Settings.builder().put(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey(), "1234kb"));
- ClusterState state = internalCluster().client().admin().cluster().prepareState().get().getState();
+ ClusterState state = internalCluster().client().admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.metadata().persistentSettings().get(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey()), equalTo("1234kb"));
internalCluster().stopCurrentMasterNode();
@@ -359,7 +377,7 @@ public void testCanRunUnsafeBootstrapAfterErroneousDetachWithoutLoosingMetadata(
internalCluster().startMasterOnlyNode(masterNodeDataPathSettings);
ensureGreen();
- state = internalCluster().client().admin().cluster().prepareState().get().getState();
+ state = internalCluster().client().admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.metadata().settings().get(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey()), equalTo("1234kb"));
}
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/VotingConfigurationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/VotingConfigurationIT.java
index b0cc81bf34811..6e21c3622ec45 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/VotingConfigurationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/VotingConfigurationIT.java
@@ -43,8 +43,11 @@ public void testAbdicateAfterVotingConfigExclusionAdded() throws ExecutionExcept
final String originalMaster = internalCluster().getMasterName();
logger.info("--> excluding master node {}", originalMaster);
- client().execute(TransportAddVotingConfigExclusionsAction.TYPE, new AddVotingConfigExclusionsRequest(originalMaster)).get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).get();
+ client().execute(
+ TransportAddVotingConfigExclusionsAction.TYPE,
+ new AddVotingConfigExclusionsRequest(TEST_REQUEST_TIMEOUT, originalMaster)
+ ).get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).get();
assertNotEquals(originalMaster, internalCluster().getMasterName());
}
@@ -60,7 +63,7 @@ public void testElectsNodeNotInVotingConfiguration() throws Exception {
internalCluster().client()
.admin()
.cluster()
- .prepareHealth()
+ .prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForNodes("4")
.setWaitForEvents(Priority.LANGUID)
.get()
@@ -71,7 +74,7 @@ public void testElectsNodeNotInVotingConfiguration() throws Exception {
final ClusterState clusterState = internalCluster().client()
.admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setNodes(true)
.setMetadata(true)
@@ -111,7 +114,7 @@ public void testElectsNodeNotInVotingConfiguration() throws Exception {
internalCluster().client()
.admin()
.cluster()
- .prepareHealth()
+ .prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForNodes("3")
.setWaitForEvents(Priority.LANGUID)
.get()
@@ -121,7 +124,7 @@ public void testElectsNodeNotInVotingConfiguration() throws Exception {
final ClusterState newClusterState = internalCluster().client()
.admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setNodes(true)
.setMetadata(true)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/ZenDiscoveryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/ZenDiscoveryIT.java
index 9b117365777ce..ea127a7352914 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/ZenDiscoveryIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/ZenDiscoveryIT.java
@@ -35,7 +35,7 @@ public void testNoShardRelocationsOccurWhenElectedMasterNodeFails() throws Excep
internalCluster().startNodes(2, masterNodeSettings);
Settings dateNodeSettings = dataNode();
internalCluster().startNodes(2, dateNodeSettings);
- ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes("4")
.setWaitForNoRelocatingShards(true)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/AllocationIdIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/AllocationIdIT.java
index 8cee57ee34b89..69923c787a054 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/AllocationIdIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/AllocationIdIT.java
@@ -111,7 +111,7 @@ public void testFailedRecoveryOnAllocateStalePrimaryRequiresAnotherAllocateStale
// allocation fails due to corruption marker
assertBusy(() -> {
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final ShardRouting shardRouting = state.routingTable().index(indexName).shard(shardId.id()).primaryShard();
assertThat(shardRouting.state(), equalTo(ShardRoutingState.UNASSIGNED));
assertThat(shardRouting.unassignedInfo().reason(), equalTo(UnassignedInfo.Reason.ALLOCATION_FAILED));
@@ -143,7 +143,9 @@ public void testFailedRecoveryOnAllocateStalePrimaryRequiresAnotherAllocateStale
}
public void checkHealthStatus(String indexName, ClusterHealthStatus healthStatus) {
- final ClusterHealthStatus indexHealthStatus = clusterAdmin().health(new ClusterHealthRequest(indexName)).actionGet().getStatus();
+ final ClusterHealthStatus indexHealthStatus = clusterAdmin().health(new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, indexName))
+ .actionGet()
+ .getStatus();
assertThat(indexHealthStatus, is(healthStatus));
}
@@ -169,7 +171,7 @@ private Path getIndexPath(String nodeName, ShardId shardId) {
}
private Set getAllocationIds(String indexName) {
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
return state.metadata().index(indexName).inSyncAllocationIds(0);
}
@@ -181,7 +183,14 @@ private IndexSettings getIndexSettings(String indexName, String nodeName) {
private String historyUUID(String node, String indexName) {
final ShardStats[] shards = client(node).admin().indices().prepareStats(indexName).clear().get().getShards();
- final String nodeId = client(node).admin().cluster().prepareState().get().getState().nodes().resolveNode(node).getId();
+ final String nodeId = client(node).admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .resolveNode(node)
+ .getId();
assertThat(shards.length, greaterThan(0));
final Set historyUUIDs = Arrays.stream(shards)
.filter(shard -> shard.getShardRouting().currentNodeId().equals(nodeId))
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/DelayedAllocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/DelayedAllocationIT.java
index 543b0be8ae48d..8a2f5d749ff21 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/DelayedAllocationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/DelayedAllocationIT.java
@@ -32,7 +32,7 @@ public void testNoDelayedTimeout() throws Exception {
ensureGreen("test");
indexRandomData();
internalCluster().stopNode(findNodeWithShard());
- assertThat(clusterAdmin().prepareHealth().get().getDelayedUnassignedShards(), equalTo(0));
+ assertThat(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).get().getDelayedUnassignedShards(), equalTo(0));
ensureGreen("test");
}
@@ -53,9 +53,12 @@ public void testDelayedAllocationNodeLeavesAndComesBack() throws Exception {
Settings nodeWithShardDataPathSettings = internalCluster().dataPathSettings(nodeWithShard);
internalCluster().stopNode(nodeWithShard);
assertBusy(
- () -> assertThat(clusterAdmin().prepareState().all().get().getState().getRoutingNodes().unassigned().size() > 0, equalTo(true))
+ () -> assertThat(
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).all().get().getState().getRoutingNodes().unassigned().size() > 0,
+ equalTo(true)
+ )
);
- assertThat(clusterAdmin().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1));
+ assertThat(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).get().getDelayedUnassignedShards(), equalTo(1));
internalCluster().startNode(nodeWithShardDataPathSettings); // this will use the same data location as the stopped node
ensureGreen("test");
}
@@ -97,16 +100,19 @@ public void testDelayedAllocationChangeWithSettingTo100ms() throws Exception {
indexRandomData();
internalCluster().stopNode(findNodeWithShard());
assertBusy(
- () -> assertThat(clusterAdmin().prepareState().all().get().getState().getRoutingNodes().unassigned().size() > 0, equalTo(true))
+ () -> assertThat(
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).all().get().getState().getRoutingNodes().unassigned().size() > 0,
+ equalTo(true)
+ )
);
- assertThat(clusterAdmin().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1));
+ assertThat(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).get().getDelayedUnassignedShards(), equalTo(1));
logger.info("Setting shorter allocation delay");
updateIndexSettings(
Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueMillis(100)),
"test"
);
ensureGreen("test");
- assertThat(clusterAdmin().prepareHealth().get().getDelayedUnassignedShards(), equalTo(0));
+ assertThat(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).get().getDelayedUnassignedShards(), equalTo(0));
}
/**
@@ -123,15 +129,18 @@ public void testDelayedAllocationChangeWithSettingTo0() throws Exception {
indexRandomData();
internalCluster().stopNode(findNodeWithShard());
assertBusy(
- () -> assertThat(clusterAdmin().prepareState().all().get().getState().getRoutingNodes().unassigned().size() > 0, equalTo(true))
+ () -> assertThat(
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).all().get().getState().getRoutingNodes().unassigned().size() > 0,
+ equalTo(true)
+ )
);
- assertThat(clusterAdmin().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1));
+ assertThat(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).get().getDelayedUnassignedShards(), equalTo(1));
updateIndexSettings(
Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), TimeValue.timeValueMillis(0)),
"test"
);
ensureGreen("test");
- assertThat(clusterAdmin().prepareHealth().get().getDelayedUnassignedShards(), equalTo(0));
+ assertThat(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).get().getDelayedUnassignedShards(), equalTo(0));
}
private void indexRandomData() throws Exception {
@@ -147,7 +156,7 @@ private void indexRandomData() throws Exception {
}
private String findNodeWithShard() {
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
List startedShards = RoutingNodesHelper.shardsWithState(state.getRoutingNodes(), ShardRoutingState.STARTED);
return state.nodes().get(randomFrom(startedShards).currentNodeId()).getName();
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java
index d970634549209..9a13470eea255 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java
@@ -118,7 +118,7 @@ public void testBulkWeirdScenario() throws Exception {
private Settings createStaleReplicaScenario(String master) throws Exception {
prepareIndex("test").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).get();
refresh();
- ClusterState state = clusterAdmin().prepareState().all().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).all().get().getState();
List shards = state.routingTable().allShards("test");
assertThat(shards.size(), equalTo(2));
@@ -164,7 +164,10 @@ private Settings createStaleReplicaScenario(String master) throws Exception {
);
// kick reroute a second time and check that all shards are unassigned
ClusterRerouteUtils.reroute(client(master));
- assertThat(client(master).admin().cluster().prepareState().get().getState().getRoutingNodes().unassigned().size(), equalTo(2));
+ assertThat(
+ client(master).admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getRoutingNodes().unassigned().size(),
+ equalTo(2)
+ );
return inSyncDataPathSettings;
}
@@ -197,7 +200,7 @@ public void testFailedAllocationOfStalePrimaryToDataNodeWithNoData() throws Exce
internalCluster().stopNode(dataNodeWithShardCopy);
ensureStableCluster(1);
assertThat(
- clusterAdmin().prepareState()
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.getRoutingTable()
@@ -223,11 +226,11 @@ public void testFailedAllocationOfStalePrimaryToDataNodeWithNoData() throws Exce
logger.info("--> wait until shard is failed and becomes unassigned again");
assertTrue(
- clusterAdmin().prepareState().get().getState().toString(),
- clusterAdmin().prepareState().get().getState().getRoutingTable().index("test").allPrimaryShardsUnassigned()
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().toString(),
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getRoutingTable().index("test").allPrimaryShardsUnassigned()
);
assertThat(
- clusterAdmin().prepareState()
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.getRoutingTable()
@@ -302,7 +305,14 @@ public void testForceStaleReplicaToBePromotedToPrimary() throws Exception {
// search can throw an "all shards failed" exception. We will wait until the shard initialization has completed before
// verifying the search hit count.
assertBusy(
- () -> assertTrue(clusterAdmin().prepareState().get().getState().routingTable().index(idxName).allPrimaryShardsActive())
+ () -> assertTrue(
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .routingTable()
+ .index(idxName)
+ .allPrimaryShardsActive()
+ )
);
}
ShardStats[] shardStats = indicesAdmin().prepareStats("test")
@@ -313,7 +323,7 @@ public void testForceStaleReplicaToBePromotedToPrimary() throws Exception {
assertThat(shardStat.getCommitStats().getNumDocs(), equalTo(useStaleReplica ? 1 : 0));
}
// allocation id of old primary was cleaned from the in-sync set
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertEquals(
Collections.singleton(state.routingTable().index(idxName).shard(0).primary.allocationId().getId()),
@@ -402,7 +412,15 @@ public void testForcePrimaryShardIfAllocationDecidersSayNoAfterIndexCreation() t
.setSettings(indexSettings(1, 0).put("index.routing.allocation.exclude._name", node))
.get();
- assertThat(clusterAdmin().prepareState().get().getState().getRoutingTable().shardRoutingTable("test", 0).assignedShards(), empty());
+ assertThat(
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .getRoutingTable()
+ .shardRoutingTable("test", 0)
+ .assignedShards(),
+ empty()
+ );
ClusterRerouteUtils.reroute(client(), new AllocateEmptyPrimaryAllocationCommand("test", 0, node, true));
ensureGreen("test");
@@ -419,7 +437,10 @@ public void testDoNotRemoveAllocationIdOnNodeLeave() throws Exception {
final Settings inSyncDataPathSettings = internalCluster().dataPathSettings(replicaNode);
internalCluster().stopNode(replicaNode);
ensureYellow("test");
- assertEquals(2, clusterAdmin().prepareState().get().getState().metadata().index("test").inSyncAllocationIds(0).size());
+ assertEquals(
+ 2,
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test").inSyncAllocationIds(0).size()
+ );
internalCluster().restartRandomDataNode(new InternalTestCluster.RestartCallback() {
@Override
public boolean clearData(String nodeName) {
@@ -428,9 +449,19 @@ public boolean clearData(String nodeName) {
});
logger.info("--> wait until shard is failed and becomes unassigned again");
assertBusy(
- () -> assertTrue(clusterAdmin().prepareState().get().getState().getRoutingTable().index("test").allPrimaryShardsUnassigned())
+ () -> assertTrue(
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .getRoutingTable()
+ .index("test")
+ .allPrimaryShardsUnassigned()
+ )
+ );
+ assertEquals(
+ 2,
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test").inSyncAllocationIds(0).size()
);
- assertEquals(2, clusterAdmin().prepareState().get().getState().metadata().index("test").inSyncAllocationIds(0).size());
logger.info("--> starting node that reuses data folder with the up-to-date shard");
internalCluster().startDataOnlyNode(inSyncDataPathSettings);
@@ -448,10 +479,16 @@ public void testRemoveAllocationIdOnWriteAfterNodeLeave() throws Exception {
final Settings inSyncDataPathSettings = internalCluster().dataPathSettings(replicaNode);
internalCluster().stopNode(replicaNode);
ensureYellow("test");
- assertEquals(2, clusterAdmin().prepareState().get().getState().metadata().index("test").inSyncAllocationIds(0).size());
+ assertEquals(
+ 2,
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test").inSyncAllocationIds(0).size()
+ );
logger.info("--> indexing...");
prepareIndex("test").setSource(jsonBuilder().startObject().field("field", "value1").endObject()).get();
- assertEquals(1, clusterAdmin().prepareState().get().getState().metadata().index("test").inSyncAllocationIds(0).size());
+ assertEquals(
+ 1,
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test").inSyncAllocationIds(0).size()
+ );
internalCluster().restartRandomDataNode(new InternalTestCluster.RestartCallback() {
@Override
public boolean clearData(String nodeName) {
@@ -460,14 +497,31 @@ public boolean clearData(String nodeName) {
});
logger.info("--> wait until shard is failed and becomes unassigned again");
assertBusy(
- () -> assertTrue(clusterAdmin().prepareState().get().getState().getRoutingTable().index("test").allPrimaryShardsUnassigned())
+ () -> assertTrue(
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .getRoutingTable()
+ .index("test")
+ .allPrimaryShardsUnassigned()
+ )
+ );
+ assertEquals(
+ 1,
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test").inSyncAllocationIds(0).size()
);
- assertEquals(1, clusterAdmin().prepareState().get().getState().metadata().index("test").inSyncAllocationIds(0).size());
logger.info("--> starting node that reuses data folder with the up-to-date shard");
internalCluster().startDataOnlyNode(inSyncDataPathSettings);
assertBusy(
- () -> assertTrue(clusterAdmin().prepareState().get().getState().getRoutingTable().index("test").allPrimaryShardsUnassigned())
+ () -> assertTrue(
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .getRoutingTable()
+ .index("test")
+ .allPrimaryShardsUnassigned()
+ )
);
}
@@ -506,7 +560,13 @@ public void testForceAllocatePrimaryOnNoDecision() throws Exception {
ensureGreen(indexName);
assertEquals(
1,
- clusterAdmin().prepareState().get().getState().routingTable().index(indexName).shardsWithState(ShardRoutingState.STARTED).size()
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .routingTable()
+ .index(indexName)
+ .shardsWithState(ShardRoutingState.STARTED)
+ .size()
);
}
@@ -547,7 +607,7 @@ public void testPrimaryReplicaResyncFailed() throws Exception {
internalCluster().stopNode(oldPrimary);
// Checks that we fails replicas in one side but not mark them as stale.
assertBusy(() -> {
- ClusterState state = client(master).admin().cluster().prepareState().get().getState();
+ ClusterState state = client(master).admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexShardRoutingTable shardRoutingTable = state.routingTable().shardRoutingTable(shardId);
final String newPrimaryNode = state.getRoutingNodes().node(shardRoutingTable.primary.currentNodeId()).node().getName();
assertThat(newPrimaryNode, not(equalTo(oldPrimary)));
@@ -563,7 +623,7 @@ public void testPrimaryReplicaResyncFailed() throws Exception {
partition.ensureHealthy(internalCluster());
logger.info("--> stop disrupting network and re-enable allocation");
assertBusy(() -> {
- ClusterState state = client(master).admin().cluster().prepareState().get().getState();
+ ClusterState state = client(master).admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.routingTable().shardRoutingTable(shardId).activeShards(), hasSize(numberOfReplicas));
assertThat(state.metadata().index("test").inSyncAllocationIds(shardId.id()), hasSize(numberOfReplicas + 1));
for (String node : replicaNodes) {
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/RemoveReplicaPriorityIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/RemoveReplicaPriorityIT.java
index 57c4c0986a798..de61c6cf566c2 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/RemoveReplicaPriorityIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/RemoveReplicaPriorityIT.java
@@ -52,7 +52,7 @@ public void testReplicaRemovalPriority() throws Exception {
});
}
- final String dataNodeIdFilter = clusterAdmin().prepareState()
+ final String dataNodeIdFilter = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setNodes(true)
.get()
@@ -74,7 +74,7 @@ public void testReplicaRemovalPriority() throws Exception {
);
assertBusy(() -> {
- final IndexShardRoutingTable indexShardRoutingTable = clusterAdmin().prepareState()
+ final IndexShardRoutingTable indexShardRoutingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setRoutingTable(true)
.get()
@@ -90,7 +90,7 @@ public void testReplicaRemovalPriority() throws Exception {
updateIndexSettings(Settings.builder().putNull(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_PREFIX + "._id"), INDEX_NAME);
assertBusy(() -> {
- final IndexShardRoutingTable indexShardRoutingTable = clusterAdmin().prepareState()
+ final IndexShardRoutingTable indexShardRoutingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setRoutingTable(true)
.get()
@@ -107,7 +107,7 @@ public void testReplicaRemovalPriority() throws Exception {
setReplicaCount(2, INDEX_NAME);
assertBusy(() -> {
- final IndexShardRoutingTable indexShardRoutingTable = clusterAdmin().prepareState()
+ final IndexShardRoutingTable indexShardRoutingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setRoutingTable(true)
.get()
@@ -125,7 +125,7 @@ public void testReplicaRemovalPriority() throws Exception {
setReplicaCount(1, INDEX_NAME);
assertBusy(() -> {
- final IndexShardRoutingTable indexShardRoutingTable = clusterAdmin().prepareState()
+ final IndexShardRoutingTable indexShardRoutingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setRoutingTable(true)
.get()
@@ -143,7 +143,7 @@ public void testReplicaRemovalPriority() throws Exception {
setReplicaCount(0, INDEX_NAME);
assertBusy(() -> {
- final IndexShardRoutingTable indexShardRoutingTable = clusterAdmin().prepareState()
+ final IndexShardRoutingTable indexShardRoutingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setRoutingTable(true)
.get()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/ShardRoutingRoleIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/ShardRoutingRoleIT.java
index 85a04ee6f1851..556836736a9f8 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/ShardRoutingRoleIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/ShardRoutingRoleIT.java
@@ -296,7 +296,7 @@ public void testShardCreation() throws Exception {
createIndex(INDEX_NAME, routingTableWatcher.getIndexSettings());
- final var clusterState = clusterAdmin().prepareState().clear().setRoutingTable(true).get().getState();
+ final var clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).clear().setRoutingTable(true).get().getState();
// verify non-DEFAULT roles reported in cluster state XContent
assertRolesInRoutingTableXContent(clusterState);
@@ -440,7 +440,7 @@ public void testPromotion() {
@Nullable
public AllocationCommand getCancelPrimaryCommand() {
- final var indexRoutingTable = clusterAdmin().prepareState()
+ final var indexRoutingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setRoutingTable(true)
.get()
@@ -488,7 +488,7 @@ public void testSearchRouting() throws Exception {
assertEngineTypes();
final var searchShardProfileKeys = new HashSet();
- final var indexRoutingTable = clusterAdmin().prepareState()
+ final var indexRoutingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setRoutingTable(true)
.get()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/AllocationFailuresResetIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/AllocationFailuresResetIT.java
index 671c308f98fbb..6b97a8b6f3ad0 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/AllocationFailuresResetIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/AllocationFailuresResetIT.java
@@ -48,7 +48,7 @@ private void removeAllocationFailuresInjection(String node) {
private void awaitShardAllocMaxRetries() throws Exception {
var maxRetries = MaxRetryAllocationDecider.SETTING_ALLOCATION_MAX_RETRY.get(internalCluster().getDefaultSettings());
assertBusy(() -> {
- var state = clusterAdmin().prepareState().get().getState();
+ var state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
var index = state.getRoutingTable().index(INDEX);
assertNotNull(index);
var shard = index.shard(SHARD).primaryShard();
@@ -61,7 +61,7 @@ private void awaitShardAllocMaxRetries() throws Exception {
private void awaitShardAllocSucceed() throws Exception {
assertBusy(() -> {
- var state = clusterAdmin().prepareState().get().getState();
+ var state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
var index = state.getRoutingTable().index(INDEX);
assertNotNull(index);
var shard = index.shard(SHARD).primaryShard();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitorIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitorIT.java
index eb62ad5e6eec1..5509f46786a80 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitorIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitorIT.java
@@ -86,7 +86,7 @@ public void testFloodStageExceeded() throws Exception {
final String newDataNodeName = internalCluster().startDataOnlyNode();
final String newDataNodeId = clusterAdmin().prepareNodesInfo(newDataNodeName).get().getNodes().get(0).getNode().getId();
assertBusy(() -> {
- final ShardRouting primaryShard = clusterAdmin().prepareState()
+ final ShardRouting primaryShard = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setRoutingTable(true)
.setNodes(true)
@@ -103,7 +103,7 @@ public void testFloodStageExceeded() throws Exception {
// Verify that the block is removed once the shard migration is complete
refreshClusterInfo();
- assertFalse(clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).get().isTimedOut());
assertNull(getIndexBlock(indexName, IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE));
}
@@ -135,7 +135,7 @@ public void testRemoveExistingIndexBlocksWhenDiskThresholdMonitorIsDisabled() th
// Verify that the block is removed
refreshClusterInfo();
- assertFalse(clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).get().isTimedOut());
assertNull(getIndexBlock(indexName, IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE));
// Re-enable and the blocks should be back!
@@ -143,7 +143,7 @@ public void testRemoveExistingIndexBlocksWhenDiskThresholdMonitorIsDisabled() th
Settings.builder().put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true)
);
refreshClusterInfo();
- assertFalse(clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).get().isTimedOut());
assertThat(getIndexBlock(indexName, IndexMetadata.SETTING_READ_ONLY_ALLOW_DELETE), equalTo("true"));
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java
index e3b6f2ddba4c6..2f4b3588cf566 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java
@@ -28,7 +28,7 @@ public void testPrimaryFailureIncreasesTerm() throws Exception {
logger.info("--> disabling allocation to capture shard failure");
disableAllocation("test");
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final int shard = randomBoolean() ? 0 : 1;
final String nodeId = state.routingTable().index("test").shard(shard).primaryShard().currentNodeId();
final String node = state.nodes().get(nodeId).getName();
@@ -38,7 +38,12 @@ public void testPrimaryFailureIncreasesTerm() throws Exception {
logger.info("--> waiting for a yellow index");
// we can't use ensureYellow since that one is just as happy with a GREEN status.
- assertBusy(() -> assertThat(clusterAdmin().prepareHealth("test").get().getStatus(), equalTo(ClusterHealthStatus.YELLOW)));
+ assertBusy(
+ () -> assertThat(
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test").get().getStatus(),
+ equalTo(ClusterHealthStatus.YELLOW)
+ )
+ );
final long term0 = shard == 0 ? 2 : 1;
final long term1 = shard == 1 ? 2 : 1;
@@ -53,7 +58,7 @@ public void testPrimaryFailureIncreasesTerm() throws Exception {
protected void assertPrimaryTerms(long shard0Term, long shard1Term) {
for (String node : internalCluster().getNodeNames()) {
logger.debug("--> asserting primary terms terms on [{}]", node);
- ClusterState state = client(node).admin().cluster().prepareState().setLocal(true).get().getState();
+ ClusterState state = client(node).admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
IndexMetadata metadata = state.metadata().index("test");
assertThat(metadata.primaryTerm(0), equalTo(shard0Term));
assertThat(metadata.primaryTerm(1), equalTo(shard1Term));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java
index a1a29468cc5bd..106fd9530c3a5 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java
@@ -231,7 +231,7 @@ public void testRestoreSnapshotAllocationDoesNotExceedWatermarkWithMultipleShard
private Set getShardIds(final String nodeId, final String indexName) {
final Set shardIds = new HashSet<>();
- final IndexRoutingTable indexRoutingTable = clusterAdmin().prepareState()
+ final IndexRoutingTable indexRoutingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setRoutingTable(true)
.get()
@@ -319,7 +319,7 @@ private void refreshDiskUsage() {
}
assertFalse(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNoRelocatingShards(true)
.setWaitForNoInitializingShards(true)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java
index 7464f83cb2814..fd7e9f8fb3572 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java
@@ -75,7 +75,7 @@ public void testRerouteOccursOnDiskPassingHighWatermark() throws Exception {
internalCluster().startNode(Settings.builder().put(Environment.PATH_DATA_SETTING.getKey(), createTempDir()));
}
- final List nodeIds = clusterAdmin().prepareState()
+ final List nodeIds = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.getRoutingNodes()
@@ -153,7 +153,7 @@ public void testAutomaticReleaseOfIndexBlock() throws Exception {
internalCluster().startNode(Settings.builder().put(Environment.PATH_DATA_SETTING.getKey(), createTempDir()));
}
- final List nodeIds = clusterAdmin().prepareState()
+ final List nodeIds = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.getRoutingNodes()
@@ -211,7 +211,7 @@ public void testAutomaticReleaseOfIndexBlock() throws Exception {
() -> assertBlocked(prepareIndex("test").setId("1").setSource("foo", "bar"), IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK)
);
- assertFalse(clusterAdmin().prepareHealth("test").setWaitForEvents(Priority.LANGUID).get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test").setWaitForEvents(Priority.LANGUID).get().isTimedOut());
// Cannot add further documents
assertBlocked(prepareIndex("test").setId("2").setSource("foo", "bar"), IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK);
@@ -261,7 +261,7 @@ public void testOnlyMovesEnoughShardsToDropBelowHighWatermark() throws Exception
.put(CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING.getKey(), "0ms")
);
- final List nodeIds = clusterAdmin().prepareState()
+ final List nodeIds = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.getRoutingNodes()
@@ -318,7 +318,7 @@ public void testDoesNotExceedLowWatermarkWhenRebalancing() throws Exception {
final MockInternalClusterInfoService clusterInfoService = getMockInternalClusterInfoService();
- final List nodeIds = clusterAdmin().prepareState()
+ final List nodeIds = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.getRoutingNodes()
@@ -414,7 +414,7 @@ public void testMovesShardsOffSpecificDataPathAboveWatermark() throws Exception
.put(CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING.getKey(), "0ms")
);
- final List nodeIds = clusterAdmin().prepareState()
+ final List nodeIds = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.getRoutingNodes()
@@ -483,7 +483,7 @@ public void testMovesShardsOffSpecificDataPathAboveWatermark() throws Exception
private Map getShardCountByNodeId() {
final Map shardCountByNodeId = new HashMap<>();
- final ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ final ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
for (final RoutingNode node : clusterState.getRoutingNodes()) {
logger.info(
"----> node {} has {} shards",
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/UpdateShardAllocationSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/UpdateShardAllocationSettingsIT.java
index 921ed3265f1b6..be530f0bd4cb4 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/UpdateShardAllocationSettingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/UpdateShardAllocationSettingsIT.java
@@ -100,7 +100,7 @@ public void testUpdateSameHostSetting() {
updateClusterSettings(Settings.builder().put(CLUSTER_ROUTING_ALLOCATION_SAME_HOST_SETTING.getKey(), true));
final String indexName = "idx";
createIndex(indexName, 1, 1);
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertFalse(
"replica should be unassigned",
clusterState.getRoutingTable().index(indexName).shardsWithState(ShardRoutingState.UNASSIGNED).isEmpty()
@@ -109,7 +109,7 @@ public void testUpdateSameHostSetting() {
// the same host - the replica should get assigned
updateClusterSettings(Settings.builder().put(CLUSTER_ROUTING_ALLOCATION_SAME_HOST_SETTING.getKey(), false));
- clusterState = clusterAdmin().prepareState().get().getState();
+ clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertTrue(
"all shards should be assigned",
clusterState.getRoutingTable().index(indexName).shardsWithState(ShardRoutingState.UNASSIGNED).isEmpty()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java
index a142d594fe06e..a9767cce318d4 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java
@@ -43,7 +43,7 @@ public class ClusterSettingsIT extends ESIntegTestCase {
@After
public void cleanup() throws Exception {
assertAcked(
- clusterAdmin().prepareUpdateSettings()
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().putNull("*"))
.setTransientSettings(Settings.builder().putNull("*"))
);
@@ -64,7 +64,7 @@ private void testClusterNonExistingSettingsUpdate(
String key1 = "no_idea_what_you_are_talking_about";
int value1 = 10;
try {
- ClusterUpdateSettingsRequestBuilder builder = clusterAdmin().prepareUpdateSettings();
+ ClusterUpdateSettingsRequestBuilder builder = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT);
consumer.accept(Settings.builder().put(key1, value1), builder);
builder.get();
@@ -95,7 +95,7 @@ private void testDeleteIsAppliedFirst(
final Setting INITIAL_RECOVERIES = CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING;
final Setting REROUTE_INTERVAL = CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING;
- ClusterUpdateSettingsRequestBuilder builder = clusterAdmin().prepareUpdateSettings();
+ ClusterUpdateSettingsRequestBuilder builder = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT);
consumer.accept(Settings.builder().put(INITIAL_RECOVERIES.getKey(), 7).put(REROUTE_INTERVAL.getKey(), "42s"), builder);
ClusterUpdateSettingsResponse response = builder.get();
@@ -106,7 +106,7 @@ private void testDeleteIsAppliedFirst(
assertThat(REROUTE_INTERVAL.get(settingsFunction.apply(response)), equalTo(TimeValue.timeValueSeconds(42)));
assertThat(clusterService().getClusterSettings().get(REROUTE_INTERVAL), equalTo(TimeValue.timeValueSeconds(42)));
- ClusterUpdateSettingsRequestBuilder undoBuilder = clusterAdmin().prepareUpdateSettings();
+ ClusterUpdateSettingsRequestBuilder undoBuilder = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT);
consumer.accept(
Settings.builder().putNull((randomBoolean() ? "cluster.routing.*" : "*")).put(REROUTE_INTERVAL.getKey(), "43s"),
undoBuilder
@@ -124,7 +124,7 @@ public void testResetClusterTransientSetting() {
final Setting INITIAL_RECOVERIES = CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING;
final Setting REROUTE_INTERVAL = CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING;
- ClusterUpdateSettingsResponse response = clusterAdmin().prepareUpdateSettings()
+ ClusterUpdateSettingsResponse response = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setTransientSettings(Settings.builder().put(INITIAL_RECOVERIES.getKey(), 7).build())
.get();
@@ -132,7 +132,7 @@ public void testResetClusterTransientSetting() {
assertThat(INITIAL_RECOVERIES.get(response.getTransientSettings()), equalTo(7));
assertThat(clusterService().getClusterSettings().get(INITIAL_RECOVERIES), equalTo(7));
- response = clusterAdmin().prepareUpdateSettings()
+ response = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setTransientSettings(Settings.builder().putNull(INITIAL_RECOVERIES.getKey()))
.get();
@@ -140,7 +140,7 @@ public void testResetClusterTransientSetting() {
assertNull(response.getTransientSettings().get(INITIAL_RECOVERIES.getKey()));
assertThat(clusterService().getClusterSettings().get(INITIAL_RECOVERIES), equalTo(INITIAL_RECOVERIES.get(Settings.EMPTY)));
- response = clusterAdmin().prepareUpdateSettings()
+ response = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setTransientSettings(Settings.builder().put(INITIAL_RECOVERIES.getKey(), 8).put(REROUTE_INTERVAL.getKey(), "43s").build())
.get();
@@ -149,7 +149,7 @@ public void testResetClusterTransientSetting() {
assertThat(clusterService().getClusterSettings().get(INITIAL_RECOVERIES), equalTo(8));
assertThat(REROUTE_INTERVAL.get(response.getTransientSettings()), equalTo(TimeValue.timeValueSeconds(43)));
assertThat(clusterService().getClusterSettings().get(REROUTE_INTERVAL), equalTo(TimeValue.timeValueSeconds(43)));
- response = clusterAdmin().prepareUpdateSettings()
+ response = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setTransientSettings(Settings.builder().putNull((randomBoolean() ? "cluster.routing.*" : "*")))
.get();
@@ -164,7 +164,7 @@ public void testResetClusterPersistentSetting() {
final Setting INITIAL_RECOVERIES = CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING;
final Setting REROUTE_INTERVAL = CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING;
- ClusterUpdateSettingsResponse response = clusterAdmin().prepareUpdateSettings()
+ ClusterUpdateSettingsResponse response = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().put(INITIAL_RECOVERIES.getKey(), 9).build())
.get();
@@ -172,7 +172,7 @@ public void testResetClusterPersistentSetting() {
assertThat(INITIAL_RECOVERIES.get(response.getPersistentSettings()), equalTo(9));
assertThat(clusterService().getClusterSettings().get(INITIAL_RECOVERIES), equalTo(9));
- response = clusterAdmin().prepareUpdateSettings()
+ response = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().putNull(INITIAL_RECOVERIES.getKey()))
.get();
@@ -180,7 +180,7 @@ public void testResetClusterPersistentSetting() {
assertThat(INITIAL_RECOVERIES.get(response.getPersistentSettings()), equalTo(INITIAL_RECOVERIES.get(Settings.EMPTY)));
assertThat(clusterService().getClusterSettings().get(INITIAL_RECOVERIES), equalTo(INITIAL_RECOVERIES.get(Settings.EMPTY)));
- response = clusterAdmin().prepareUpdateSettings()
+ response = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().put(INITIAL_RECOVERIES.getKey(), 10).put(REROUTE_INTERVAL.getKey(), "44s").build())
.get();
@@ -189,7 +189,7 @@ public void testResetClusterPersistentSetting() {
assertThat(clusterService().getClusterSettings().get(INITIAL_RECOVERIES), equalTo(10));
assertThat(REROUTE_INTERVAL.get(response.getPersistentSettings()), equalTo(TimeValue.timeValueSeconds(44)));
assertThat(clusterService().getClusterSettings().get(REROUTE_INTERVAL), equalTo(TimeValue.timeValueSeconds(44)));
- response = clusterAdmin().prepareUpdateSettings()
+ response = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().putNull((randomBoolean() ? "cluster.routing.*" : "*")))
.get();
@@ -209,7 +209,7 @@ public void testClusterSettingsUpdateResponse() {
Settings transientSettings1 = Settings.builder().put(key1, value1, ByteSizeUnit.BYTES).build();
Settings persistentSettings1 = Settings.builder().put(key2, value2).build();
- ClusterUpdateSettingsResponse response1 = clusterAdmin().prepareUpdateSettings()
+ ClusterUpdateSettingsResponse response1 = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setTransientSettings(transientSettings1)
.setPersistentSettings(persistentSettings1)
.get();
@@ -223,7 +223,7 @@ public void testClusterSettingsUpdateResponse() {
Settings transientSettings2 = Settings.builder().put(key1, value1, ByteSizeUnit.BYTES).put(key2, value2).build();
Settings persistentSettings2 = Settings.EMPTY;
- ClusterUpdateSettingsResponse response2 = clusterAdmin().prepareUpdateSettings()
+ ClusterUpdateSettingsResponse response2 = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setTransientSettings(transientSettings2)
.setPersistentSettings(persistentSettings2)
.get();
@@ -237,7 +237,7 @@ public void testClusterSettingsUpdateResponse() {
Settings transientSettings3 = Settings.EMPTY;
Settings persistentSettings3 = Settings.builder().put(key1, value1, ByteSizeUnit.BYTES).put(key2, value2).build();
- ClusterUpdateSettingsResponse response3 = clusterAdmin().prepareUpdateSettings()
+ ClusterUpdateSettingsResponse response3 = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setTransientSettings(transientSettings3)
.setPersistentSettings(persistentSettings3)
.get();
@@ -267,7 +267,7 @@ private void testCanUpdateTracerSettings(
final BiConsumer consumer,
final Function settingsFunction
) {
- ClusterUpdateSettingsRequestBuilder builder = clusterAdmin().prepareUpdateSettings();
+ ClusterUpdateSettingsRequestBuilder builder = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT);
consumer.accept(
Settings.builder().putList("transport.tracer.include", "internal:index/shard/recovery/*", "internal:gateway/local*"),
builder
@@ -300,7 +300,10 @@ private void testUpdateSettings(
) {
final Setting INITIAL_RECOVERIES = CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING;
- ClusterUpdateSettingsRequestBuilder initialBuilder = clusterAdmin().prepareUpdateSettings();
+ ClusterUpdateSettingsRequestBuilder initialBuilder = clusterAdmin().prepareUpdateSettings(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT
+ );
consumer.accept(Settings.builder().put(INITIAL_RECOVERIES.getKey(), 42), initialBuilder);
ClusterUpdateSettingsResponse response = initialBuilder.get();
@@ -310,7 +313,10 @@ private void testUpdateSettings(
assertThat(clusterService().getClusterSettings().get(INITIAL_RECOVERIES), equalTo(42));
try {
- ClusterUpdateSettingsRequestBuilder badBuilder = clusterAdmin().prepareUpdateSettings();
+ ClusterUpdateSettingsRequestBuilder badBuilder = clusterAdmin().prepareUpdateSettings(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT
+ );
consumer.accept(Settings.builder().put(INITIAL_RECOVERIES.getKey(), "whatever"), badBuilder);
badBuilder.get();
fail("bogus value");
@@ -321,7 +327,10 @@ private void testUpdateSettings(
assertThat(clusterService().getClusterSettings().get(INITIAL_RECOVERIES), equalTo(42));
try {
- ClusterUpdateSettingsRequestBuilder badBuilder = clusterAdmin().prepareUpdateSettings();
+ ClusterUpdateSettingsRequestBuilder badBuilder = clusterAdmin().prepareUpdateSettings(
+ TEST_REQUEST_TIMEOUT,
+ TEST_REQUEST_TIMEOUT
+ );
consumer.accept(Settings.builder().put(INITIAL_RECOVERIES.getKey(), -1), badBuilder);
badBuilder.get();
fail("bogus value");
@@ -346,9 +355,13 @@ private void testRemoveArchiveSettingsWithBlocks(boolean readOnly, boolean readO
if (readOnlyAllowDelete) {
settingsBuilder.put(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey(), "true");
}
- assertAcked(clusterAdmin().prepareUpdateSettings().setPersistentSettings(settingsBuilder).setTransientSettings(settingsBuilder));
+ assertAcked(
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(settingsBuilder)
+ .setTransientSettings(settingsBuilder)
+ );
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
if (readOnly) {
assertTrue(Metadata.SETTING_READ_ONLY_SETTING.get(state.getMetadata().transientSettings()));
assertTrue(Metadata.SETTING_READ_ONLY_SETTING.get(state.getMetadata().persistentSettings()));
@@ -365,7 +378,7 @@ private void testRemoveArchiveSettingsWithBlocks(boolean readOnly, boolean readO
.build();
restartNodesOnBrokenClusterState(ClusterState.builder(state).metadata(brokenMeta));
ensureGreen(); // wait for state recovery
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertTrue(state.getMetadata().persistentSettings().getAsBoolean("archived.this.is.unknown", false));
// cannot remove read only block due to archived settings
@@ -375,7 +388,9 @@ private void testRemoveArchiveSettingsWithBlocks(boolean readOnly, boolean readO
clearOrSetFalse(builder, readOnlyAllowDelete, Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING);
final IllegalArgumentException e1 = expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings().setPersistentSettings(builder).setTransientSettings(builder)
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(builder)
+ .setTransientSettings(builder)
);
assertTrue(e1.getMessage().contains("unknown setting [archived.this.is.unknown]"));
}
@@ -383,7 +398,7 @@ private void testRemoveArchiveSettingsWithBlocks(boolean readOnly, boolean readO
// fail to clear archived settings with non-archived settings
final ClusterBlockException e2 = expectThrows(
ClusterBlockException.class,
- clusterAdmin().prepareUpdateSettings()
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().putNull("cluster.routing.allocation.enable"))
.setTransientSettings(Settings.builder().putNull("archived.*"))
);
@@ -397,7 +412,8 @@ private void testRemoveArchiveSettingsWithBlocks(boolean readOnly, boolean readO
// fail to clear archived settings due to cluster read only block
final ClusterBlockException e3 = expectThrows(
ClusterBlockException.class,
- clusterAdmin().prepareUpdateSettings().setPersistentSettings(Settings.builder().putNull("archived.*"))
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(Settings.builder().putNull("archived.*"))
);
if (readOnly) {
assertTrue(e3.getMessage().contains("cluster read-only (api)"));
@@ -419,7 +435,7 @@ private void testRemoveArchiveSettingsWithBlocks(boolean readOnly, boolean readO
}
final ClusterBlockException e4 = expectThrows(
ClusterBlockException.class,
- clusterAdmin().prepareUpdateSettings().setPersistentSettings(builder)
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT).setPersistentSettings(builder)
);
if (readOnly) {
assertTrue(e4.getMessage().contains("cluster read-only (api)"));
@@ -436,7 +452,7 @@ private void testRemoveArchiveSettingsWithBlocks(boolean readOnly, boolean readO
clearOrSetFalse(builder, readOnlyAllowDelete, Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING);
final ClusterBlockException e5 = expectThrows(
ClusterBlockException.class,
- clusterAdmin().prepareUpdateSettings().setPersistentSettings(builder)
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT).setPersistentSettings(builder)
);
if (readOnly) {
assertTrue(e5.getMessage().contains("cluster read-only (api)"));
@@ -450,9 +466,14 @@ private void testRemoveArchiveSettingsWithBlocks(boolean readOnly, boolean readO
Settings.Builder builder = Settings.builder().putNull("archived.*");
clearOrSetFalse(builder, readOnly, Metadata.SETTING_READ_ONLY_SETTING);
clearOrSetFalse(builder, readOnlyAllowDelete, Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING);
- assertAcked(clusterAdmin().prepareUpdateSettings().setPersistentSettings(builder).setTransientSettings(builder).get());
+ assertAcked(
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(builder)
+ .setTransientSettings(builder)
+ .get()
+ );
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertFalse(Metadata.SETTING_READ_ONLY_SETTING.get(state.getMetadata().transientSettings()));
assertFalse(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.get(state.getMetadata().transientSettings()));
assertFalse(Metadata.SETTING_READ_ONLY_SETTING.get(state.getMetadata().persistentSettings()));
@@ -477,7 +498,7 @@ public void testClusterUpdateSettingsWithBlocks() {
String key2 = "cluster.routing.allocation.node_concurrent_recoveries";
Settings persistentSettings = Settings.builder().put(key2, "5").build();
- ClusterUpdateSettingsRequestBuilder request = clusterAdmin().prepareUpdateSettings()
+ ClusterUpdateSettingsRequestBuilder request = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setTransientSettings(transientSettings)
.setPersistentSettings(persistentSettings);
@@ -488,7 +509,9 @@ public void testClusterUpdateSettingsWithBlocks() {
// But it's possible to update the settings to update the "cluster.blocks.read_only" setting
Settings settings = Settings.builder().putNull(Metadata.SETTING_READ_ONLY_SETTING.getKey()).build();
- assertAcked(clusterAdmin().prepareUpdateSettings().setTransientSettings(settings).get());
+ assertAcked(
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT).setTransientSettings(settings).get()
+ );
} finally {
setClusterReadOnly(false);
@@ -498,12 +521,14 @@ public void testClusterUpdateSettingsWithBlocks() {
try {
// But it's possible to update the settings to update the "cluster.blocks.read_only" setting
Settings settings = Settings.builder().put(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey(), true).build();
- assertAcked(clusterAdmin().prepareUpdateSettings().setTransientSettings(settings).get());
+ assertAcked(
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT).setTransientSettings(settings).get()
+ );
assertBlocked(request, Metadata.CLUSTER_READ_ONLY_ALLOW_DELETE_BLOCK);
} finally {
// But it's possible to update the settings to update the "cluster.blocks.read_only" setting
Settings s = Settings.builder().putNull(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey()).build();
- assertAcked(clusterAdmin().prepareUpdateSettings().setTransientSettings(s).get());
+ assertAcked(clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT).setTransientSettings(s).get());
}
// It should work now
@@ -541,7 +566,7 @@ private void testLoggerLevelUpdate(final BiConsumer updating cluster settings");
var future = client(masterNode).admin()
.cluster()
- .prepareUpdateSettings()
+ .prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().put(BlockingClusterSettingTestPlugin.TEST_BLOCKING_SETTING.getKey(), true).build())
.setMasterNodeTimeout(TimeValue.timeValueMillis(100L))
.execute();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterSearchShardsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterSearchShardsIT.java
index 895bd6932fdb9..7e9406dfcf09a 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterSearchShardsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterSearchShardsIT.java
@@ -88,7 +88,7 @@ public void testMultipleIndicesAllocation() {
.addAliasAction(AliasActions.add().index("test1").alias("routing_alias").routing("ABC"))
.addAliasAction(AliasActions.add().index("test2").alias("routing_alias").routing("EFG"))
.get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
ClusterSearchShardsResponse response = safeExecute(new ClusterSearchShardsRequest(TEST_REQUEST_TIMEOUT, "routing_alias"));
assertThat(response.getGroups().length, equalTo(2));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java
index 31dd002a6af7d..7a66cb3abb7cd 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java
@@ -49,11 +49,11 @@ public void testMinimumPerNode() {
int negativeShardsPerNode = between(-50_000, 0);
try {
if (frequently()) {
- clusterAdmin().prepareUpdateSettings()
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().put(shardsPerNodeKey, negativeShardsPerNode).build())
.get();
} else {
- clusterAdmin().prepareUpdateSettings()
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().put(shardsPerNodeKey, negativeShardsPerNode).build())
.get();
}
@@ -67,7 +67,7 @@ public void testMinimumPerNode() {
}
public void testIndexCreationOverLimit() {
- int dataNodes = clusterAdmin().prepareState().get().getState().getNodes().getDataNodes().size();
+ int dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getNodes().getDataNodes().size();
ShardCounts counts = ShardCounts.forDataNodeCount(dataNodes);
@@ -95,12 +95,12 @@ public void testIndexCreationOverLimit() {
} catch (IllegalArgumentException e) {
verifyException(dataNodes, counts, e);
}
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertFalse(clusterState.getMetadata().hasIndex("should-fail"));
}
public void testIndexCreationOverLimitFromTemplate() {
- int dataNodes = clusterAdmin().prepareState().get().getState().getNodes().getDataNodes().size();
+ int dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getNodes().getDataNodes().size();
final ShardCounts counts = ShardCounts.forDataNodeCount(dataNodes);
@@ -126,12 +126,12 @@ public void testIndexCreationOverLimitFromTemplate() {
final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, indicesAdmin().prepareCreate("should-fail"));
verifyException(dataNodes, counts, e);
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertFalse(clusterState.getMetadata().hasIndex("should-fail"));
}
public void testIncreaseReplicasOverLimit() {
- int dataNodes = clusterAdmin().prepareState().get().getState().getNodes().getDataNodes().size();
+ int dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getNodes().getDataNodes().size();
dataNodes = ensureMultipleDataNodes(dataNodes);
@@ -158,12 +158,12 @@ public void testIncreaseReplicasOverLimit() {
+ ";";
assertEquals(expectedError, e.getMessage());
}
- Metadata clusterState = clusterAdmin().prepareState().get().getState().metadata();
+ Metadata clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata();
assertEquals(0, clusterState.index("growing-should-fail").getNumberOfReplicas());
}
public void testChangingMultipleIndicesOverLimit() {
- int dataNodes = clusterAdmin().prepareState().get().getState().getNodes().getDataNodes().size();
+ int dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getNodes().getDataNodes().size();
dataNodes = ensureMultipleDataNodes(dataNodes);
@@ -219,13 +219,13 @@ public void testChangingMultipleIndicesOverLimit() {
+ ";";
assertEquals(expectedError, e.getMessage());
}
- Metadata clusterState = clusterAdmin().prepareState().get().getState().metadata();
+ Metadata clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata();
assertEquals(firstIndexReplicas, clusterState.index("test-1-index").getNumberOfReplicas());
assertEquals(secondIndexReplicas, clusterState.index("test-2-index").getNumberOfReplicas());
}
public void testPreserveExistingSkipsCheck() {
- int dataNodes = clusterAdmin().prepareState().get().getState().getNodes().getDataNodes().size();
+ int dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getNodes().getDataNodes().size();
dataNodes = ensureMultipleDataNodes(dataNodes);
@@ -245,7 +245,7 @@ public void testPreserveExistingSkipsCheck() {
.setPreserveExisting(true)
.setSettings(Settings.builder().put("number_of_replicas", dataNodes))
);
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertEquals(0, clusterState.getMetadata().index("test-index").getNumberOfReplicas());
}
@@ -266,7 +266,7 @@ public void testRestoreSnapshotOverLimit() {
.setSettings(repoSettings.build())
);
- int dataNodes = clusterAdmin().prepareState().get().getState().getNodes().getDataNodes().size();
+ int dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getNodes().getDataNodes().size();
ShardCounts counts = ShardCounts.forDataNodeCount(dataNodes);
createIndex(
"snapshot-index",
@@ -330,13 +330,13 @@ public void testRestoreSnapshotOverLimit() {
verifyException(dataNodes, counts, e);
}
ensureGreen();
- ClusterState clusterState = client.admin().cluster().prepareState().get().getState();
+ ClusterState clusterState = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertFalse(clusterState.getMetadata().hasIndex("snapshot-index"));
}
public void testOpenIndexOverLimit() {
Client client = client();
- int dataNodes = clusterAdmin().prepareState().get().getState().getNodes().getDataNodes().size();
+ int dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getNodes().getDataNodes().size();
ShardCounts counts = ShardCounts.forDataNodeCount(dataNodes);
createIndex(
@@ -348,7 +348,7 @@ public void testOpenIndexOverLimit() {
.build()
);
- ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertFalse(healthResponse.isTimedOut());
AcknowledgedResponse closeIndexResponse = client.admin().indices().prepareClose("test-index-1").get();
@@ -371,7 +371,7 @@ public void testOpenIndexOverLimit() {
} catch (IllegalArgumentException e) {
verifyException(dataNodes, counts, e);
}
- ClusterState clusterState = client.admin().cluster().prepareState().get().getState();
+ ClusterState clusterState = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertFalse(clusterState.getMetadata().hasIndex("snapshot-index"));
}
@@ -379,17 +379,22 @@ private int ensureMultipleDataNodes(int dataNodes) {
if (dataNodes == 1) {
internalCluster().startNode(dataNode());
assertThat(
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes(">=2").setLocal(true).get().isTimedOut(),
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForEvents(Priority.LANGUID)
+ .setWaitForNodes(">=2")
+ .setLocal(true)
+ .get()
+ .isTimedOut(),
equalTo(false)
);
- dataNodes = clusterAdmin().prepareState().get().getState().getNodes().getDataNodes().size();
+ dataNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getNodes().getDataNodes().size();
}
return dataNodes;
}
private void setShardsPerNode(int shardsPerNode) {
try {
- ClusterUpdateSettingsResponse response = clusterAdmin().prepareUpdateSettings()
+ ClusterUpdateSettingsResponse response = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().put(shardsPerNodeKey, shardsPerNode).build())
.get();
assertEquals(shardsPerNode, response.getPersistentSettings().getAsInt(shardsPerNodeKey, -1).intValue());
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/discovery/ClusterDisruptionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/discovery/ClusterDisruptionIT.java
index a0fa63aa58ab5..6ae7e0f7e84e5 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/discovery/ClusterDisruptionIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/discovery/ClusterDisruptionIT.java
@@ -293,7 +293,14 @@ public void testRejoinDocumentExistsInAllShardCopies() throws Exception {
NetworkDisruption scheme = addRandomDisruptionType(partitions);
scheme.startDisrupting();
ensureStableCluster(2, notIsolatedNode);
- assertFalse(client(notIsolatedNode).admin().cluster().prepareHealth("test").setWaitForYellowStatus().get().isTimedOut());
+ assertFalse(
+ client(notIsolatedNode).admin()
+ .cluster()
+ .prepareHealth(TEST_REQUEST_TIMEOUT, "test")
+ .setWaitForYellowStatus()
+ .get()
+ .isTimedOut()
+ );
DocWriteResponse indexResponse = internalCluster().client(notIsolatedNode).prepareIndex("test").setSource("field", "value").get();
assertThat(indexResponse.getVersion(), equalTo(1L));
@@ -424,12 +431,12 @@ public boolean validateClusterForming() {
});
assertBusy(() -> {
- assertFalse(internalCluster().client(masterNode).admin().cluster().prepareHealth().get().isTimedOut());
+ assertFalse(internalCluster().client(masterNode).admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).get().isTimedOut());
assertTrue(
internalCluster().client(masterNode)
.admin()
.cluster()
- .prepareHealth()
+ .prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForNodes("2")
.setTimeout(TimeValue.timeValueSeconds(2))
.get()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/discovery/DiscoveryDisruptionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/discovery/DiscoveryDisruptionIT.java
index cad5c8f524bc7..b512f369c76d5 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/discovery/DiscoveryDisruptionIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/discovery/DiscoveryDisruptionIT.java
@@ -145,7 +145,7 @@ public void testElectMasterWithLatestVersion() throws Exception {
isolateAllNodes.stopDisrupting();
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
if (state.metadata().hasIndex("test") == false) {
fail("index 'test' was lost. current cluster state: " + state);
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/discovery/StableMasterDisruptionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/discovery/StableMasterDisruptionIT.java
index f8bdf17e2cec8..601266b50d237 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/discovery/StableMasterDisruptionIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/discovery/StableMasterDisruptionIT.java
@@ -158,7 +158,13 @@ private String xContentToString(ChunkedToXContent xContent) throws IOException {
private void ensureNoMaster(String node) throws Exception {
assertBusy(
() -> assertNull(
- client(node).admin().cluster().state(new ClusterStateRequest().local(true)).get().getState().nodes().getMasterNode()
+ client(node).admin()
+ .cluster()
+ .state(new ClusterStateRequest(TEST_REQUEST_TIMEOUT).local(true))
+ .get()
+ .getState()
+ .nodes()
+ .getMasterNode()
)
);
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/document/ShardInfoIT.java b/server/src/internalClusterTest/java/org/elasticsearch/document/ShardInfoIT.java
index 3aa97f79a82da..eeda0257fb0e4 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/document/ShardInfoIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/document/ShardInfoIT.java
@@ -113,12 +113,14 @@ private void assertShardInfo(ReplicationResponse response, int expectedTotal, in
private void ensureActiveShardCopies(final int shardId, final int copyCount) throws Exception {
assertBusy(() -> {
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.routingTable().index("idx"), not(nullValue()));
assertThat(state.routingTable().index("idx").shard(shardId), not(nullValue()));
assertThat(state.routingTable().index("idx").shard(shardId).activeShards().size(), equalTo(copyCount));
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth("idx").setWaitForNoRelocatingShards(true).get();
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "idx")
+ .setWaitForNoRelocatingShards(true)
+ .get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
RecoveryResponse recoveryResponse = indicesAdmin().prepareRecoveries("idx").setActiveOnly(true).get();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/env/NodeEnvironmentIT.java b/server/src/internalClusterTest/java/org/elasticsearch/env/NodeEnvironmentIT.java
index 8c6abc3e14cd8..00a4f170cf7eb 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/env/NodeEnvironmentIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/env/NodeEnvironmentIT.java
@@ -153,7 +153,7 @@ public void testUpgradeDataFolder() throws IOException, InterruptedException {
String node = internalCluster().startNode();
prepareCreate("test").get();
indexRandom(true, prepareIndex("test").setId("1").setSource("{}", XContentType.JSON));
- String nodeId = clusterAdmin().prepareState().get().getState().nodes().getMasterNodeId();
+ String nodeId = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getMasterNodeId();
final Settings dataPathSettings = internalCluster().dataPathSettings(node);
internalCluster().stopRandomDataNode();
@@ -235,7 +235,7 @@ public void testUpgradeDataFolder() throws IOException, InterruptedException {
dataPaths.forEach(path -> assertTrue(Files.isDirectory(path.resolve("nodes"))));
internalCluster().startNode(dataPathSettings);
dataPaths.forEach(path -> assertTrue(Files.isRegularFile(path.resolve("nodes"))));
- assertEquals(nodeId, clusterAdmin().prepareState().get().getState().nodes().getMasterNodeId());
+ assertEquals(nodeId, clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getMasterNodeId());
assertTrue(indexExists("test"));
ensureYellow("test");
assertHitCount(prepareSearch().setQuery(matchAllQuery()), 1L);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/features/ClusterFeaturesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/features/ClusterFeaturesIT.java
index 24bf198b7b42f..a695c46bcbfa2 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/features/ClusterFeaturesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/features/ClusterFeaturesIT.java
@@ -32,7 +32,7 @@ public void testClusterHasFeatures() {
assertThat(service.getNodeFeatures(), hasKey(FeatureService.FEATURES_SUPPORTED.id()));
// check the nodes all have a feature in their cluster state (there should always be features_supported)
- var response = clusterAdmin().state(new ClusterStateRequest().clear().nodes(true)).actionGet();
+ var response = clusterAdmin().state(new ClusterStateRequest(TEST_REQUEST_TIMEOUT).clear().nodes(true)).actionGet();
var features = response.getState().clusterFeatures().nodeFeatures();
Set missing = features.entrySet()
.stream()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/gateway/GatewayIndexStateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/gateway/GatewayIndexStateIT.java
index e05bda69d2c9c..92c1e9729b460 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/gateway/GatewayIndexStateIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/gateway/GatewayIndexStateIT.java
@@ -92,7 +92,7 @@ public void testMappingMetadataParsed() throws Exception {
.get();
logger.info("--> verify meta _routing required exists");
- MappingMetadata mappingMd = clusterAdmin().prepareState().get().getState().metadata().index("test").mapping();
+ MappingMetadata mappingMd = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test").mapping();
assertThat(mappingMd.routingRequired(), equalTo(true));
logger.info("--> restarting nodes...");
@@ -102,7 +102,7 @@ public void testMappingMetadataParsed() throws Exception {
ensureYellow();
logger.info("--> verify meta _routing required exists");
- mappingMd = clusterAdmin().prepareState().get().getState().metadata().index("test").mapping();
+ mappingMd = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test").mapping();
assertThat(mappingMd.routingRequired(), equalTo(true));
}
@@ -118,7 +118,7 @@ public void testSimpleOpenClose() throws Exception {
logger.info("--> waiting for green status");
ensureGreen();
- ClusterStateResponse stateResponse = clusterAdmin().prepareState().get();
+ ClusterStateResponse stateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(stateResponse.getState().metadata().index("test").getState(), equalTo(IndexMetadata.State.OPEN));
assertThat(stateResponse.getState().routingTable().index("test").size(), equalTo(test.numPrimaries));
assertThat(
@@ -132,7 +132,7 @@ public void testSimpleOpenClose() throws Exception {
logger.info("--> closing test index...");
assertAcked(indicesAdmin().prepareClose("test"));
- stateResponse = clusterAdmin().prepareState().get();
+ stateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(stateResponse.getState().metadata().index("test").getState(), equalTo(IndexMetadata.State.CLOSE));
assertThat(stateResponse.getState().routingTable().index("test"), notNullValue());
@@ -158,7 +158,7 @@ public void testSimpleOpenClose() throws Exception {
logger.info("--> verifying that the state is green");
ensureGreen();
- stateResponse = clusterAdmin().prepareState().get();
+ stateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(stateResponse.getState().metadata().index("test").getState(), equalTo(IndexMetadata.State.OPEN));
assertThat(stateResponse.getState().routingTable().index("test").size(), equalTo(test.numPrimaries));
assertThat(
@@ -172,7 +172,7 @@ public void testSimpleOpenClose() throws Exception {
logger.info("--> closing test index...");
assertAcked(indicesAdmin().prepareClose("test"));
- stateResponse = clusterAdmin().prepareState().get();
+ stateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(stateResponse.getState().metadata().index("test").getState(), equalTo(IndexMetadata.State.CLOSE));
assertThat(stateResponse.getState().routingTable().index("test"), notNullValue());
@@ -181,7 +181,7 @@ public void testSimpleOpenClose() throws Exception {
logger.info("--> waiting for two nodes and green status");
ensureGreen();
- stateResponse = clusterAdmin().prepareState().get();
+ stateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(stateResponse.getState().metadata().index("test").getState(), equalTo(IndexMetadata.State.CLOSE));
assertThat(stateResponse.getState().routingTable().index("test"), notNullValue());
@@ -199,7 +199,7 @@ public void testSimpleOpenClose() throws Exception {
logger.info("--> waiting for green status");
ensureGreen();
- stateResponse = clusterAdmin().prepareState().get();
+ stateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(stateResponse.getState().metadata().index("test").getState(), equalTo(IndexMetadata.State.OPEN));
assertThat(stateResponse.getState().routingTable().index("test").size(), equalTo(test.numPrimaries));
assertThat(
@@ -233,11 +233,14 @@ public Settings onNodeStopped(String nodeName) {
});
logger.info("--> waiting for test index to be created");
- ClusterHealthResponse health = clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setIndices("test").get();
+ ClusterHealthResponse health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForEvents(Priority.LANGUID)
+ .setIndices("test")
+ .get();
assertThat(health.isTimedOut(), equalTo(false));
logger.info("--> verify we have an index");
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().setIndices("test").get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setIndices("test").get();
assertThat(clusterStateResponse.getState().metadata().hasIndex("test"), equalTo(true));
}
@@ -264,7 +267,7 @@ public void testTwoNodesSingleDoc() throws Exception {
prepareIndex("test").setId("1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get();
logger.info("--> waiting for green status");
- ClusterHealthResponse health = clusterAdmin().prepareHealth()
+ ClusterHealthResponse health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForNodes("2")
@@ -279,7 +282,7 @@ public void testTwoNodesSingleDoc() throws Exception {
logger.info("--> closing test index...");
assertAcked(indicesAdmin().prepareClose("test"));
- ClusterStateResponse stateResponse = clusterAdmin().prepareState().get();
+ ClusterStateResponse stateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(stateResponse.getState().metadata().index("test").getState(), equalTo(IndexMetadata.State.CLOSE));
assertThat(stateResponse.getState().routingTable().index("test"), notNullValue());
@@ -287,7 +290,11 @@ public void testTwoNodesSingleDoc() throws Exception {
indicesAdmin().prepareOpen("test").get();
logger.info("--> waiting for green status");
- health = clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("2").get();
+ health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForEvents(Priority.LANGUID)
+ .setWaitForGreenStatus()
+ .setWaitForNodes("2")
+ .get();
assertThat(health.isTimedOut(), equalTo(false));
logger.info("--> verify 1 doc in the index");
@@ -337,7 +344,8 @@ public Settings onNodeStopped(final String nodeName) throws Exception {
logger.info("--> wait until all nodes are back online");
clusterAdmin().health(
- new ClusterHealthRequest(new String[] {}).waitForEvents(Priority.LANGUID).waitForNodes(Integer.toString(numNodes))
+ new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, new String[] {}).waitForEvents(Priority.LANGUID)
+ .waitForNodes(Integer.toString(numNodes))
).actionGet();
logger.info("--> waiting for green status");
@@ -372,13 +380,13 @@ public void testRecoverBrokenIndexMetadata() throws Exception {
} else {
internalCluster().startNode();
clusterAdmin().health(
- new ClusterHealthRequest(new String[] {}).waitForGreenStatus()
+ new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, new String[] {}).waitForGreenStatus()
.waitForEvents(Priority.LANGUID)
.waitForNoRelocatingShards(true)
.waitForNodes("2")
).actionGet();
}
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexMetadata metadata = state.getMetadata().index("test");
final IndexMetadata.Builder brokenMeta = IndexMetadata.builder(metadata)
@@ -395,7 +403,7 @@ public void testRecoverBrokenIndexMetadata() throws Exception {
// check that the cluster does not keep reallocating shards
assertBusy(() -> {
- final RoutingTable routingTable = clusterAdmin().prepareState().get().getState().routingTable();
+ final RoutingTable routingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().routingTable();
final IndexRoutingTable indexRoutingTable = routingTable.index("test");
assertNotNull(indexRoutingTable);
for (int i = 0; i < indexRoutingTable.size(); i++) {
@@ -410,7 +418,7 @@ public void testRecoverBrokenIndexMetadata() throws Exception {
}, 60, TimeUnit.SECONDS);
indicesAdmin().prepareClose("test").get();
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertEquals(IndexMetadata.State.CLOSE, state.getMetadata().index(metadata.getIndex()).getState());
assertEquals("boolean", state.getMetadata().index(metadata.getIndex()).getSettings().get("archived.index.similarity.BM25.type"));
// try to open it with the broken setting - fail again!
@@ -449,13 +457,13 @@ public void testRecoverMissingAnalyzer() throws Exception {
} else {
internalCluster().startNode();
clusterAdmin().health(
- new ClusterHealthRequest(new String[] {}).waitForGreenStatus()
+ new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, new String[] {}).waitForGreenStatus()
.waitForEvents(Priority.LANGUID)
.waitForNoRelocatingShards(true)
.waitForNodes("2")
).actionGet();
}
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexMetadata metadata = state.getMetadata().index("test");
final IndexMetadata.Builder brokenMeta = IndexMetadata.builder(metadata)
@@ -464,7 +472,7 @@ public void testRecoverMissingAnalyzer() throws Exception {
// check that the cluster does not keep reallocating shards
assertBusy(() -> {
- final RoutingTable routingTable = clusterAdmin().prepareState().get().getState().routingTable();
+ final RoutingTable routingTable = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().routingTable();
final IndexRoutingTable indexRoutingTable = routingTable.index("test");
assertNotNull(indexRoutingTable);
for (int i = 0; i < indexRoutingTable.size(); i++) {
@@ -497,13 +505,13 @@ public void testArchiveBrokenClusterSettings() throws Exception {
} else {
internalCluster().startNode();
clusterAdmin().health(
- new ClusterHealthRequest(new String[] {}).waitForGreenStatus()
+ new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, new String[] {}).waitForGreenStatus()
.waitForEvents(Priority.LANGUID)
.waitForNoRelocatingShards(true)
.waitForNodes("2")
).actionGet();
}
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final Metadata metadata = state.getMetadata();
final Metadata brokenMeta = Metadata.builder(metadata)
@@ -518,7 +526,7 @@ public void testArchiveBrokenClusterSettings() throws Exception {
restartNodesOnBrokenClusterState(ClusterState.builder(state).metadata(brokenMeta));
ensureYellow("test"); // wait for state recovery
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertEquals("true", state.metadata().persistentSettings().get("archived.this.is.unknown"));
assertEquals(
"broken",
@@ -528,7 +536,7 @@ public void testArchiveBrokenClusterSettings() throws Exception {
// delete these settings
updateClusterSettings(Settings.builder().putNull("archived.*"));
- state = clusterAdmin().prepareState().get().getState();
+ state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertNull(state.metadata().persistentSettings().get("archived.this.is.unknown"));
assertNull(
state.metadata().persistentSettings().get("archived." + ShardLimitValidator.SETTING_CLUSTER_MAX_SHARDS_PER_NODE.getKey())
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/gateway/MetadataNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/gateway/MetadataNodesIT.java
index 1e34967073adc..94824db66d152 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/gateway/MetadataNodesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/gateway/MetadataNodesIT.java
@@ -69,7 +69,7 @@ public void testIndexFilesAreRemovedIfAllShardsFromIndexRemoved() throws Excepti
logger.debug("relocating index...");
updateIndexSettings(Settings.builder().put(IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + "_name", node2), index);
- clusterAdmin().prepareHealth().setWaitForNoRelocatingShards(true).get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNoRelocatingShards(true).get();
ensureGreen();
assertIndexDirectoryDeleted(node1, resolveIndex);
assertIndexInMetaState(node2, index);
@@ -98,7 +98,7 @@ public void testMetaWrittenWhenIndexIsClosedAndMetaUpdated() throws Exception {
logger.info("--> close index");
indicesAdmin().prepareClose(index).get();
// close the index
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(clusterStateResponse.getState().getMetadata().index(index).getState().name(), equalTo(IndexMetadata.State.CLOSE.name()));
// update the mapping. this should cause the new meta data to be written although index is closed
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/gateway/QuorumGatewayIT.java b/server/src/internalClusterTest/java/org/elasticsearch/gateway/QuorumGatewayIT.java
index 15a72e3534b50..f1b06e4efc97d 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/gateway/QuorumGatewayIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/gateway/QuorumGatewayIT.java
@@ -62,7 +62,7 @@ public void doAfterNodes(int numNodes, final Client activeClient) throws Excepti
ClusterHealthResponse clusterHealth = activeClient.admin()
.cluster()
.health(
- new ClusterHealthRequest(new String[] {}).waitForYellowStatus()
+ new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, new String[] {}).waitForYellowStatus()
.waitForNodes("2")
.waitForActiveShards(test.numPrimaries * 2)
)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java
index b55dd5e207c41..4281562b64791 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/gateway/RecoverAfterNodesIT.java
@@ -35,7 +35,7 @@ public Set waitForNoBlocksOnNode(TimeValue timeout, Client nodeCli
do {
blocks = nodeClient.admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.setLocal(true)
.get()
.getState()
@@ -55,33 +55,75 @@ public void testRecoverAfterDataNodes() {
logger.info("--> start master_node (1)");
Client master1 = startNode(Settings.builder().put(RECOVER_AFTER_DATA_NODES_SETTING.getKey(), 2).put(masterOnlyNode()));
assertThat(
- master1.admin().cluster().prepareState().setLocal(true).get().getState().blocks().global(ClusterBlockLevel.METADATA_WRITE),
+ master1.admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .setLocal(true)
+ .get()
+ .getState()
+ .blocks()
+ .global(ClusterBlockLevel.METADATA_WRITE),
hasItem(GatewayService.STATE_NOT_RECOVERED_BLOCK)
);
logger.info("--> start data_node (1)");
Client data1 = startNode(Settings.builder().put(RECOVER_AFTER_DATA_NODES_SETTING.getKey(), 2).put(dataOnlyNode()));
assertThat(
- master1.admin().cluster().prepareState().setLocal(true).get().getState().blocks().global(ClusterBlockLevel.METADATA_WRITE),
+ master1.admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .setLocal(true)
+ .get()
+ .getState()
+ .blocks()
+ .global(ClusterBlockLevel.METADATA_WRITE),
hasItem(GatewayService.STATE_NOT_RECOVERED_BLOCK)
);
assertThat(
- data1.admin().cluster().prepareState().setLocal(true).get().getState().blocks().global(ClusterBlockLevel.METADATA_WRITE),
+ data1.admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .setLocal(true)
+ .get()
+ .getState()
+ .blocks()
+ .global(ClusterBlockLevel.METADATA_WRITE),
hasItem(GatewayService.STATE_NOT_RECOVERED_BLOCK)
);
logger.info("--> start master_node (2)");
Client master2 = startNode(Settings.builder().put(RECOVER_AFTER_DATA_NODES_SETTING.getKey(), 2).put(masterOnlyNode()));
assertThat(
- master2.admin().cluster().prepareState().setLocal(true).get().getState().blocks().global(ClusterBlockLevel.METADATA_WRITE),
+ master2.admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .setLocal(true)
+ .get()
+ .getState()
+ .blocks()
+ .global(ClusterBlockLevel.METADATA_WRITE),
hasItem(GatewayService.STATE_NOT_RECOVERED_BLOCK)
);
assertThat(
- data1.admin().cluster().prepareState().setLocal(true).get().getState().blocks().global(ClusterBlockLevel.METADATA_WRITE),
+ data1.admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .setLocal(true)
+ .get()
+ .getState()
+ .blocks()
+ .global(ClusterBlockLevel.METADATA_WRITE),
hasItem(GatewayService.STATE_NOT_RECOVERED_BLOCK)
);
assertThat(
- master2.admin().cluster().prepareState().setLocal(true).get().getState().blocks().global(ClusterBlockLevel.METADATA_WRITE),
+ master2.admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .setLocal(true)
+ .get()
+ .getState()
+ .blocks()
+ .global(ClusterBlockLevel.METADATA_WRITE),
hasItem(GatewayService.STATE_NOT_RECOVERED_BLOCK)
);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java b/server/src/internalClusterTest/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java
index 26573644790fa..193f025e6843b 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java
@@ -142,7 +142,7 @@ private Map assertAndCapturePrimaryTerms(Map pre
previousTerms = new HashMap<>();
}
final Map result = new HashMap<>();
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
for (IndexMetadata indexMetadata : state.metadata().indices().values()) {
final String index = indexMetadata.getIndex().getName();
final long[] previous = previousTerms.get(index);
@@ -316,7 +316,10 @@ public void testTwoNodeFirstNodeCleared() throws Exception {
Map primaryTerms = assertAndCapturePrimaryTerms(null);
- client().execute(TransportAddVotingConfigExclusionsAction.TYPE, new AddVotingConfigExclusionsRequest(firstNode)).get();
+ client().execute(
+ TransportAddVotingConfigExclusionsAction.TYPE,
+ new AddVotingConfigExclusionsRequest(TEST_REQUEST_TIMEOUT, firstNode)
+ ).get();
internalCluster().fullRestart(new RestartCallback() {
@Override
@@ -342,7 +345,8 @@ public boolean clearData(String nodeName) {
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
}
- client().execute(TransportClearVotingConfigExclusionsAction.TYPE, new ClearVotingConfigExclusionsRequest()).get();
+ client().execute(TransportClearVotingConfigExclusionsAction.TYPE, new ClearVotingConfigExclusionsRequest(TEST_REQUEST_TIMEOUT))
+ .get();
}
public void testLatestVersionLoaded() throws Exception {
@@ -364,7 +368,7 @@ public void testLatestVersionLoaded() throws Exception {
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 2);
}
- String metadataUuid = clusterAdmin().prepareState().execute().get().getState().getMetadata().clusterUUID();
+ String metadataUuid = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).execute().get().getState().getMetadata().clusterUUID();
assertThat(metadataUuid, not(equalTo("_na_")));
logger.info("--> closing first node, and indexing more data to the second node");
@@ -420,13 +424,16 @@ public void testLatestVersionLoaded() throws Exception {
logger.info("--> running cluster_health (wait for the shards to startup)");
ensureGreen();
- assertThat(clusterAdmin().prepareState().execute().get().getState().getMetadata().clusterUUID(), equalTo(metadataUuid));
+ assertThat(
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).execute().get().getState().getMetadata().clusterUUID(),
+ equalTo(metadataUuid)
+ );
for (int i = 0; i < 10; i++) {
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 3);
}
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.metadata().templates().get("template_1").patterns(), equalTo(Collections.singletonList("te*")));
assertThat(state.metadata().index("test").getAliases().get("test_alias"), notNullValue());
assertThat(state.metadata().index("test").getAliases().get("test_alias").filter(), notNullValue());
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/gateway/ReplicaShardAllocatorIT.java b/server/src/internalClusterTest/java/org/elasticsearch/gateway/ReplicaShardAllocatorIT.java
index ae0a1e15923ec..02c566f49e2b3 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/gateway/ReplicaShardAllocatorIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/gateway/ReplicaShardAllocatorIT.java
@@ -202,7 +202,7 @@ public void testRecentPrimaryInformation() throws Exception {
);
internalCluster().startDataOnlyNode(nodeWithReplicaSettings);
// need to wait for events to ensure the reroute has happened since we perform it async when a new node joins.
- clusterAdmin().prepareHealth(indexName).setWaitForYellowStatus().setWaitForEvents(Priority.LANGUID).get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, indexName).setWaitForYellowStatus().setWaitForEvents(Priority.LANGUID).get();
blockRecovery.countDown();
ensureGreen(indexName);
assertThat(internalCluster().nodesInclude(indexName), hasItem(newNode));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/health/HealthMetadataServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/health/HealthMetadataServiceIT.java
index 660d6028486a0..30fc7e263a4c8 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/health/HealthMetadataServiceIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/health/HealthMetadataServiceIT.java
@@ -253,7 +253,7 @@ private static void updateSettings(InternalTestCluster internalCluster, Settings
internalCluster.client()
.admin()
.cluster()
- .updateSettings(new ClusterUpdateSettingsRequest().persistentSettings(settings))
+ .updateSettings(new ClusterUpdateSettingsRequest(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT).persistentSettings(settings))
.actionGet();
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/health/HealthServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/health/HealthServiceIT.java
index 14697cc6533c1..a5931f29b9ff0 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/health/HealthServiceIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/health/HealthServiceIT.java
@@ -88,7 +88,7 @@ private void waitForAllNodesToReportHealth() throws Exception {
ClusterState state = internalCluster().client()
.admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setMetadata(true)
.setNodes(true)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/health/UpdateHealthInfoCacheIT.java b/server/src/internalClusterTest/java/org/elasticsearch/health/UpdateHealthInfoCacheIT.java
index 5a5fad9be3ef2..b6477a7e1a6c8 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/health/UpdateHealthInfoCacheIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/health/UpdateHealthInfoCacheIT.java
@@ -136,13 +136,22 @@ private void decreasePollingInterval(InternalTestCluster internalCluster) {
.admin()
.cluster()
.updateSettings(
- new ClusterUpdateSettingsRequest().persistentSettings(
+ new ClusterUpdateSettingsRequest(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT).persistentSettings(
Settings.builder().put(LocalHealthMonitor.POLL_INTERVAL_SETTING.getKey(), TimeValue.timeValueSeconds(10))
)
);
}
private static Map getNodes(InternalTestCluster internalCluster) {
- return internalCluster.client().admin().cluster().prepareState().clear().setNodes(true).get().getState().getNodes().getNodes();
+ return internalCluster.client()
+ .admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .clear()
+ .setNodes(true)
+ .get()
+ .getState()
+ .getNodes()
+ .getNodes();
}
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/IndexingPressureIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/IndexingPressureIT.java
index da89f3252bec0..97dd3d9723d5f 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/index/IndexingPressureIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/index/IndexingPressureIT.java
@@ -396,7 +396,15 @@ public Settings onNodeStopped(String nodeName) {
}
private String getCoordinatingOnlyNode() {
- return clusterAdmin().prepareState().get().getState().nodes().getCoordinatingOnlyNodes().values().iterator().next().getName();
+ return clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getCoordinatingOnlyNodes()
+ .values()
+ .iterator()
+ .next()
+ .getName();
}
private Tuple getPrimaryReplicaNodeNames() {
@@ -413,7 +421,7 @@ private Tuple getPrimaryReplicaNodeNames() {
.findAny()
.get()
.currentNodeId();
- DiscoveryNodes nodes = clusterAdmin().prepareState().get().getState().nodes();
+ DiscoveryNodes nodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes();
String primaryName = nodes.get(primaryId).getName();
String replicaName = nodes.get(replicaId).getName();
return new Tuple<>(primaryName, replicaName);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncIT.java
index 53f632f6ba8d5..749cf73e822ec 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncIT.java
@@ -84,7 +84,7 @@ public void testPostOperationGlobalCheckpointSync() throws Exception {
public void testBackgroundGlobalCheckpointSync() throws Exception {
runGlobalCheckpointSyncTest(TimeValue.timeValueSeconds(randomIntBetween(1, 3)), client -> {
// prevent global checkpoint syncs between all nodes
- final DiscoveryNodes nodes = client.admin().cluster().prepareState().get().getState().getNodes();
+ final DiscoveryNodes nodes = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getNodes();
for (final DiscoveryNode node : nodes) {
for (final DiscoveryNode other : nodes) {
if (node == other) {
@@ -105,7 +105,7 @@ public void testBackgroundGlobalCheckpointSync() throws Exception {
}
}, client -> {
// restore global checkpoint syncs between all nodes
- final DiscoveryNodes nodes = client.admin().cluster().prepareState().get().getState().getNodes();
+ final DiscoveryNodes nodes = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getNodes();
for (final DiscoveryNode node : nodes) {
for (final DiscoveryNode other : nodes) {
if (node == other) {
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/RetentionLeaseIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/RetentionLeaseIT.java
index c9906ccf1fbee..5a4785252bf98 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/RetentionLeaseIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/RetentionLeaseIT.java
@@ -558,7 +558,7 @@ private void runWaitForShardsTest(
.build();
assertAcked(prepareCreate("index").setSettings(settings));
ensureYellowAndNoInitializingShards("index");
- assertFalse(clusterAdmin().prepareHealth("index").setWaitForActiveShards(numDataNodes).get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "index").setWaitForActiveShards(numDataNodes).get().isTimedOut());
final String primaryShardNodeId = clusterService().state().routingTable().index("index").shard(0).primaryShard().currentNodeId();
final String primaryShardNodeName = clusterService().state().nodes().get(primaryShardNodeId).getName();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/shard/RemoveCorruptedShardDataCommandIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/shard/RemoveCorruptedShardDataCommandIT.java
index bdfe629f4bab0..b7dbcf42630e1 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/index/shard/RemoveCorruptedShardDataCommandIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/index/shard/RemoveCorruptedShardDataCommandIT.java
@@ -194,7 +194,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {
waitNoPendingTasksOnAll();
String nodeId = null;
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final DiscoveryNodes nodes = state.nodes();
for (Map.Entry cursor : nodes.getNodes().entrySet()) {
final String name = cursor.getValue().getName();
@@ -350,7 +350,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {
});
String primaryNodeId = null;
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final DiscoveryNodes nodes = state.nodes();
for (Map.Entry cursor : nodes.getNodes().entrySet()) {
final String name = cursor.getValue().getName();
@@ -524,7 +524,7 @@ public void testResolvePath() throws Exception {
ensureGreen(indexName);
final Map nodeNameToNodeId = new HashMap<>();
- final ClusterState state = clusterAdmin().prepareState().get().getState();
+ final ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final DiscoveryNodes nodes = state.nodes();
for (Map.Entry cursor : nodes.getNodes().entrySet()) {
nodeNameToNodeId.put(cursor.getValue().getName(), cursor.getKey());
@@ -569,7 +569,7 @@ public void testResolvePath() throws Exception {
}
private Path getPathToShardData(String indexName, String dirSuffix) {
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
GroupShardsIterator shardIterators = state.getRoutingTable()
.activePrimaryShardsGrouped(new String[] { indexName }, false);
List iterators = iterableAsArrayList(shardIterators);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/store/CorruptedFileIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/store/CorruptedFileIT.java
index 4bd8fadc93095..f3b888022127f 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/index/store/CorruptedFileIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/index/store/CorruptedFileIT.java
@@ -180,14 +180,18 @@ public void testCorruptFileAndRecover() throws InterruptedException, IOException
*/
setReplicaCount(2, "test");
ClusterHealthResponse health = clusterAdmin().health(
- new ClusterHealthRequest("test").waitForGreenStatus()
+ new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, "test").waitForGreenStatus()
// sometimes due to cluster rebalancing and random settings default timeout is just not enough.
.masterNodeTimeout(TimeValue.timeValueMinutes(5))
.timeout(TimeValue.timeValueMinutes(5))
.waitForNoRelocatingShards(true)
).actionGet();
if (health.isTimedOut()) {
- logger.info("cluster state:\n{}\n{}", clusterAdmin().prepareState().get().getState(), getClusterPendingTasks());
+ logger.info(
+ "cluster state:\n{}\n{}",
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState(),
+ getClusterPendingTasks()
+ );
assertThat("timed out waiting for green state", health.isTimedOut(), equalTo(false));
}
assertThat(health.getStatus(), equalTo(ClusterHealthStatus.GREEN));
@@ -288,18 +292,24 @@ public void testCorruptPrimaryNoReplica() throws ExecutionException, Interrupted
ClusterRerouteUtils.reroute(client());
boolean didClusterTurnRed = waitUntil(() -> {
- ClusterHealthStatus test = clusterAdmin().health(new ClusterHealthRequest("test")).actionGet().getStatus();
+ ClusterHealthStatus test = clusterAdmin().health(new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, "test"))
+ .actionGet()
+ .getStatus();
return test == ClusterHealthStatus.RED;
}, 5, TimeUnit.MINUTES);// sometimes on slow nodes the replication / recovery is just dead slow
- final ClusterHealthResponse response = clusterAdmin().health(new ClusterHealthRequest("test")).get();
+ final ClusterHealthResponse response = clusterAdmin().health(new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, "test")).get();
if (response.getStatus() != ClusterHealthStatus.RED) {
logger.info("Cluster turned red in busy loop: {}", didClusterTurnRed);
- logger.info("cluster state:\n{}\n{}", clusterAdmin().prepareState().get().getState(), getClusterPendingTasks());
+ logger.info(
+ "cluster state:\n{}\n{}",
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState(),
+ getClusterPendingTasks()
+ );
}
assertThat(response.getStatus(), is(ClusterHealthStatus.RED));
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
GroupShardsIterator shardIterators = state.getRoutingTable()
.activePrimaryShardsGrouped(new String[] { "test" }, false);
for (ShardIterator iterator : shardIterators) {
@@ -509,7 +519,7 @@ public void onTimeout(TimeValue timeout) {
}
private void assertThatAllShards(String index, Consumer verifier) {
- var clusterStateResponse = clusterAdmin().state(new ClusterStateRequest().routingTable(true)).actionGet();
+ var clusterStateResponse = clusterAdmin().state(new ClusterStateRequest(TEST_REQUEST_TIMEOUT).routingTable(true)).actionGet();
var indexRoutingTable = clusterStateResponse.getState().getRoutingTable().index(index);
for (int shardId = 0; shardId < indexRoutingTable.size(); shardId++) {
verifier.accept(indexRoutingTable.shard(shardId));
@@ -655,7 +665,7 @@ public void testReplicaCorruption() throws Exception {
}
private int numShards(String... index) {
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
GroupShardsIterator> shardIterators = state.getRoutingTable().activePrimaryShardsGrouped(index, false);
return shardIterators.size();
}
@@ -682,7 +692,7 @@ private ShardRouting corruptRandomPrimaryFile() throws IOException {
}
private ShardRouting corruptRandomPrimaryFile(final boolean includePerCommitFiles) throws IOException {
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
Index test = state.metadata().index("test").getIndex();
GroupShardsIterator shardIterators = state.getRoutingTable()
.activePrimaryShardsGrouped(new String[] { "test" }, false);
@@ -738,7 +748,7 @@ private static boolean isPerSegmentFile(String fileName) {
public List listShardFiles(ShardRouting routing) throws IOException {
NodesStatsResponse nodeStatses = clusterAdmin().prepareNodesStats(routing.currentNodeId()).setFs(true).get();
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final Index test = state.metadata().index("test").getIndex();
assertThat(routing.toString(), nodeStatses.getNodes().size(), equalTo(1));
List files = new ArrayList<>();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java
index 143ffedeefc55..45b9091ab2552 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java
@@ -144,7 +144,7 @@ private SearchRequestBuilder addSuggestions(SearchRequestBuilder request, int i)
}
private Set nodeIdsWithIndex(String... indices) {
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
GroupShardsIterator allAssignedShardsGrouped = state.routingTable().allAssignedShardsGrouped(indices, true);
Set nodes = new HashSet<>();
for (ShardIterator shardIterator : allAssignedShardsGrouped) {
@@ -159,7 +159,7 @@ private Set nodeIdsWithIndex(String... indices) {
}
protected int numAssignedShards(String... indices) {
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
GroupShardsIterator> allAssignedShardsGrouped = state.routingTable().allAssignedShardsGrouped(indices, true);
return allAssignedShardsGrouped.size();
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java
index 5c4cdc8cde851..8ea707c0a26b3 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java
@@ -58,7 +58,7 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
CreateIndexResponse createIndexResponse = indicesAdmin().create(new CreateIndexRequest("test").settings(settings)).actionGet();
assertAcked(createIndexResponse);
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
RoutingNode routingNodeEntry1 = clusterState.getRoutingNodes().node(node1);
assertThat(routingNodeEntry1.numberOfShardsWithState(STARTED), equalTo(11));
@@ -68,7 +68,7 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
// first wait for 2 nodes in the cluster
logger.info("Waiting for replicas to be assigned");
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForGreenStatus()
.setWaitForNodes("2")
.setWaitForNoRelocatingShards(true)
@@ -83,7 +83,9 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
ClusterRerouteUtils.reroute(client());
clusterHealth = clusterAdmin().health(
- new ClusterHealthRequest(new String[] {}).waitForGreenStatus().waitForNodes("2").waitForNoRelocatingShards(true)
+ new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, new String[] {}).waitForGreenStatus()
+ .waitForNodes("2")
+ .waitForNoRelocatingShards(true)
).actionGet();
assertThat(clusterHealth.isTimedOut(), equalTo(false));
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
@@ -94,7 +96,7 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
assertThat(clusterHealth.getActiveShards(), equalTo(22));
assertThat(clusterHealth.getActivePrimaryShards(), equalTo(11));
- clusterState = clusterAdmin().prepareState().get().getState();
+ clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertNodesPresent(clusterState.getRoutingNodes(), node1, node2);
routingNodeEntry1 = clusterState.getRoutingNodes().node(node1);
assertThat(routingNodeEntry1.numberOfShardsWithState(RELOCATING), equalTo(0));
@@ -109,7 +111,7 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
// first wait for 3 nodes in the cluster
logger.info("Waiting for replicas to be assigned");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForGreenStatus()
.setWaitForNodes("3")
.setWaitForNoRelocatingShards(true)
@@ -123,7 +125,7 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
// explicitly call reroute, so shards will get relocated to the new node (we delay it in ES in case other nodes join)
ClusterRerouteUtils.reroute(client());
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForGreenStatus()
.setWaitForNodes("3")
.setWaitForNoRelocatingShards(true)
@@ -138,7 +140,7 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
assertThat(clusterHealth.getActiveShards(), equalTo(22));
assertThat(clusterHealth.getActivePrimaryShards(), equalTo(11));
- clusterState = clusterAdmin().prepareState().get().getState();
+ clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertNodesPresent(clusterState.getRoutingNodes(), node1, node2, node3);
routingNodeEntry1 = clusterState.getRoutingNodes().node(node1);
@@ -165,7 +167,7 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
internalCluster().stopNode(server_1);
// verify health
logger.info("Running Cluster Health");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForGreenStatus()
.setWaitForNodes("2")
.setWaitForNoRelocatingShards(true)
@@ -177,7 +179,7 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
ClusterRerouteUtils.reroute(client());
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForGreenStatus()
.setWaitForNodes("2")
.setWaitForNoRelocatingShards(true)
@@ -189,7 +191,7 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
assertThat(clusterHealth.getActiveShards(), equalTo(22));
assertThat(clusterHealth.getActivePrimaryShards(), equalTo(11));
- clusterState = clusterAdmin().prepareState().get().getState();
+ clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertNodesPresent(clusterState.getRoutingNodes(), node3, node2);
routingNodeEntry2 = clusterState.getRoutingNodes().node(node2);
routingNodeEntry3 = clusterState.getRoutingNodes().node(node3);
@@ -207,7 +209,7 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
AcknowledgedResponse deleteIndexResponse = indicesAdmin().prepareDelete("test").get();
assertThat(deleteIndexResponse.isAcknowledged(), equalTo(true));
- clusterState = clusterAdmin().prepareState().get().getState();
+ clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertNodesPresent(clusterState.getRoutingNodes(), node3, node2);
routingNodeEntry2 = clusterState.getRoutingNodes().node(node2);
assertThat(routingNodeEntry2.isEmpty(), equalTo(true));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java
index fb22aaa3747c2..69e982a30b354 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java
@@ -177,7 +177,7 @@ public void testCreateIndexWithDateMathExpression() {
assertEquals(dateMathExp3, response.getSetting(index3, IndexMetadata.SETTING_INDEX_PROVIDED_NAME));
});
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(clusterState.metadata().index(index1), notNullValue());
assertThat(clusterState.metadata().index(index2), notNullValue());
assertThat(clusterState.metadata().index(index3), notNullValue());
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java
index e9e88a2d6b76c..325cd27f0090f 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java
@@ -97,7 +97,7 @@ public void beforeIndexCreated(Index index, Settings indexSettings) {
fail("should have thrown an exception during creation");
} catch (Exception e) {
assertTrue(e.getMessage().contains("failing on purpose"));
- assertFalse(clusterAdmin().prepareState().get().getState().routingTable().hasIndex("failed"));
+ assertFalse(clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().routingTable().hasIndex("failed"));
}
}
@@ -120,7 +120,7 @@ public void beforeIndexCreated(Index index, Settings indexSettings) {
ClusterRerouteUtils.reroute(client(), new MoveAllocationCommand("index1", 0, node1, node2));
ensureGreen("index1");
- var state = clusterAdmin().prepareState().get().getState();
+ var state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
logger.info("Final routing is {}", state.getRoutingNodes().toString());
var shard = state.routingTable().index("index1").shard(0).primaryShard();
assertThat(shard, notNullValue());
@@ -148,13 +148,13 @@ public void beforeIndexCreated(Index index, Settings indexSettings) {
// await all relocation attempts are exhausted
assertBusy(() -> {
- var state = clusterAdmin().prepareState().get().getState();
+ var state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
var shard = state.routingTable().index("index1").shard(0).primaryShard();
assertThat(shard, notNullValue());
assertThat(shard.relocationFailureInfo().failedRelocations(), equalTo(maxAttempts));
});
// ensure the shard remain started
- var state = clusterAdmin().prepareState().get().getState();
+ var state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
logger.info("Final routing is {}", state.getRoutingNodes().toString());
var shard = state.routingTable().index("index1").shard(0).primaryShard();
assertThat(shard, notNullValue());
@@ -177,7 +177,7 @@ public void testIndexStateShardChanged() throws Throwable {
fail("should have thrown an exception");
} catch (ElasticsearchException e) {
assertTrue(e.getMessage().contains("failing on purpose"));
- ClusterStateResponse resp = clusterAdmin().prepareState().get();
+ ClusterStateResponse resp = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertFalse(resp.getState().routingTable().indicesRouting().keySet().contains("failed"));
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/ResolveClusterIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/ResolveClusterIT.java
index c4be9568f8bab..1ca8fb315b09f 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/ResolveClusterIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/ResolveClusterIT.java
@@ -677,7 +677,7 @@ private Map setupThreeClusters(boolean useAlias) throws IOExcept
assertFalse(
client(REMOTE_CLUSTER_1).admin()
.cluster()
- .prepareHealth(remoteIndex1)
+ .prepareHealth(TEST_REQUEST_TIMEOUT, remoteIndex1)
.setWaitForYellowStatus()
.setTimeout(TimeValue.timeValueSeconds(10))
.get()
@@ -715,7 +715,7 @@ private Map setupThreeClusters(boolean useAlias) throws IOExcept
assertFalse(
client(REMOTE_CLUSTER_2).admin()
.cluster()
- .prepareHealth(remoteIndex2)
+ .prepareHealth(TEST_REQUEST_TIMEOUT, remoteIndex2)
.setWaitForYellowStatus()
.setTimeout(TimeValue.timeValueSeconds(10))
.get()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/ShardLockFailureIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/ShardLockFailureIT.java
index 28e89f4590557..d263a9d658891 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/ShardLockFailureIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/ShardLockFailureIT.java
@@ -106,7 +106,7 @@ public void assertMatched() {}
updateIndexSettings(Settings.builder().putNull(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_PREFIX + "._name"), indexName);
ensureYellow(indexName);
assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
- assertEquals(ClusterHealthStatus.YELLOW, clusterAdmin().prepareHealth(indexName).get().getStatus());
+ assertEquals(ClusterHealthStatus.YELLOW, clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, indexName).get().getStatus());
mockLog.assertAllExpectationsMatched();
}
@@ -153,7 +153,7 @@ public void testShardLockTimeout() throws Exception {
updateIndexSettings(Settings.builder().putNull(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_PREFIX + "._name"), indexName);
assertBusy(mockLog::assertAllExpectationsMatched);
- final var clusterHealthResponse = clusterAdmin().prepareHealth(indexName)
+ final var clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, indexName)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueSeconds(10))
.setWaitForNoInitializingShards(true)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java
index 720f48754519b..57f09e1ed2bb1 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetMappingsIT.java
@@ -62,7 +62,7 @@ public void testSimpleGetMappings() throws Exception {
indicesAdmin().prepareCreate("indexa").setMapping(getMappingForType()).get();
indicesAdmin().prepareCreate("indexb").setMapping(getMappingForType()).get();
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.get();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
index 0008ec1f9cbd2..3d240627cf23f 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java
@@ -62,7 +62,7 @@ public void testDynamicUpdates() throws Exception {
indicesAdmin().prepareCreate("test")
.setSettings(indexSettings(1, 0).put(MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING.getKey(), Long.MAX_VALUE))
.get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
updateClusterSettings(
Settings.builder().put(MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING.getKey(), TimeValue.timeValueMinutes(5))
);
@@ -100,7 +100,7 @@ public void testUpdateMappingWithoutType() {
indicesAdmin().prepareCreate("test").setSettings(indexSettings(1, 0)).setMapping("""
{"properties":{"body":{"type":"text"}}}
""").get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
AcknowledgedResponse putMappingResponse = indicesAdmin().preparePutMapping("test").setSource("""
{"properties":{"date":{"type":"integer"}}}
@@ -115,7 +115,7 @@ public void testUpdateMappingWithoutType() {
public void testUpdateMappingWithoutTypeMultiObjects() {
createIndex("test", 1, 0);
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
AcknowledgedResponse putMappingResponse = indicesAdmin().preparePutMapping("test").setSource("""
{"properties":{"date":{"type":"integer"}}}""", XContentType.JSON).get();
@@ -131,7 +131,7 @@ public void testUpdateMappingWithConflicts() {
indicesAdmin().prepareCreate("test").setSettings(indexSettings(2, 0)).setMapping("""
{"properties":{"body":{"type":"text"}}}
""").get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
try {
indicesAdmin().preparePutMapping("test").setSource("""
@@ -163,7 +163,7 @@ public void testUpdateMappingWithNormsConflicts() {
public void testUpdateMappingNoChanges() {
indicesAdmin().prepareCreate("test").setSettings(indexSettings(2, 0)).setMapping("""
{"properties":{"body":{"type":"text"}}}""").get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
AcknowledgedResponse putMappingResponse = indicesAdmin().preparePutMapping("test").setSource("""
{"_doc":{"properties":{"body":{"type":"text"}}}}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java
index 705fb879e9125..e547ae5a46deb 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java
@@ -319,7 +319,7 @@ public void testCanResetUnreasonableSettings() {
reset();
assertThat(
- clusterAdmin().prepareState()
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.metadata()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/HierarchyCircuitBreakerTelemetryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/HierarchyCircuitBreakerTelemetryIT.java
index ff2117ea93bb9..56fcb3c1d123d 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/HierarchyCircuitBreakerTelemetryIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/HierarchyCircuitBreakerTelemetryIT.java
@@ -63,7 +63,12 @@ public void testCircuitBreakerTripCountMetric() {
// NOTE: we start with empty circuitBreakerSettings to allow cluster formation
masterNodeName = internalCluster().startMasterOnlyNode(Settings.EMPTY);
dataNodeName = internalCluster().startDataOnlyNode(Settings.EMPTY);
- assertTrue(clusterAdmin().prepareUpdateSettings().setPersistentSettings(circuitBreakerSettings).get().isAcknowledged());
+ assertTrue(
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(circuitBreakerSettings)
+ .get()
+ .isAcknowledged()
+ );
assertTrue(
client().admin()
.indices()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/DanglingIndicesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/DanglingIndicesIT.java
index 0b9ca9d9f9586..a51f4bb10dc00 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/DanglingIndicesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/DanglingIndicesIT.java
@@ -325,7 +325,7 @@ public void testDanglingIndicesImportedAndDeletedCannotBeReimported() throws Exc
}
}
- final Metadata metadata = clusterAdmin().prepareState().clear().setMetadata(true).get().getState().metadata();
+ final Metadata metadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).clear().setMetadata(true).get().getState().metadata();
assertTrue(metadata.indexGraveyard().toString(), metadata.indexGraveyard().containsIndex(new Index(INDEX_NAME, danglingIndexUUID)));
assertNull(Strings.toString(metadata, true, true), metadata.index(INDEX_NAME));
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java
index a9e06fe438c41..64f594c488a5e 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java
@@ -53,7 +53,7 @@ public void run() {
};
indexingThread.start();
- ClusterState initialState = clusterAdmin().prepareState().get().getState();
+ ClusterState initialState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
DiscoveryNode[] dataNodes = initialState.getNodes().getDataNodes().values().toArray(DiscoveryNode[]::new);
DiscoveryNode relocationSource = initialState.getNodes()
.getDataNodes()
@@ -65,7 +65,7 @@ public void run() {
}
logger.info("--> [iteration {}] relocating from {} to {} ", i, relocationSource.getName(), relocationTarget.getName());
ClusterRerouteUtils.reroute(client(), new MoveAllocationCommand("test", 0, relocationSource.getId(), relocationTarget.getId()));
- ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setTimeout(TimeValue.timeValueSeconds(60))
.setWaitForEvents(Priority.LANGUID)
.setWaitForNoRelocatingShards(true)
@@ -77,7 +77,7 @@ public void run() {
"timed out waiting for relocation iteration [" + i + "]",
ReferenceDocs.LOGGING
);
- final ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ final ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
logger.info("timed out for waiting for relocation iteration [{}] \ncluster state {}", i, clusterState);
finished.set(true);
indexingThread.join();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java
index fbbeec4b4e9ba..abeaf8422748d 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java
@@ -523,7 +523,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {
transportService.clearAllRules();
// make sure nodeA has primary and nodeB has replica
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
List startedShards = RoutingNodesHelper.shardsWithState(state.getRoutingNodes(), ShardRoutingState.STARTED);
assertThat(startedShards.size(), equalTo(2));
for (ShardRouting shardRouting : startedShards) {
@@ -635,7 +635,7 @@ public void testRerouteRecovery() throws Exception {
logger.info("--> start node C");
String nodeC = internalCluster().startNode();
- assertFalse(clusterAdmin().prepareHealth().setWaitForNodes("3").get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("3").get().isTimedOut());
logger.info("--> slowing down recoveries");
throttleRecovery10Seconds(shardSize);
@@ -1118,7 +1118,7 @@ public void testOngoingRecoveryAndMasterFailOver() throws Exception {
Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 2).putNull("index.routing.allocation.include._name"),
indexName
);
- assertFalse(clusterAdmin().prepareHealth(indexName).setWaitForActiveShards(2).get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, indexName).setWaitForActiveShards(2).get().isTimedOut());
} finally {
allowToCompletePhase1Latch.countDown();
}
@@ -1261,7 +1261,7 @@ public void testUsesFileBasedRecoveryIfRetentionLeaseMissing() throws Exception
@Override
public Settings onNodeStopped(String nodeName) throws Exception {
assertFalse(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForNodes(Integer.toString(discoveryNodes.getSize() - 1))
.setWaitForEvents(Priority.LANGUID)
.get()
@@ -1325,7 +1325,7 @@ public void testUsesFileBasedRecoveryIfRetentionLeaseAheadOfGlobalCheckpoint() t
@Override
public Settings onNodeStopped(String nodeName) throws Exception {
assertFalse(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForNodes(Integer.toString(discoveryNodes.getSize() - 1))
.setWaitForEvents(Priority.LANGUID)
.get()
@@ -1432,7 +1432,7 @@ public void testUsesFileBasedRecoveryIfOperationsBasedRecoveryWouldBeUnreasonabl
@Override
public Settings onNodeStopped(String nodeName) throws Exception {
assertFalse(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForNodes(Integer.toString(discoveryNodes.getSize() - 1))
.setWaitForEvents(Priority.LANGUID)
.get()
@@ -1657,7 +1657,7 @@ public void testPeerRecoveryTrimsLocalTranslog() throws Exception {
String indexName = "test-index";
createIndex(indexName, indexSettings(1, 1).put("index.routing.allocation.include._name", String.join(",", dataNodes)).build());
ensureGreen(indexName);
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
DiscoveryNode nodeWithOldPrimary = clusterState.nodes()
.get(clusterState.routingTable().index(indexName).shard(0).primaryShard().currentNodeId());
final var transportService = MockTransportService.getInstance(nodeWithOldPrimary.getName());
@@ -1731,7 +1731,7 @@ public void testReservesBytesDuringPeerRecoveryPhaseOne() throws Exception {
indexRandom(randomBoolean(), true, true, indexRequests);
assertThat(indicesAdmin().prepareFlush(indexName).get().getFailedShards(), equalTo(0));
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
DiscoveryNode nodeWithPrimary = clusterState.nodes()
.get(clusterState.routingTable().index(indexName).shard(0).primaryShard().currentNodeId());
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/ReplicaToPrimaryPromotionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/ReplicaToPrimaryPromotionIT.java
index 8595f11bae428..25ac384a22917 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/ReplicaToPrimaryPromotionIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/ReplicaToPrimaryPromotionIT.java
@@ -55,7 +55,11 @@ public void testPromoteReplicaToPrimary() throws Exception {
}
// pick up a data node that contains a random primary shard
- ClusterState state = client(internalCluster().getMasterName()).admin().cluster().prepareState().get().getState();
+ ClusterState state = client(internalCluster().getMasterName()).admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState();
final int numShards = state.metadata().index(indexName).getNumberOfShards();
final ShardRouting primaryShard = state.routingTable().index(indexName).shard(randomIntBetween(0, numShards - 1)).primaryShard();
final DiscoveryNode randomNode = state.nodes().resolveNode(primaryShard.currentNodeId());
@@ -64,7 +68,7 @@ public void testPromoteReplicaToPrimary() throws Exception {
internalCluster().stopNode(randomNode.getName());
ensureYellowAndNoInitializingShards(indexName);
- state = client(internalCluster().getMasterName()).admin().cluster().prepareState().get().getState();
+ state = client(internalCluster().getMasterName()).admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
final IndexRoutingTable indexRoutingTable = state.routingTable().index(indexName);
for (int i = 0; i < indexRoutingTable.size(); i++) {
for (ShardRouting shardRouting : indexRoutingTable.shard(i).activeShards()) {
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/plan/ShardSnapshotsServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/plan/ShardSnapshotsServiceIT.java
index 2f336f25c3cab..d117373b58f05 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/plan/ShardSnapshotsServiceIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/plan/ShardSnapshotsServiceIT.java
@@ -284,7 +284,7 @@ private ShardSnapshotsService getShardSnapshotsService() {
}
private ShardId getShardIdForIndex(String indexName) {
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
return state.routingTable().index(indexName).shard(0).shardId();
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java
index 67482ad733676..606b694cbfeb9 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java
@@ -36,7 +36,7 @@ public void testSimpleUpdateNumberOfReplicas() throws Exception {
logger.info("Creating index test");
assertAcked(prepareCreate("test", 2));
logger.info("Running Cluster Health");
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.get();
@@ -62,11 +62,16 @@ public void testSimpleUpdateNumberOfReplicas() throws Exception {
assertHitCount(prepareSearch().setSize(0).setQuery(matchAllQuery()), 10L);
}
- final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long settingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
logger.info("Increasing the number of replicas from 1 to 2");
setReplicaCount(2, "test");
logger.info("Running Cluster Health");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForYellowStatus()
.setWaitForActiveShards(numShards.numPrimaries * 2)
@@ -79,7 +84,7 @@ public void testSimpleUpdateNumberOfReplicas() throws Exception {
// only 2 copies allocated (1 replica) across 2 nodes
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 2));
- final long afterReplicaIncreaseSettingsVersion = clusterAdmin().prepareState()
+ final long afterReplicaIncreaseSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.metadata()
@@ -90,7 +95,7 @@ public void testSimpleUpdateNumberOfReplicas() throws Exception {
logger.info("starting another node to new replicas will be allocated to it");
allowNodes("test", 3);
- final long afterStartingAnotherNodeVersion = clusterAdmin().prepareState()
+ final long afterStartingAnotherNodeVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.metadata()
@@ -98,7 +103,7 @@ public void testSimpleUpdateNumberOfReplicas() throws Exception {
.getSettingsVersion();
logger.info("Running Cluster Health");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForNoRelocatingShards(true)
@@ -120,7 +125,7 @@ public void testSimpleUpdateNumberOfReplicas() throws Exception {
setReplicaCount(0, "test");
logger.info("Running Cluster Health");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForNoRelocatingShards(true)
@@ -138,7 +143,7 @@ public void testSimpleUpdateNumberOfReplicas() throws Exception {
assertHitCount(prepareSearch().setQuery(matchAllQuery()), 10);
}
- final long afterReplicaDecreaseSettingsVersion = clusterAdmin().prepareState()
+ final long afterReplicaDecreaseSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.metadata()
@@ -155,7 +160,7 @@ public void testAutoExpandNumberOfReplicas0ToData() throws IOException {
NumShards numShards = getNumShards("test");
logger.info("--> running cluster health");
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForActiveShards(numShards.numPrimaries * 2)
@@ -170,7 +175,7 @@ public void testAutoExpandNumberOfReplicas0ToData() throws IOException {
if (randomBoolean()) {
assertAcked(indicesAdmin().prepareClose("test").setWaitForActiveShards(ActiveShardCount.ALL));
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForActiveShards(numShards.numPrimaries * 2)
@@ -183,13 +188,18 @@ public void testAutoExpandNumberOfReplicas0ToData() throws IOException {
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 2));
}
- final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long settingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
logger.info("--> add another node, should increase the number of replicas");
allowNodes("test", 3);
logger.info("--> running cluster health");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForActiveShards(numShards.numPrimaries * 3)
@@ -202,7 +212,7 @@ public void testAutoExpandNumberOfReplicas0ToData() throws IOException {
assertThat(clusterHealth.getIndices().get("test").getNumberOfReplicas(), equalTo(2));
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 3));
- final long afterAddingOneNodeSettingsVersion = clusterAdmin().prepareState()
+ final long afterAddingOneNodeSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.metadata()
@@ -215,7 +225,7 @@ public void testAutoExpandNumberOfReplicas0ToData() throws IOException {
allowNodes("test", 2);
logger.info("--> running cluster health");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForActiveShards(numShards.numPrimaries * 2)
@@ -228,7 +238,7 @@ public void testAutoExpandNumberOfReplicas0ToData() throws IOException {
assertThat(clusterHealth.getIndices().get("test").getNumberOfReplicas(), equalTo(1));
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 2));
- final long afterClosingOneNodeSettingsVersion = clusterAdmin().prepareState()
+ final long afterClosingOneNodeSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.metadata()
@@ -241,7 +251,7 @@ public void testAutoExpandNumberOfReplicas0ToData() throws IOException {
allowNodes("test", 1);
logger.info("--> running cluster health");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForNodes(">=1")
@@ -254,7 +264,7 @@ public void testAutoExpandNumberOfReplicas0ToData() throws IOException {
assertThat(clusterHealth.getIndices().get("test").getNumberOfReplicas(), equalTo(0));
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries));
- final long afterClosingAnotherNodeSettingsVersion = clusterAdmin().prepareState()
+ final long afterClosingAnotherNodeSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.metadata()
@@ -271,7 +281,7 @@ public void testAutoExpandNumberReplicas1ToData() throws IOException {
NumShards numShards = getNumShards("test");
logger.info("--> running cluster health");
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForActiveShards(numShards.numPrimaries * 2)
@@ -286,7 +296,7 @@ public void testAutoExpandNumberReplicas1ToData() throws IOException {
if (randomBoolean()) {
assertAcked(indicesAdmin().prepareClose("test").setWaitForActiveShards(ActiveShardCount.ALL));
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForActiveShards(numShards.numPrimaries * 2)
@@ -299,12 +309,17 @@ public void testAutoExpandNumberReplicas1ToData() throws IOException {
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 2));
}
- final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long settingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
logger.info("--> add another node, should increase the number of replicas");
allowNodes("test", 3);
logger.info("--> running cluster health");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForActiveShards(numShards.numPrimaries * 3)
@@ -316,7 +331,7 @@ public void testAutoExpandNumberReplicas1ToData() throws IOException {
assertThat(clusterHealth.getIndices().get("test").getNumberOfReplicas(), equalTo(2));
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 3));
- final long afterAddingOneNodeSettingsVersion = clusterAdmin().prepareState()
+ final long afterAddingOneNodeSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.metadata()
@@ -329,7 +344,7 @@ public void testAutoExpandNumberReplicas1ToData() throws IOException {
allowNodes("test", 2);
logger.info("--> running cluster health");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForNodes(">=2")
@@ -342,7 +357,7 @@ public void testAutoExpandNumberReplicas1ToData() throws IOException {
assertThat(clusterHealth.getIndices().get("test").getNumberOfReplicas(), equalTo(1));
assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 2));
- final long afterClosingOneNodeSettingsVersion = clusterAdmin().prepareState()
+ final long afterClosingOneNodeSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.get()
.getState()
.metadata()
@@ -355,7 +370,7 @@ public void testAutoExpandNumberReplicas1ToData() throws IOException {
allowNodes("test", 1);
logger.info("--> running cluster health");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForYellowStatus()
.setWaitForNodes(">=1")
@@ -376,7 +391,7 @@ public void testAutoExpandNumberReplicas2() {
NumShards numShards = getNumShards("test");
logger.info("--> running cluster health");
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForActiveShards(numShards.numPrimaries * 3)
@@ -392,12 +407,17 @@ public void testAutoExpandNumberReplicas2() {
allowNodes("test", 4);
allowNodes("test", 5);
- final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long settingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
logger.info("--> update the auto expand replicas to 0-3");
updateIndexSettings(Settings.builder().put("auto_expand_replicas", "0-3"), "test");
logger.info("--> running cluster health");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
.setWaitForActiveShards(numShards.numPrimaries * 4)
@@ -414,14 +434,19 @@ public void testAutoExpandNumberReplicas2() {
* time from the number of replicas changed by the allocation service.
*/
assertThat(
- clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion(),
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test").getSettingsVersion(),
equalTo(1 + 1 + settingsVersion)
);
}
public void testUpdateWithInvalidNumberOfReplicas() {
createIndex("test");
- final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long settingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
final int value = randomIntBetween(-10, -1);
try {
indicesAdmin().prepareUpdateSettings("test")
@@ -431,7 +456,7 @@ public void testUpdateWithInvalidNumberOfReplicas() {
} catch (IllegalArgumentException e) {
assertEquals("Failed to parse value [" + value + "] for setting [index.number_of_replicas] must be >= 0", e.getMessage());
assertThat(
- clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion(),
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test").getSettingsVersion(),
equalTo(settingsVersion)
);
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java
index 6e58d275e578f..20089cd463bff 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java
@@ -64,7 +64,7 @@ public void testInvalidDynamicUpdate() {
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.dummy", "boom"))
);
assertEquals(exception.getCause().getMessage(), "this setting goes boom");
- IndexMetadata indexMetadata = clusterAdmin().prepareState().get().getState().metadata().index("test");
+ IndexMetadata indexMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test");
assertNotEquals(indexMetadata.getSettings().get("index.dummy"), "invalid dynamic value");
}
@@ -141,44 +141,48 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
public void testUpdateDependentClusterSettings() {
IllegalArgumentException iae = expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings().setPersistentSettings(Settings.builder().put("cluster.acc.test.pw", "asdf"))
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(Settings.builder().put("cluster.acc.test.pw", "asdf"))
);
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", iae.getMessage());
iae = expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings().setTransientSettings(Settings.builder().put("cluster.acc.test.pw", "asdf"))
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setTransientSettings(Settings.builder().put("cluster.acc.test.pw", "asdf"))
);
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", iae.getMessage());
iae = expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings()
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setTransientSettings(Settings.builder().put("cluster.acc.test.pw", "asdf"))
.setPersistentSettings(Settings.builder().put("cluster.acc.test.user", "asdf"))
);
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", iae.getMessage());
if (randomBoolean()) {
- clusterAdmin().prepareUpdateSettings()
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setTransientSettings(Settings.builder().put("cluster.acc.test.pw", "asdf").put("cluster.acc.test.user", "asdf"))
.get();
iae = expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings().setTransientSettings(Settings.builder().putNull("cluster.acc.test.user"))
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setTransientSettings(Settings.builder().putNull("cluster.acc.test.user"))
);
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", iae.getMessage());
- clusterAdmin().prepareUpdateSettings()
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setTransientSettings(Settings.builder().putNull("cluster.acc.test.pw").putNull("cluster.acc.test.user"))
.get();
} else {
- clusterAdmin().prepareUpdateSettings()
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().put("cluster.acc.test.pw", "asdf").put("cluster.acc.test.user", "asdf"))
.get();
iae = expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings().setPersistentSettings(Settings.builder().putNull("cluster.acc.test.user"))
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(Settings.builder().putNull("cluster.acc.test.user"))
);
assertEquals("missing required setting [cluster.acc.test.user] for setting [cluster.acc.test.pw]", iae.getMessage());
@@ -230,7 +234,7 @@ public void testResetDefaultWithWildcard() {
createIndex("test");
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.refresh_interval", -1)).get();
- IndexMetadata indexMetadata = clusterAdmin().prepareState().get().getState().metadata().index("test");
+ IndexMetadata indexMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test");
assertEquals(indexMetadata.getSettings().get("index.refresh_interval"), "-1");
for (IndicesService service : internalCluster().getInstances(IndicesService.class)) {
IndexService indexService = service.indexService(resolveIndex("test"));
@@ -239,7 +243,7 @@ public void testResetDefaultWithWildcard() {
}
}
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().putNull("index.ref*")).get();
- indexMetadata = clusterAdmin().prepareState().get().getState().metadata().index("test");
+ indexMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test");
assertNull(indexMetadata.getSettings().get("index.refresh_interval"));
for (IndicesService service : internalCluster().getInstances(IndicesService.class)) {
IndexService indexService = service.indexService(resolveIndex("test"));
@@ -259,7 +263,7 @@ public void testResetDefault() {
.put("index.translog.generation_threshold_size", "4096b")
)
.get();
- IndexMetadata indexMetadata = clusterAdmin().prepareState().get().getState().metadata().index("test");
+ IndexMetadata indexMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test");
assertEquals(indexMetadata.getSettings().get("index.refresh_interval"), "-1");
for (IndicesService service : internalCluster().getInstances(IndicesService.class)) {
IndexService indexService = service.indexService(resolveIndex("test"));
@@ -270,7 +274,7 @@ public void testResetDefault() {
}
}
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().putNull("index.refresh_interval")).get();
- indexMetadata = clusterAdmin().prepareState().get().getState().metadata().index("test");
+ indexMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test");
assertNull(indexMetadata.getSettings().get("index.refresh_interval"));
for (IndicesService service : internalCluster().getInstances(IndicesService.class)) {
IndexService indexService = service.indexService(resolveIndex("test"));
@@ -303,7 +307,7 @@ public void testOpenCloseUpdateSettings() throws Exception {
.put("index.final", "no")
) // this one can't
);
- IndexMetadata indexMetadata = clusterAdmin().prepareState().get().getState().metadata().index("test");
+ IndexMetadata indexMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test");
assertThat(indexMetadata.getSettings().get("index.refresh_interval"), nullValue());
assertThat(indexMetadata.getSettings().get("index.fielddata.cache"), nullValue());
assertThat(indexMetadata.getSettings().get("index.final"), nullValue());
@@ -318,7 +322,7 @@ public void testOpenCloseUpdateSettings() throws Exception {
.setSettings(Settings.builder().put("index.refresh_interval", -1)) // this one can change
.get();
- indexMetadata = clusterAdmin().prepareState().get().getState().metadata().index("test");
+ indexMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test");
assertThat(indexMetadata.getSettings().get("index.refresh_interval"), equalTo("-1"));
// Now verify via dedicated get settings api:
getSettingsResponse = indicesAdmin().prepareGetSettings("test").get();
@@ -327,7 +331,7 @@ public void testOpenCloseUpdateSettings() throws Exception {
// now close the index, change the non dynamic setting, and see that it applies
// Wait for the index to turn green before attempting to close it
- ClusterHealthResponse health = clusterAdmin().prepareHealth()
+ ClusterHealthResponse health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setTimeout(TimeValue.timeValueSeconds(30))
.setWaitForEvents(Priority.LANGUID)
.setWaitForGreenStatus()
@@ -338,7 +342,7 @@ public void testOpenCloseUpdateSettings() throws Exception {
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)).get();
- indexMetadata = clusterAdmin().prepareState().get().getState().metadata().index("test");
+ indexMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test");
assertThat(indexMetadata.getNumberOfReplicas(), equalTo(1));
indicesAdmin().prepareUpdateSettings("test")
@@ -349,7 +353,7 @@ public void testOpenCloseUpdateSettings() throws Exception {
) // this one can't
.get();
- indexMetadata = clusterAdmin().prepareState().get().getState().metadata().index("test");
+ indexMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test");
assertThat(indexMetadata.getSettings().get("index.refresh_interval"), equalTo("1s"));
assertThat(indexMetadata.getSettings().get("index.fielddata.cache"), equalTo("none"));
@@ -363,7 +367,7 @@ public void testOpenCloseUpdateSettings() throws Exception {
) // this one really can't
);
assertThat(ex.getMessage(), containsString("final test setting [index.final], not updateable"));
- indexMetadata = clusterAdmin().prepareState().get().getState().metadata().index("test");
+ indexMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test");
assertThat(indexMetadata.getSettings().get("index.refresh_interval"), equalTo("1s"));
assertThat(indexMetadata.getSettings().get("index.final"), nullValue());
@@ -426,22 +430,42 @@ public void testSettingsVersion() {
ensureGreen("test");
{
- final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long settingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
assertAcked(
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.refresh_interval", "500ms"))
);
- final long newSettingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long newSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
assertThat(newSettingsVersion, equalTo(1 + settingsVersion));
}
{
final boolean block = randomBoolean();
assertAcked(indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.blocks.read_only", block)));
- final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long settingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
assertAcked(
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.blocks.read_only", block == false))
);
- final long newSettingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long newSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
assertThat(newSettingsVersion, equalTo(1 + settingsVersion));
// if the read-only block is present, remove it
@@ -458,12 +482,22 @@ public void testSettingsVersionUnchanged() {
ensureGreen("test");
{
- final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long settingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
final String refreshInterval = indicesAdmin().prepareGetSettings("test").get().getSetting("test", "index.refresh_interval");
assertAcked(
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.refresh_interval", refreshInterval))
);
- final long newSettingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long newSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
assertThat(newSettingsVersion, equalTo(settingsVersion));
}
@@ -471,9 +505,19 @@ public void testSettingsVersionUnchanged() {
final boolean block = randomBoolean();
assertAcked(indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.blocks.read_only", block)));
// now put the same block again
- final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long settingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
assertAcked(indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.blocks.read_only", block)));
- final long newSettingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long newSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
assertThat(newSettingsVersion, equalTo(settingsVersion));
// if the read-only block is present, remove it
@@ -493,14 +537,24 @@ public void testSettingsVersionUnchanged() {
public void testNumberOfReplicasSettingsVersionUnchanged() {
createIndex("test");
- final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long settingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
final int numberOfReplicas = Integer.valueOf(
indicesAdmin().prepareGetSettings("test").get().getSetting("test", "index.number_of_replicas")
);
assertAcked(
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.number_of_replicas", numberOfReplicas))
);
- final long newSettingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long newSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
assertThat(newSettingsVersion, equalTo(settingsVersion));
}
@@ -512,7 +566,12 @@ public void testNumberOfReplicasSettingsVersionUnchanged() {
public void testNumberOfReplicasSettingsVersion() {
createIndex("test");
- final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long settingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
final int numberOfReplicas = Integer.valueOf(
indicesAdmin().prepareGetSettings("test").get().getSetting("test", "index.number_of_replicas")
);
@@ -520,7 +579,12 @@ public void testNumberOfReplicasSettingsVersion() {
indicesAdmin().prepareUpdateSettings("test")
.setSettings(Settings.builder().put("index.number_of_replicas", 1 + numberOfReplicas))
);
- final long newSettingsVersion = clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion();
+ final long newSettingsVersion = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .metadata()
+ .index("test")
+ .getSettingsVersion();
assertThat(newSettingsVersion, equalTo(1 + settingsVersion));
}
@@ -574,7 +638,7 @@ public void testNoopUpdate() {
indicesAdmin().prepareUpdateSettings("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1))
);
assertNotSame(currentState, clusterService.state());
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForGreenStatus()
.setWaitForNoInitializingShards(true)
.setWaitForNoRelocatingShards(true)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllIT.java
index 6b1aafe2f9b17..5501b88d8a267 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/state/CloseIndexDisableCloseAllIT.java
@@ -47,7 +47,7 @@ public void testCloseAllRequiresName() {
}
private void assertIndexIsClosed(String... indices) {
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
for (String index : indices) {
IndexMetadata indexMetadata = clusterStateResponse.getState().metadata().indices().get(index);
assertNotNull(indexMetadata);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/state/CloseIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/state/CloseIndexIT.java
index d52294d7584b8..3947ae6d2b577 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/state/CloseIndexIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/state/CloseIndexIT.java
@@ -162,7 +162,7 @@ public void testCloseUnassignedIndex() throws Exception {
.setSettings(Settings.builder().put("index.routing.allocation.include._name", "nothing").build())
);
- final ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ final ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(clusterState.metadata().indices().get(indexName).getState(), is(IndexMetadata.State.OPEN));
assertThat(clusterState.routingTable().allShards().allMatch(ShardRouting::unassigned), is(true));
@@ -182,7 +182,7 @@ public void testConcurrentClose() throws InterruptedException, ExecutionExceptio
IntStream.range(0, nbDocs).mapToObj(i -> prepareIndex(indexName).setId(String.valueOf(i)).setSource("num", i)).collect(toList())
);
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(indexName)
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, indexName)
.setWaitForYellowStatus()
.setWaitForEvents(Priority.LANGUID)
.setWaitForNoRelocatingShards(true)
@@ -243,7 +243,7 @@ public void testCloseWhileDeletingIndices() throws Exception {
}
indices[i] = indexName;
}
- assertThat(clusterAdmin().prepareState().get().getState().metadata().indices().size(), equalTo(indices.length));
+ assertThat(clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().indices().size(), equalTo(indices.length));
startInParallel(indices.length * 2, i -> {
final String index = indices[i % indices.length];
@@ -285,7 +285,7 @@ public void testConcurrentClosesAndOpens() throws Exception {
indexer.stopAndAwaitStopped();
- final ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ final ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
if (clusterState.metadata().indices().get(indexName).getState() == IndexMetadata.State.CLOSE) {
assertIndexIsClosed(indexName);
assertAcked(indicesAdmin().prepareOpen(indexName));
@@ -310,7 +310,7 @@ public void testCloseIndexWaitForActiveShards() throws Exception {
ensureGreen(indexName);
final CloseIndexResponse closeIndexResponse = indicesAdmin().prepareClose(indexName).get();
- assertThat(clusterAdmin().prepareHealth(indexName).get().getStatus(), is(ClusterHealthStatus.GREEN));
+ assertThat(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, indexName).get().getStatus(), is(ClusterHealthStatus.GREEN));
assertTrue(closeIndexResponse.isAcknowledged());
assertTrue(closeIndexResponse.isShardsAcknowledged());
assertThat(closeIndexResponse.getIndices().get(0), notNullValue());
@@ -532,7 +532,7 @@ private static void closeIndices(final CloseIndexRequestBuilder requestBuilder)
}
static void assertIndexIsClosed(final String... indices) {
- final ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ final ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
for (String index : indices) {
final IndexMetadata indexMetadata = clusterState.metadata().indices().get(index);
assertThat(indexMetadata.getState(), is(IndexMetadata.State.CLOSE));
@@ -555,7 +555,7 @@ static void assertIndexIsClosed(final String... indices) {
}
static void assertIndexIsOpened(final String... indices) {
- final ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ final ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
for (String index : indices) {
final IndexMetadata indexMetadata = clusterState.metadata().indices().get(index);
assertThat(indexMetadata.getState(), is(IndexMetadata.State.OPEN));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java
index a7a2af57ef810..9ec7ebcf91535 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java
@@ -49,7 +49,7 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
public void testSimpleCloseOpen() {
Client client = client();
createIndex("test1");
- ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
AcknowledgedResponse closeIndexResponse = client.admin().indices().prepareClose("test1").get();
@@ -70,7 +70,7 @@ public void testSimpleOpenMissingIndex() {
public void testOpenOneMissingIndex() {
Client client = client();
createIndex("test1");
- ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
Exception e = expectThrows(IndexNotFoundException.class, client.admin().indices().prepareOpen("test1", "test2"));
assertThat(e.getMessage(), is("no such index [test2]"));
@@ -79,7 +79,7 @@ public void testOpenOneMissingIndex() {
public void testOpenOneMissingIndexIgnoreMissing() {
Client client = client();
createIndex("test1");
- ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
OpenIndexResponse openIndexResponse = client.admin()
.indices()
@@ -94,7 +94,7 @@ public void testOpenOneMissingIndexIgnoreMissing() {
public void testCloseOpenMultipleIndices() {
Client client = client();
createIndex("test1", "test2", "test3");
- ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
AcknowledgedResponse closeIndexResponse1 = client.admin().indices().prepareClose("test1").get();
@@ -116,7 +116,7 @@ public void testCloseOpenMultipleIndices() {
public void testCloseOpenWildcard() {
Client client = client();
createIndex("test1", "test2", "a");
- ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
AcknowledgedResponse closeIndexResponse = client.admin().indices().prepareClose("test*").get();
@@ -133,7 +133,7 @@ public void testCloseOpenWildcard() {
public void testCloseOpenAll() {
Client client = client();
createIndex("test1", "test2", "test3");
- ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
AcknowledgedResponse closeIndexResponse = client.admin().indices().prepareClose("_all").get();
@@ -149,7 +149,7 @@ public void testCloseOpenAll() {
public void testCloseOpenAllWildcard() {
Client client = client();
createIndex("test1", "test2", "test3");
- ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
AcknowledgedResponse closeIndexResponse = client.admin().indices().prepareClose("*").get();
@@ -175,7 +175,7 @@ public void testOpenNullIndex() {
public void testOpenAlreadyOpenedIndex() {
Client client = client();
createIndex("test1");
- ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
// no problem if we try to open an index that's already in open state
@@ -188,7 +188,7 @@ public void testOpenAlreadyOpenedIndex() {
public void testSimpleCloseOpenAlias() {
Client client = client();
createIndex("test1");
- ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
AcknowledgedResponse aliasesResponse = client.admin().indices().prepareAliases().addAlias("test1", "test1-alias").get();
@@ -207,7 +207,7 @@ public void testSimpleCloseOpenAlias() {
public void testCloseOpenAliasMultipleIndices() {
Client client = client();
createIndex("test1", "test2");
- ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().get();
+ ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
assertThat(healthResponse.isTimedOut(), equalTo(false));
AcknowledgedResponse aliasesResponse1 = client.admin().indices().prepareAliases().addAlias("test1", "test-alias").get();
@@ -240,7 +240,7 @@ public void testOpenWaitingForActiveShardsFailed() throws Exception {
assertThat(response.isShardsAcknowledged(), equalTo(false));
assertBusy(
() -> assertThat(
- client.admin().cluster().prepareState().get().getState().metadata().index("test").getState(),
+ client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().index("test").getState(),
equalTo(IndexMetadata.State.OPEN)
)
);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/state/ReopenWhileClosingIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/state/ReopenWhileClosingIT.java
index 3c16e0f2624ed..1b0b71b86f074 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/state/ReopenWhileClosingIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/state/ReopenWhileClosingIT.java
@@ -159,7 +159,7 @@ private Releasable interceptVerifyShardBeforeCloseActions(final String indexPatt
}
private static void assertIndexIsBlocked(final String... indices) {
- final ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ final ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
for (String index : indices) {
assertThat(clusterState.metadata().indices().get(index).getState(), is(IndexMetadata.State.OPEN));
assertThat(clusterState.routingTable().index(index), notNullValue());
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/state/SimpleIndexStateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/state/SimpleIndexStateIT.java
index b5448498f0ce9..c62f1776178ba 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/state/SimpleIndexStateIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/state/SimpleIndexStateIT.java
@@ -34,7 +34,7 @@ public void testSimpleOpenClose() {
NumShards numShards = getNumShards("test");
- ClusterStateResponse stateResponse = clusterAdmin().prepareState().get();
+ ClusterStateResponse stateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(stateResponse.getState().metadata().index("test").getState(), equalTo(IndexMetadata.State.OPEN));
assertThat(stateResponse.getState().routingTable().index("test").size(), equalTo(numShards.numPrimaries));
assertEquals(
@@ -48,7 +48,7 @@ public void testSimpleOpenClose() {
logger.info("--> closing test index...");
assertAcked(indicesAdmin().prepareClose("test"));
- stateResponse = clusterAdmin().prepareState().get();
+ stateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(stateResponse.getState().metadata().index("test").getState(), equalTo(IndexMetadata.State.CLOSE));
assertThat(stateResponse.getState().routingTable().index("test"), notNullValue());
@@ -66,7 +66,7 @@ public void testSimpleOpenClose() {
logger.info("--> waiting for green status");
ensureGreen();
- stateResponse = clusterAdmin().prepareState().get();
+ stateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(stateResponse.getState().metadata().index("test").getState(), equalTo(IndexMetadata.State.OPEN));
assertThat(stateResponse.getState().routingTable().index("test").size(), equalTo(numShards.numPrimaries));
@@ -86,7 +86,7 @@ public void testFastCloseAfterCreateContinuesCreateAfterOpen() {
.setSettings(Settings.builder().put("index.routing.allocation.include.tag", "no_such_node").build())
.get();
- ClusterHealthResponse health = clusterAdmin().prepareHealth("test").setWaitForNodes(">=2").get();
+ ClusterHealthResponse health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test").setWaitForNodes(">=2").get();
assertThat(health.isTimedOut(), equalTo(false));
assertThat(health.getStatus(), equalTo(ClusterHealthStatus.RED));
@@ -102,7 +102,7 @@ public void testFastCloseAfterCreateContinuesCreateAfterOpen() {
NumShards numShards = getNumShards("test");
- ClusterStateResponse stateResponse = clusterAdmin().prepareState().get();
+ ClusterStateResponse stateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(stateResponse.getState().metadata().index("test").getState(), equalTo(IndexMetadata.State.OPEN));
assertThat(stateResponse.getState().routingTable().index("test").size(), equalTo(numShards.numPrimaries));
assertEquals(
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/stats/IndexStatsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/stats/IndexStatsIT.java
index 7ffc2539d2fa0..083823523afaa 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/stats/IndexStatsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/stats/IndexStatsIT.java
@@ -237,7 +237,7 @@ public void testClearAllCaches() throws Exception {
.setMapping("field", "type=text,fielddata=true")
);
ensureGreen();
- clusterAdmin().prepareHealth().setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForGreenStatus().get();
prepareIndex("test").setId("1").setSource("field", "value1").get();
prepareIndex("test").setId("2").setSource("field", "value2").get();
indicesAdmin().prepareRefresh().get();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java
index 5eeb07968ce4d..58c1a30cb5513 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/store/IndicesStoreIntegrationIT.java
@@ -98,7 +98,7 @@ public void testIndexCleanup() throws Exception {
)
);
ensureGreen("test");
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
Index index = state.metadata().index("test").getIndex();
logger.info("--> making sure that shard and its replica are allocated on node_1 and node_2");
@@ -110,7 +110,10 @@ public void testIndexCleanup() throws Exception {
logger.info("--> starting node server3");
final String node_3 = internalCluster().startNode(nonMasterNode());
logger.info("--> running cluster_health");
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth().setWaitForNodes("4").setWaitForNoRelocatingShards(true).get();
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForNodes("4")
+ .setWaitForNoRelocatingShards(true)
+ .get();
assertThat(clusterHealth.isTimedOut(), equalTo(false));
assertThat(Files.exists(shardDirectory(node_1, index, 0)), equalTo(true));
@@ -131,7 +134,7 @@ public void testIndexCleanup() throws Exception {
} else {
ClusterRerouteUtils.reroute(internalCluster().client(), new MoveAllocationCommand("test", 0, node_1, node_3));
}
- clusterHealth = clusterAdmin().prepareHealth().setWaitForNoRelocatingShards(true).get();
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNoRelocatingShards(true).get();
assertThat(clusterHealth.isTimedOut(), equalTo(false));
assertShardDeleted(node_1, index, 0);
@@ -197,13 +200,13 @@ public void testShardCleanupIfShardDeletionAfterRelocationFailedAndIndexDeleted(
)
);
ensureGreen("test");
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
Index index = state.metadata().index("test").getIndex();
assertThat(Files.exists(shardDirectory(node_1, index, 0)), equalTo(true));
assertThat(Files.exists(indexDirectory(node_1, index)), equalTo(true));
final String node_2 = internalCluster().startDataOnlyNode(Settings.builder().build());
- assertFalse(clusterAdmin().prepareHealth().setWaitForNodes("2").get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("2").get().isTimedOut());
assertThat(Files.exists(shardDirectory(node_1, index, 0)), equalTo(true));
assertThat(Files.exists(indexDirectory(node_1, index)), equalTo(true));
@@ -226,7 +229,7 @@ public void testShardCleanupIfShardDeletionAfterRelocationFailedAndIndexDeleted(
logger.info("--> move shard from {} to {}, and wait for relocation to finish", node_1, node_2);
ClusterRerouteUtils.reroute(client(), new MoveAllocationCommand("test", 0, node_1, node_2));
shardActiveRequestSent.await();
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth().setWaitForNoRelocatingShards(true).get();
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNoRelocatingShards(true).get();
assertThat(clusterHealth.isTimedOut(), equalTo(false));
logClusterState();
// delete the index. node_1 that still waits for the next cluster state update will then get the delete index next.
@@ -258,7 +261,7 @@ public void testShardsCleanup() throws Exception {
);
ensureGreen("test");
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
Index index = state.metadata().index("test").getIndex();
logger.info("--> making sure that shard and its replica are allocated on node_1 and node_2");
assertThat(Files.exists(shardDirectory(node_1, index, 0)), equalTo(true));
@@ -267,7 +270,10 @@ public void testShardsCleanup() throws Exception {
logger.info("--> starting node server3");
String node_3 = internalCluster().startNode();
logger.info("--> running cluster_health");
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth().setWaitForNodes("3").setWaitForNoRelocatingShards(true).get();
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForNodes("3")
+ .setWaitForNoRelocatingShards(true)
+ .get();
assertThat(clusterHealth.isTimedOut(), equalTo(false));
logger.info("--> making sure that shard is not allocated on server3");
@@ -278,7 +284,7 @@ public void testShardsCleanup() throws Exception {
internalCluster().stopNode(node_2);
logger.info("--> running cluster_health");
- clusterHealth = clusterAdmin().prepareHealth()
+ clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForGreenStatus()
.setWaitForNodes("2")
.setWaitForNoRelocatingShards(true)
@@ -325,7 +331,7 @@ public void testShardActiveElsewhereDoesNotDeleteAnother() throws Exception {
)
);
assertFalse(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForNoRelocatingShards(true)
.setWaitForGreenStatus()
.setWaitForNodes("5")
@@ -344,7 +350,7 @@ public void testShardActiveElsewhereDoesNotDeleteAnother() throws Exception {
internalCluster().stopNode(nodesToShutDown.get(1));
logger.debug("--> verifying index is red");
- ClusterHealthResponse health = clusterAdmin().prepareHealth().setWaitForNodes("3").get();
+ ClusterHealthResponse health = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("3").get();
if (health.getStatus() != ClusterHealthStatus.RED) {
logClusterState();
fail("cluster didn't become red, despite of shutting 2 of 3 nodes");
@@ -362,7 +368,7 @@ public void testShardActiveElsewhereDoesNotDeleteAnother() throws Exception {
assertBusy(() -> assertTrue(internalCluster().getInstance(IndicesService.class, node4).hasIndex(index)));
// wait for 4 active shards - we should have lost one shard
- assertFalse(clusterAdmin().prepareHealth().setWaitForActiveShards(4).get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForActiveShards(4).get().isTimedOut());
// disable allocation again to control concurrency a bit and allow shard active to kick in before allocation
updateClusterSettings(Settings.builder().put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "none"));
@@ -371,7 +377,7 @@ public void testShardActiveElsewhereDoesNotDeleteAnother() throws Exception {
internalCluster().startNodes(node1DataPathSettings, node2DataPathSettings);
- assertFalse(clusterAdmin().prepareHealth().setWaitForNodes("5").get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("5").get().isTimedOut());
updateClusterSettings(Settings.builder().put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "all"));
@@ -395,7 +401,7 @@ public void testShardActiveElseWhere() throws Exception {
ensureGreen("test");
waitNoPendingTasksOnAll();
- ClusterStateResponse stateResponse = clusterAdmin().prepareState().get();
+ ClusterStateResponse stateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
final Index index = stateResponse.getState().metadata().index("test").getIndex();
RoutingNode routingNode = stateResponse.getState().getRoutingNodes().node(nonMasterId);
final int[] node2Shards = new int[routingNode.numberOfOwningShards()];
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java
index 1e1333f376e9f..4051dba84588a 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java
@@ -178,7 +178,7 @@ public void testSimpleIndexTemplateTests() throws Exception {
}
public void testDeleteIndexTemplate() throws Exception {
- final int existingTemplates = admin().cluster().prepareState().get().getState().metadata().templates().size();
+ final int existingTemplates = admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().templates().size();
logger.info("--> put template_1 and template_2");
indicesAdmin().preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
@@ -223,7 +223,7 @@ public void testDeleteIndexTemplate() throws Exception {
logger.info("--> explicitly delete template_1");
indicesAdmin().prepareDeleteTemplate("template_1").get();
- ClusterState state = admin().cluster().prepareState().get().getState();
+ ClusterState state = admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(state.metadata().templates().size(), equalTo(1 + existingTemplates));
assertThat(state.metadata().templates().containsKey("template_2"), equalTo(true));
@@ -254,11 +254,14 @@ public void testDeleteIndexTemplate() throws Exception {
logger.info("--> delete template*");
indicesAdmin().prepareDeleteTemplate("template*").get();
- assertThat(admin().cluster().prepareState().get().getState().metadata().templates().size(), equalTo(existingTemplates));
+ assertThat(
+ admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().templates().size(),
+ equalTo(existingTemplates)
+ );
logger.info("--> delete * with no templates, make sure we don't get a failure");
indicesAdmin().prepareDeleteTemplate("*").get();
- assertThat(admin().cluster().prepareState().get().getState().metadata().templates().size(), equalTo(0));
+ assertThat(admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().templates().size(), equalTo(0));
}
public void testThatGetIndexTemplatesWorks() throws Exception {
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestFileSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestFileSettingsIT.java
index a3c43de39218d..0fa1ef1208593 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestFileSettingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestFileSettingsIT.java
@@ -158,7 +158,7 @@ private void assertPipelinesSaveOK(CountDownLatch savedClusterState, AtomicLong
assertTrue(awaitSuccessful);
final ClusterStateResponse clusterStateResponse = clusterAdmin().state(
- new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get())
+ new ClusterStateRequest(TEST_REQUEST_TIMEOUT).waitForMetadataVersion(metadataVersion.get())
).get();
ReservedStateMetadata reservedState = clusterStateResponse.getState()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/nodescapabilities/SimpleNodesCapabilitiesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/nodescapabilities/SimpleNodesCapabilitiesIT.java
index 9b60044c94f70..eec90241fd902 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/nodescapabilities/SimpleNodesCapabilitiesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/nodescapabilities/SimpleNodesCapabilitiesIT.java
@@ -24,7 +24,10 @@ public class SimpleNodesCapabilitiesIT extends ESIntegTestCase {
public void testNodesCapabilities() throws IOException {
internalCluster().startNodes(2);
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").get();
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForGreenStatus()
+ .setWaitForNodes("2")
+ .get();
logger.info("--> done cluster_health, status {}", clusterHealth.getStatus());
// check we support the capabilities API itself. Which we do.
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java b/server/src/internalClusterTest/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java
index a5700c319aa59..e4c83c81a7684 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/nodesinfo/SimpleNodesInfoIT.java
@@ -33,7 +33,10 @@ public void testNodesInfos() {
final String node_1 = nodesNames.get(0);
final String node_2 = nodesNames.get(1);
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").get();
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForGreenStatus()
+ .setWaitForNodes("2")
+ .get();
logger.info("--> done cluster_health, status {}", clusterHealth.getStatus());
String server1NodeId = getNodeId(node_1);
@@ -72,7 +75,10 @@ public void testNodesInfosTotalIndexingBuffer() {
final String node_1 = nodesNames.get(0);
final String node_2 = nodesNames.get(1);
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").get();
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForGreenStatus()
+ .setWaitForNodes("2")
+ .get();
logger.info("--> done cluster_health, status {}", clusterHealth.getStatus());
String server1NodeId = getNodeId(node_1);
@@ -110,7 +116,10 @@ public void testAllocatedProcessors() throws Exception {
final String node_1 = nodeNames.get(0);
final String node_2 = nodeNames.get(1);
- ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").get();
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
+ .setWaitForGreenStatus()
+ .setWaitForNodes("2")
+ .get();
logger.info("--> done cluster_health, status {}", clusterHealth.getStatus());
String server1NodeId = getNodeId(node_1);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIT.java
index a49fadb0c4b5b..a851ecb11c798 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/operateAllIndices/DestructiveOperationsIT.java
@@ -84,7 +84,7 @@ public void testCloseIndexDefaultBehaviour() throws Exception {
assertAcked(indicesAdmin().prepareClose("*").get());
}
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
for (Map.Entry indexMetadataEntry : state.getMetadata().indices().entrySet()) {
assertEquals(IndexMetadata.State.CLOSE, indexMetadataEntry.getValue().getState());
}
@@ -117,7 +117,7 @@ public void testOpenIndexDefaultBehaviour() throws Exception {
assertAcked(indicesAdmin().prepareOpen("*").get());
}
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
for (Map.Entry indexMetadataEntry : state.getMetadata().indices().entrySet()) {
assertEquals(IndexMetadata.State.OPEN, indexMetadataEntry.getValue().getState());
}
@@ -150,7 +150,7 @@ public void testAddIndexBlockDefaultBehaviour() throws Exception {
assertAcked(indicesAdmin().prepareAddBlock(WRITE, "*").get());
}
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertTrue("write block is set on index1", state.getBlocks().hasIndexBlock("index1", IndexMetadata.INDEX_WRITE_BLOCK));
assertTrue("write block is set on 1index", state.getBlocks().hasIndexBlock("1index", IndexMetadata.INDEX_WRITE_BLOCK));
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/persistent/decider/EnableAssignmentDeciderIT.java b/server/src/internalClusterTest/java/org/elasticsearch/persistent/decider/EnableAssignmentDeciderIT.java
index e7d23f97fc992..caaea0a8a3846 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/persistent/decider/EnableAssignmentDeciderIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/persistent/decider/EnableAssignmentDeciderIT.java
@@ -110,7 +110,7 @@ public void testEnableAssignmentAfterRestart() throws Exception {
}
private void assertEnableAssignmentSetting(final Allocation expected) {
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().clear().setMetadata(true).get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).clear().setMetadata(true).get();
Settings settings = clusterStateResponse.getState().getMetadata().settings();
String value = settings.get(CLUSTER_TASKS_ALLOCATION_ENABLE_SETTING.getKey());
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/plugins/IndexFoldersDeletionListenerIT.java b/server/src/internalClusterTest/java/org/elasticsearch/plugins/IndexFoldersDeletionListenerIT.java
index db26d630fefea..21aa8a8770359 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/plugins/IndexFoldersDeletionListenerIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/plugins/IndexFoldersDeletionListenerIT.java
@@ -73,7 +73,7 @@ public void testListenersInvokedWhenIndexIsDeleted() throws Exception {
final NumShards numShards = getNumShards(indexName);
assertFalse(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices(indexName)
.setWaitForGreenStatus()
.setWaitForEvents(Priority.LANGUID)
@@ -140,7 +140,7 @@ public void testListenersInvokedWhenIndexIsRelocated() throws Exception {
final NumShards numShards = getNumShards(indexName);
assertFalse(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices(indexName)
.setWaitForGreenStatus()
.setWaitForEvents(Priority.LANGUID)
@@ -206,7 +206,7 @@ public void testListenersInvokedWhenIndexIsDangling() throws Exception {
final NumShards numShards = getNumShards(indexName);
assertFalse(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setIndices(indexName)
.setWaitForGreenStatus()
.setWaitForEvents(Priority.LANGUID)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/readiness/ReadinessClusterIT.java b/server/src/internalClusterTest/java/org/elasticsearch/readiness/ReadinessClusterIT.java
index 8335b3c0c4249..6be1612c32ad8 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/readiness/ReadinessClusterIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/readiness/ReadinessClusterIT.java
@@ -111,13 +111,16 @@ protected Collection> getMockPlugins() {
}
private void assertMasterNode(Client client, String node) {
- assertThat(client.admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(), equalTo(node));
+ assertThat(
+ client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getMasterNode().getName(),
+ equalTo(node)
+ );
}
private void expectMasterNotFound() {
expectThrows(
MasterNotDiscoveredException.class,
- clusterAdmin().prepareState().setMasterNodeTimeout(TimeValue.timeValueMillis(100))
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).setMasterNodeTimeout(TimeValue.timeValueMillis(100))
);
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/recovery/FullRollingRestartIT.java b/server/src/internalClusterTest/java/org/elasticsearch/recovery/FullRollingRestartIT.java
index da59d306d4119..adc9db1cb3ed1 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/recovery/FullRollingRestartIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/recovery/FullRollingRestartIT.java
@@ -62,7 +62,7 @@ public void testFullRollingRestart() throws Exception {
// make sure the cluster state is green, and all has been recovered
assertTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(healthTimeout)
.setWaitForGreenStatus()
@@ -76,7 +76,7 @@ public void testFullRollingRestart() throws Exception {
// make sure the cluster state is green, and all has been recovered
assertTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(healthTimeout)
.setWaitForGreenStatus()
@@ -94,7 +94,7 @@ public void testFullRollingRestart() throws Exception {
internalCluster().stopRandomDataNode();
// make sure the cluster state is green, and all has been recovered
assertTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(healthTimeout)
.setWaitForGreenStatus()
@@ -105,7 +105,7 @@ public void testFullRollingRestart() throws Exception {
internalCluster().stopRandomDataNode();
// make sure the cluster state is green, and all has been recovered
assertTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(healthTimeout)
.setWaitForGreenStatus()
@@ -123,7 +123,7 @@ public void testFullRollingRestart() throws Exception {
internalCluster().stopRandomDataNode();
// make sure the cluster state is green, and all has been recovered
assertTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(healthTimeout)
.setWaitForGreenStatus()
@@ -135,7 +135,7 @@ public void testFullRollingRestart() throws Exception {
// make sure the cluster state is yellow, and all has been recovered
assertTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(healthTimeout)
.setWaitForYellowStatus()
@@ -168,7 +168,7 @@ public void testNoRebalanceOnRollingRestart() throws Exception {
prepareIndex("test").setId(Long.toString(i)).setSource(Map.of("test", "value" + i)).get();
}
ensureGreen();
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
RecoveryResponse recoveryResponse = indicesAdmin().prepareRecoveries("test").get();
for (RecoveryState recoveryState : recoveryResponse.shardRecoveryStates().get("test")) {
assertNotEquals(
@@ -186,7 +186,7 @@ public void testNoRebalanceOnRollingRestart() throws Exception {
}
internalCluster().restartRandomDataNode();
ensureGreen();
- clusterAdmin().prepareState().get();
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
recoveryResponse = indicesAdmin().prepareRecoveries("test").get();
for (RecoveryState recoveryState : recoveryResponse.shardRecoveryStates().get("test")) {
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java b/server/src/internalClusterTest/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java
index 70aabbc8c30d5..c066e3098df6f 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadIT.java
@@ -102,7 +102,7 @@ public void testRecoverWhileUnderLoadAllocateReplicasTest() throws Exception {
logger.info("--> waiting for GREEN health status ...");
// make sure the cluster state is green, and all has been recovered
assertNoTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueMinutes(5))
.setWaitForGreenStatus()
@@ -163,7 +163,7 @@ public void testRecoverWhileUnderLoadAllocateReplicasRelocatePrimariesTest() thr
logger.info("--> waiting for GREEN health status ...");
assertNoTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueMinutes(5))
.setWaitForGreenStatus()
@@ -225,7 +225,7 @@ public void testRecoverWhileUnderLoadWithReducedAllowedNodes() throws Exception
logger.info("--> waiting for GREEN health status ...");
assertNoTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueMinutes(5))
.setWaitForGreenStatus()
@@ -242,7 +242,7 @@ public void testRecoverWhileUnderLoadWithReducedAllowedNodes() throws Exception
allowNodes("test", 3);
logger.info("--> waiting for relocations ...");
assertNoTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueMinutes(5))
.setWaitForNoRelocatingShards(true)
@@ -252,7 +252,7 @@ public void testRecoverWhileUnderLoadWithReducedAllowedNodes() throws Exception
allowNodes("test", 2);
logger.info("--> waiting for relocations ...");
assertNoTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueMinutes(5))
.setWaitForNoRelocatingShards(true)
@@ -262,7 +262,7 @@ public void testRecoverWhileUnderLoadWithReducedAllowedNodes() throws Exception
allowNodes("test", 1);
logger.info("--> waiting for relocations ...");
assertNoTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueMinutes(5))
.setWaitForNoRelocatingShards(true)
@@ -273,7 +273,7 @@ public void testRecoverWhileUnderLoadWithReducedAllowedNodes() throws Exception
logger.info("--> indexing threads stopped");
assertNoTimeout(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueMinutes(5))
.setWaitForNoRelocatingShards(true)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/recovery/RelocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/recovery/RelocationIT.java
index 17daf403e0566..52a95b2065866 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/recovery/RelocationIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/recovery/RelocationIT.java
@@ -140,7 +140,7 @@ public void testSimpleRelocationNoIndexing() {
logger.info("--> start another node");
final String node_2 = internalCluster().startNode();
- ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes("2")
.get();
@@ -149,7 +149,7 @@ public void testSimpleRelocationNoIndexing() {
logger.info("--> relocate the shard from node1 to node2");
ClusterRerouteUtils.reroute(client(), new MoveAllocationCommand("test", 0, node_1, node_2));
- clusterHealthResponse = clusterAdmin().prepareHealth()
+ clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNoRelocatingShards(true)
.setTimeout(ACCEPTABLE_RELOCATION_TIME)
@@ -184,7 +184,7 @@ public void testRelocationWhileIndexingRandom() throws Exception {
logger.info("--> starting [node{}] ...", i);
nodes[i - 1] = internalCluster().startNode();
if (i != numberOfNodes) {
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth()
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes(Integer.toString(i))
.setWaitForGreenStatus()
@@ -215,7 +215,7 @@ public void testRelocationWhileIndexingRandom() throws Exception {
logger.debug("--> flushing");
indicesAdmin().prepareFlush().get();
}
- ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNoRelocatingShards(true)
.setTimeout(ACCEPTABLE_RELOCATION_TIME)
@@ -288,7 +288,7 @@ public void testRelocationWhileRefreshing() throws Exception {
logger.info("--> starting [node_{}] ...", i);
nodes[i] = internalCluster().startNode();
if (i != numberOfNodes - 1) {
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth()
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes(Integer.toString(i + 1))
.setWaitForGreenStatus()
@@ -349,7 +349,7 @@ public void indexShardStateChanged(
// verify cluster was finished.
assertFalse(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForNoRelocatingShards(true)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueSeconds(30))
@@ -390,7 +390,7 @@ public void testCancellationCleansTempFiles() throws Exception {
requests.add(prepareIndex(indexName).setSource("{}", XContentType.JSON));
}
indexRandom(true, requests);
- assertFalse(clusterAdmin().prepareHealth().setWaitForNodes("3").setWaitForGreenStatus().get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForNodes("3").setWaitForGreenStatus().get().isTimedOut());
flush();
int allowedFailures = randomIntBetween(3, 5); // the default of the `index.allocation.max_retries` is 5.
@@ -418,7 +418,7 @@ public void testCancellationCleansTempFiles() throws Exception {
if (node.equals(p_node)) {
continue;
}
- ClusterState state = client(node).admin().cluster().prepareState().setLocal(true).get().getState();
+ ClusterState state = client(node).admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).setLocal(true).get().getState();
assertThat(
node + " indicates assigned replicas",
state.getRoutingTable().index(indexName).shardsWithState(ShardRoutingState.UNASSIGNED).size(),
@@ -551,7 +551,7 @@ public void testRelocateWhileWaitingForRefresh() {
logger.info("--> start another node");
final String node2 = internalCluster().startNode();
- ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes("2")
.get();
@@ -560,7 +560,7 @@ public void testRelocateWhileWaitingForRefresh() {
logger.info("--> relocate the shard from node1 to node2");
ClusterRerouteUtils.reroute(client(), new MoveAllocationCommand("test", 0, node1, node2));
- clusterHealthResponse = clusterAdmin().prepareHealth()
+ clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNoRelocatingShards(true)
.setTimeout(ACCEPTABLE_RELOCATION_TIME)
@@ -602,7 +602,7 @@ public void testRelocateWhileContinuouslyIndexingAndWaitingForRefresh() throws E
logger.info("--> start another node");
final String node2 = internalCluster().startNode();
- ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth()
+ ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes("2")
.get();
@@ -623,7 +623,7 @@ public void testRelocateWhileContinuouslyIndexingAndWaitingForRefresh() throws E
);
}
safeGet(relocationListener);
- clusterHealthResponse = clusterAdmin().prepareHealth()
+ clusterHealthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNoRelocatingShards(true)
.setTimeout(ACCEPTABLE_RELOCATION_TIME)
@@ -670,7 +670,7 @@ public void testRelocationEstablishedPeerRecoveryRetentionLeases() throws Except
private void assertActiveCopiesEstablishedPeerRecoveryRetentionLeases() throws Exception {
assertBusy(() -> {
- for (String index : clusterAdmin().prepareState().get().getState().metadata().indices().keySet()) {
+ for (String index : clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().indices().keySet()) {
Map> byShardId = Stream.of(indicesAdmin().prepareStats(index).get().getShards())
.collect(Collectors.groupingBy(l -> l.getShardRouting().shardId()));
for (List shardStats : byShardId.values()) {
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/recovery/RestartInactiveAutoExpandReplicaNotStaleIT.java b/server/src/internalClusterTest/java/org/elasticsearch/recovery/RestartInactiveAutoExpandReplicaNotStaleIT.java
index 0b56eb36c08e4..a1aecab66bbfc 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/recovery/RestartInactiveAutoExpandReplicaNotStaleIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/recovery/RestartInactiveAutoExpandReplicaNotStaleIT.java
@@ -28,7 +28,7 @@ public void testNotStale() throws Exception {
ensureGreen();
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get();
IndexMetadata target = clusterStateResponse.getState().getMetadata().index("test");
internalCluster().restartNode(replica, new InternalTestCluster.RestartCallback() {
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/repositories/IndexSnapshotsServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/repositories/IndexSnapshotsServiceIT.java
index 6c7bcd17af1f0..f9dc42cb7abe8 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/repositories/IndexSnapshotsServiceIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/repositories/IndexSnapshotsServiceIT.java
@@ -137,7 +137,7 @@ public void testGetShardSnapshotReturnsTheLatestSuccessfulSnapshot() throws Exce
final SnapshotInfo snapshotInfo = createSnapshot(repoName, Strings.format("snap-%03d", i), snapshotIndices);
if (snapshotInfo.indices().contains(indexName)) {
lastSnapshot = snapshotInfo;
- ClusterStateResponse clusterStateResponse = admin().cluster().prepareState().get();
+ ClusterStateResponse clusterStateResponse = admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get();
IndexMetadata indexMetadata = clusterStateResponse.getState().metadata().index(indexName);
expectedIndexMetadataId = IndexMetaDataGenerations.buildUniqueIdentifier(indexMetadata);
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryCleanupIT.java b/server/src/internalClusterTest/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryCleanupIT.java
index 3eb05aa36b1b5..b8ada92c9033b 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryCleanupIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryCleanupIT.java
@@ -66,7 +66,10 @@ public void testRepeatCleanupsDontRemove() throws Exception {
);
logger.info("--> ensure cleanup is still in progress");
- final RepositoryCleanupInProgress cleanup = clusterAdmin().prepareState().get().getState().custom(RepositoryCleanupInProgress.TYPE);
+ final RepositoryCleanupInProgress cleanup = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .custom(RepositoryCleanupInProgress.TYPE);
assertTrue(cleanup.hasCleanupInProgress());
logger.info("--> unblocking master node");
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/ComponentTemplatesFileSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/ComponentTemplatesFileSettingsIT.java
index 4ce92610eff17..82b6ba15930b2 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/ComponentTemplatesFileSettingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/ComponentTemplatesFileSettingsIT.java
@@ -357,7 +357,10 @@ public class ComponentTemplatesFileSettingsIT extends ESIntegTestCase {
}""";
private void assertMasterNode(Client client, String node) throws ExecutionException, InterruptedException {
- assertThat(client.admin().cluster().prepareState().execute().get().getState().nodes().getMasterNode().getName(), equalTo(node));
+ assertThat(
+ client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).execute().get().getState().nodes().getMasterNode().getName(),
+ equalTo(node)
+ );
}
private void writeJSONFile(String node, String json) throws Exception {
@@ -403,7 +406,7 @@ private void assertClusterStateSaveOK(CountDownLatch savedClusterState, AtomicLo
assertTrue(awaitSuccessful);
final ClusterStateResponse clusterStateResponse = clusterAdmin().state(
- new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get())
+ new ClusterStateRequest(TEST_REQUEST_TIMEOUT).waitForMetadataVersion(metadataVersion.get())
).actionGet();
Map allTemplates = clusterStateResponse.getState().metadata().templatesV2();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java
index 2fe808d813ccc..049a58b633556 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java
@@ -102,7 +102,10 @@ public class FileSettingsServiceIT extends ESIntegTestCase {
}""";
private void assertMasterNode(Client client, String node) {
- assertThat(client.admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(), equalTo(node));
+ assertThat(
+ client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState().nodes().getMasterNode().getName(),
+ equalTo(node)
+ );
}
public static void writeJSONFile(String node, String json, AtomicLong versionCounter, Logger logger) throws Exception {
@@ -169,7 +172,7 @@ private void assertClusterStateSaveOK(CountDownLatch savedClusterState, AtomicLo
assertTrue(savedClusterState.await(20, TimeUnit.SECONDS));
final ClusterStateResponse clusterStateResponse = clusterAdmin().state(
- new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get())
+ new ClusterStateRequest(TEST_REQUEST_TIMEOUT).waitForMetadataVersion(metadataVersion.get())
).actionGet();
assertThat(
@@ -177,7 +180,7 @@ private void assertClusterStateSaveOK(CountDownLatch savedClusterState, AtomicLo
equalTo(expectedBytesPerSec)
);
- ClusterUpdateSettingsRequest req = new ClusterUpdateSettingsRequest().persistentSettings(
+ ClusterUpdateSettingsRequest req = new ClusterUpdateSettingsRequest(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT).persistentSettings(
Settings.builder().put(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey(), "1234kb")
);
assertThat(
@@ -257,7 +260,7 @@ public void testReservedStatePersistsOnRestart() throws Exception {
logger.info("--> restart master");
internalCluster().restartNode(masterNode);
- final ClusterStateResponse clusterStateResponse = clusterAdmin().state(new ClusterStateRequest()).actionGet();
+ final ClusterStateResponse clusterStateResponse = clusterAdmin().state(new ClusterStateRequest(TEST_REQUEST_TIMEOUT)).actionGet();
assertThat(
clusterStateResponse.getState()
.metadata()
@@ -300,7 +303,7 @@ private void assertClusterStateNotSaved(CountDownLatch savedClusterState, Atomic
assertTrue(awaitSuccessful);
final ClusterStateResponse clusterStateResponse = clusterAdmin().state(
- new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get())
+ new ClusterStateRequest(TEST_REQUEST_TIMEOUT).waitForMetadataVersion(metadataVersion.get())
).actionGet();
assertThat(clusterStateResponse.getState().metadata().persistentSettings().get("search.allow_expensive_queries"), nullValue());
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/RepositoriesFileSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/RepositoriesFileSettingsIT.java
index 1ca2526b53dff..7cec6e895a52e 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/RepositoriesFileSettingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/RepositoriesFileSettingsIT.java
@@ -94,7 +94,10 @@ public class RepositoriesFileSettingsIT extends ESIntegTestCase {
}""";
private void assertMasterNode(Client client, String node) throws ExecutionException, InterruptedException {
- assertThat(client.admin().cluster().prepareState().execute().get().getState().nodes().getMasterNode().getName(), equalTo(node));
+ assertThat(
+ client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).execute().get().getState().nodes().getMasterNode().getName(),
+ equalTo(node)
+ );
}
private void writeJSONFile(String node, String json) throws Exception {
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/SnapshotsAndFileSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/SnapshotsAndFileSettingsIT.java
index 049260e14100f..087274a86221e 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/SnapshotsAndFileSettingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/SnapshotsAndFileSettingsIT.java
@@ -133,7 +133,7 @@ private ClusterStateResponse assertClusterStateSaveOK(CountDownLatch savedCluste
boolean awaitSuccessful = savedClusterState.await(20, TimeUnit.SECONDS);
assertTrue(awaitSuccessful);
- return clusterAdmin().state(new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get())).get();
+ return clusterAdmin().state(new ClusterStateRequest(TEST_REQUEST_TIMEOUT).waitForMetadataVersion(metadataVersion.get())).get();
}
public void testRestoreWithRemovedFileSettings() throws Exception {
@@ -180,14 +180,15 @@ public void testRestoreWithRemovedFileSettings() throws Exception {
ensureGreen();
- final ClusterStateResponse clusterStateResponse = clusterAdmin().state(new ClusterStateRequest().metadata(true)).actionGet();
+ final ClusterStateResponse clusterStateResponse = clusterAdmin().state(new ClusterStateRequest(TEST_REQUEST_TIMEOUT).metadata(true))
+ .actionGet();
// We expect no reserved metadata state for file based settings, the operator file was deleted.
assertNull(clusterStateResponse.getState().metadata().reservedStateMetadata().get(FileSettingsService.NAMESPACE));
final ClusterGetSettingsAction.Response getSettingsResponse = clusterAdmin().execute(
ClusterGetSettingsAction.INSTANCE,
- new ClusterGetSettingsAction.Request()
+ new ClusterGetSettingsAction.Request(TEST_REQUEST_TIMEOUT)
).actionGet();
assertThat(
@@ -305,14 +306,14 @@ public void testRestoreWithPersistedFileSettings() throws Exception {
logger.info("--> reserved state would be restored to non-zero version");
final ClusterStateResponse clusterStateResponse = clusterAdmin().state(
- new ClusterStateRequest().metadata(true).waitForMetadataVersion(removedReservedState.v2().get())
+ new ClusterStateRequest(TEST_REQUEST_TIMEOUT).metadata(true).waitForMetadataVersion(removedReservedState.v2().get())
).actionGet();
assertNotNull(clusterStateResponse.getState().metadata().reservedStateMetadata().get(FileSettingsService.NAMESPACE));
final ClusterGetSettingsAction.Response getSettingsResponse = clusterAdmin().execute(
ClusterGetSettingsAction.INSTANCE,
- new ClusterGetSettingsAction.Request()
+ new ClusterGetSettingsAction.Request(TEST_REQUEST_TIMEOUT)
).actionGet();
assertThat(
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java b/server/src/internalClusterTest/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java
index 502f02d9ce17f..2ab77444f86b9 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java
@@ -51,7 +51,12 @@ public void testRollingRestartOfTwoNodeCluster() throws Exception {
);
ensureGreen("test");
- final DiscoveryNodes discoveryNodes = clusterAdmin().prepareState().clear().setNodes(true).get().getState().nodes();
+ final DiscoveryNodes discoveryNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .clear()
+ .setNodes(true)
+ .get()
+ .getState()
+ .nodes();
final Map nodeIdsByName = Maps.newMapWithExpectedSize(discoveryNodes.getSize());
discoveryNodes.forEach(n -> nodeIdsByName.put(n.getName(), n.getId()));
@@ -98,7 +103,7 @@ public Settings onNodeStopped(String nodeName) throws IOException {
ClusterHealthResponse clusterHealthResponse = client(viaNode).admin()
.cluster()
- .prepareHealth()
+ .prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes(Integer.toString(1))
.setTimeout(TimeValue.timeValueSeconds(30L))
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/routing/AliasResolveRoutingIT.java b/server/src/internalClusterTest/java/org/elasticsearch/routing/AliasResolveRoutingIT.java
index 53001e30763a0..1e18f156f1fcf 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/routing/AliasResolveRoutingIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/routing/AliasResolveRoutingIT.java
@@ -51,7 +51,7 @@ public void testSearchClosedWildcardIndex() throws ExecutionException, Interrupt
public void testResolveIndexRouting() {
createIndex("test1");
createIndex("test2");
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
indicesAdmin().prepareAliases()
.addAliasAction(AliasActions.add().index("test1").alias("alias"))
@@ -93,7 +93,7 @@ public void testResolveSearchRouting() {
createIndex("test1");
createIndex("test2");
createIndex("test3");
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
indicesAdmin().prepareAliases()
.addAliasAction(AliasActions.add().index("test1").alias("alias"))
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/routing/PartitionedRoutingIT.java b/server/src/internalClusterTest/java/org/elasticsearch/routing/PartitionedRoutingIT.java
index e25da54d7b214..20c197bf73893 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/routing/PartitionedRoutingIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/routing/PartitionedRoutingIT.java
@@ -93,8 +93,13 @@ public void testShrinking() throws Exception {
Settings.builder()
.put(
"index.routing.allocation.require._name",
- clusterAdmin().prepareState().get().getState().nodes().getDataNodes().values().toArray(DiscoveryNode[]::new)[0]
- .getName()
+ clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .nodes()
+ .getDataNodes()
+ .values()
+ .toArray(DiscoveryNode[]::new)[0].getName()
)
.put("index.blocks.write", true),
index
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/routing/SimpleRoutingIT.java b/server/src/internalClusterTest/java/org/elasticsearch/routing/SimpleRoutingIT.java
index f59ec4d42089e..2eb37291d41cf 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/routing/SimpleRoutingIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/routing/SimpleRoutingIT.java
@@ -49,7 +49,7 @@ protected int minimumNumberOfShards() {
}
public String findNonMatchingRoutingValue(String index, String id) {
- ClusterState state = clusterAdmin().prepareState().all().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).all().get().getState();
IndexMetadata metadata = state.metadata().index(index);
IndexMetadata withoutRoutingRequired = IndexMetadata.builder(metadata).putMapping("{}").build();
IndexRouting indexRouting = IndexRouting.fromIndexMetadata(withoutRoutingRequired);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/SearchServiceCleanupOnLostMasterIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/SearchServiceCleanupOnLostMasterIT.java
index 5625299890b7e..b71dd4a39b198 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/SearchServiceCleanupOnLostMasterIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/SearchServiceCleanupOnLostMasterIT.java
@@ -56,7 +56,7 @@ public void testDroppedOutNode() throws Exception {
assertBusy(() -> {
final ClusterHealthStatus indexHealthStatus = client(master).admin()
.cluster()
- .health(new ClusterHealthRequest("test"))
+ .health(new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, "test"))
.actionGet()
.getStatus();
assertThat(indexHealthStatus, Matchers.is(ClusterHealthStatus.RED));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java
index 0ed83f73e418d..17b976bdd3748 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java
@@ -223,7 +223,7 @@ public void testSimpleWithCustomKeys() throws Exception {
}
public void testUnmapped() throws Exception {
- clusterAdmin().prepareHealth("idx_unmapped").setWaitForYellowStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "idx_unmapped").setWaitForYellowStatus().get();
assertNoFailuresAndResponse(
prepareSearch("idx_unmapped").addAggregation(
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java
index 6a60969e632ee..0c39859856d56 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java
@@ -761,7 +761,7 @@ public void testUnmapped() throws Exception {
}
public void testPartiallyUnmapped() throws Exception {
- clusterAdmin().prepareHealth("idx_unmapped").setWaitForYellowStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "idx_unmapped").setWaitForYellowStatus().get();
assertNoFailuresAndResponse(
prepareSearch("idx", "idx_unmapped").addAggregation(
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchRedStateIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchRedStateIndexIT.java
index 1525496176418..9e2139f832f15 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchRedStateIndexIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchRedStateIndexIT.java
@@ -99,7 +99,9 @@ private void setClusterDefaultAllowPartialResults(boolean allowPartialResults) {
Settings persistentSettings = Settings.builder().put(key, allowPartialResults).build();
- ClusterUpdateSettingsResponse response1 = clusterAdmin().prepareUpdateSettings().setPersistentSettings(persistentSettings).get();
+ ClusterUpdateSettingsResponse response1 = clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(persistentSettings)
+ .get();
assertAcked(response1);
assertEquals(response1.getPersistentSettings().getAsBoolean(key, null), allowPartialResults);
@@ -115,10 +117,10 @@ private void buildRedIndex(int numShards) throws Exception {
internalCluster().stopRandomDataNode();
- clusterAdmin().prepareHealth().setWaitForStatus(ClusterHealthStatus.RED).get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForStatus(ClusterHealthStatus.RED).get();
assertBusy(() -> {
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
List unassigneds = RoutingNodesHelper.shardsWithState(state.getRoutingNodes(), ShardRoutingState.UNASSIGNED);
assertThat(unassigneds.size(), greaterThan(0));
});
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java
index 68d00321848eb..df6994c57f425 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java
@@ -61,7 +61,7 @@ private void searchWhileCreatingIndex(boolean createIndex, int numberOfReplicas)
logger.info("using preference {}", preference);
// we want to make sure that while recovery happens, and a replica gets recovered, its properly refreshed
- ClusterHealthStatus status = clusterAdmin().prepareHealth("test").get().getStatus();
+ ClusterHealthStatus status = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test").get().getStatus();
while (status != ClusterHealthStatus.GREEN) {
// first, verify that search normal search works
assertHitCount(prepareSearch("test").setQuery(QueryBuilders.termQuery("field", "test")), 1);
@@ -97,7 +97,7 @@ private void searchWhileCreatingIndex(boolean createIndex, int numberOfReplicas)
assertHitCount(searchResponse, 1);
}
);
- status = clusterAdmin().prepareHealth("test").get().getStatus();
+ status = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test").get().getStatus();
internalCluster().ensureAtLeastNumDataNodes(numberOfReplicas + 1);
}
cluster().wipeIndices("test");
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java
index 657158327bf01..a9b0f75fe45ba 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java
@@ -125,7 +125,7 @@ public void run() {
threads[j].join();
}
// this might time out on some machines if they are really busy and you hit lots of throttling
- ClusterHealthResponse resp = clusterAdmin().prepareHealth()
+ ClusterHealthResponse resp = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForYellowStatus()
.setWaitForNoRelocatingShards(true)
.setWaitForEvents(Priority.LANGUID)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWithRandomIOExceptionsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWithRandomIOExceptionsIT.java
index 096f533a072b9..3fe93f8d91be3 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWithRandomIOExceptionsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWithRandomIOExceptionsIT.java
@@ -102,7 +102,7 @@ public void testRandomDirectoryIOExceptions() throws IOException, InterruptedExc
ClusterHealthResponse clusterHealthResponse = clusterAdmin()
// it's OK to timeout here
.health(
- new ClusterHealthRequest(new String[] {}).waitForYellowStatus()
+ new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, new String[] {}).waitForYellowStatus()
.masterNodeTimeout(TimeValue.timeValueSeconds(5))
.timeout(TimeValue.timeValueSeconds(5))
)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java
index 303030a523662..951ea29a09e8e 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java
@@ -74,13 +74,13 @@ public void testFailedSearchWithWrongQuery() throws Exception {
allowNodes("test", 2);
assertThat(
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes(">=2").get().isTimedOut(),
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForNodes(">=2").get().isTimedOut(),
equalTo(false)
);
logger.info("Running Cluster Health");
ClusterHealthResponse clusterHealth = clusterAdmin().health(
- new ClusterHealthRequest("test").waitForYellowStatus()
+ new ClusterHealthRequest(TEST_REQUEST_TIMEOUT, "test").waitForYellowStatus()
.waitForNoRelocatingShards(true)
.waitForEvents(Priority.LANGUID)
.waitForActiveShards(test.totalNumShards)
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CCSUsageTelemetryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CCSUsageTelemetryIT.java
index 8b7f69df9fcc3..23146d1907250 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CCSUsageTelemetryIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CCSUsageTelemetryIT.java
@@ -670,7 +670,7 @@ private Map setupClusters() {
assertFalse(
client(clusterAlias).admin()
.cluster()
- .prepareHealth(remoteIndex)
+ .prepareHealth(TEST_REQUEST_TIMEOUT, remoteIndex)
.setWaitForYellowStatus()
.setTimeout(TimeValue.timeValueSeconds(10))
.get()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CrossClusterIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CrossClusterIT.java
index e96689ce2846d..9cc359f40d327 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CrossClusterIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CrossClusterIT.java
@@ -224,7 +224,7 @@ public void testCancel() throws Exception {
assertFalse(
client("cluster_a").admin()
.cluster()
- .prepareHealth("prod")
+ .prepareHealth(TEST_REQUEST_TIMEOUT, "prod")
.setWaitForYellowStatus()
.setTimeout(TimeValue.timeValueSeconds(10))
.get()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CrossClusterSearchIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CrossClusterSearchIT.java
index 89bc0e83351ad..e772f94e868ae 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CrossClusterSearchIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CrossClusterSearchIT.java
@@ -701,7 +701,7 @@ private Map setupTwoClusters() {
assertFalse(
client(REMOTE_CLUSTER).admin()
.cluster()
- .prepareHealth(remoteIndex)
+ .prepareHealth(TEST_REQUEST_TIMEOUT, remoteIndex)
.setWaitForYellowStatus()
.setTimeout(TimeValue.timeValueSeconds(10))
.get()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CrossClusterSearchLeakIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CrossClusterSearchLeakIT.java
index a9ae215c1ab79..5c26899f2e3f0 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CrossClusterSearchLeakIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CrossClusterSearchLeakIT.java
@@ -110,7 +110,7 @@ public void testSearch() throws Exception {
assertFalse(
client("cluster_a").admin()
.cluster()
- .prepareHealth("prod")
+ .prepareHealth(TEST_REQUEST_TIMEOUT, "prod")
.setWaitForYellowStatus()
.setTimeout(TimeValue.timeValueSeconds(10))
.get()
@@ -169,7 +169,11 @@ protected void configureRemoteCluster(String clusterAlias, Collection se
settings.put("cluster.remote." + clusterAlias + ".mode", "proxy");
settings.put("cluster.remote." + clusterAlias + ".proxy_address", seedAddress);
- client().admin().cluster().prepareUpdateSettings().setPersistentSettings(settings).get();
+ client().admin()
+ .cluster()
+ .prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(settings)
+ .get();
}
}
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java
index d42a84677a8f7..d58e777b093ae 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java
@@ -65,7 +65,7 @@ public void testPlugin() throws Exception {
.endObject()
)
.get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().get();
client().index(
new IndexRequest("test").id("1")
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/MinimalCompoundRetrieverIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/MinimalCompoundRetrieverIT.java
index 8c65d28711c1b..32dc34045cc8b 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/MinimalCompoundRetrieverIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/MinimalCompoundRetrieverIT.java
@@ -106,7 +106,7 @@ private Map setupTwoClusters() {
assertFalse(
client(REMOTE_CLUSTER).admin()
.cluster()
- .prepareHealth(remoteIndex)
+ .prepareHealth(TEST_REQUEST_TIMEOUT, remoteIndex)
.setWaitForYellowStatus()
.setTimeout(TimeValue.timeValueSeconds(10))
.get()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/RetrieverRewriteIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/RetrieverRewriteIT.java
index e618a1b75cc4d..e6ecd9f1e3779 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/RetrieverRewriteIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/RetrieverRewriteIT.java
@@ -115,7 +115,7 @@ public void testRewriteCompoundRetrieverShouldThrowForPartialResults() throws Ex
throw new IllegalStateException("node did not stop");
}
assertBusy(() -> {
- ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(testIndex)
+ ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, testIndex)
.setWaitForStatus(ClusterHealthStatus.RED) // we are now known red because the primary shard is missing
.setWaitForEvents(Priority.LANGUID) // ensures that the update has occurred
.execute()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchPreferenceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchPreferenceIT.java
index 433f004acdd77..17a0d6441ca47 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchPreferenceIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchPreferenceIT.java
@@ -59,7 +59,7 @@ public void testStopOneNodePreferenceWithRedState() throws IOException {
}
refresh();
internalCluster().stopRandomDataNode();
- clusterAdmin().prepareHealth().setWaitForStatus(ClusterHealthStatus.RED).get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForStatus(ClusterHealthStatus.RED).get();
String[] preferences = new String[] {
"_local",
"_prefer_nodes:somenode",
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchReplicaSelectionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchReplicaSelectionIT.java
index 816fe48e5d97f..439534c3e1743 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchReplicaSelectionIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchReplicaSelectionIT.java
@@ -68,7 +68,7 @@ public void testNodeSelection() {
client.prepareSearch().setQuery(matchAllQuery()).get().decRef();
}
- ClusterStateResponse clusterStateResponse = client.admin().cluster().prepareState().get();
+ ClusterStateResponse clusterStateResponse = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get();
Map coordinatingNodes = clusterStateResponse.getState().nodes().getCoordinatingOnlyNodes();
assertEquals(1, coordinatingNodes.size());
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/scroll/SearchScrollIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/scroll/SearchScrollIT.java
index 03c217266d527..24a3d3ac422f3 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/scroll/SearchScrollIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/scroll/SearchScrollIT.java
@@ -70,9 +70,9 @@ public void cleanup() throws Exception {
public void testSimpleScrollQueryThenFetch() throws Exception {
indicesAdmin().prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", 3)).get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
for (int i = 0; i < 100; i++) {
prepareIndex("test").setId(Integer.toString(i)).setSource(jsonBuilder().startObject().field("field", i).endObject()).get();
@@ -119,9 +119,9 @@ public void testSimpleScrollQueryThenFetch() throws Exception {
public void testSimpleScrollQueryThenFetchSmallSizeUnevenDistribution() throws Exception {
indicesAdmin().prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", 3)).get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
for (int i = 0; i < 100; i++) {
String routing = "0";
@@ -189,7 +189,7 @@ public void testSimpleScrollQueryThenFetchSmallSizeUnevenDistribution() throws E
public void testScrollAndUpdateIndex() throws Exception {
indicesAdmin().prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", 5)).get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
for (int i = 0; i < 500; i++) {
prepareIndex("test").setId(Integer.toString(i))
@@ -241,9 +241,9 @@ public void testScrollAndUpdateIndex() throws Exception {
public void testSimpleScrollQueryThenFetch_clearScrollIds() throws Exception {
indicesAdmin().prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", 3)).get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
for (int i = 0; i < 100; i++) {
prepareIndex("test").setId(Integer.toString(i)).setSource(jsonBuilder().startObject().field("field", i).endObject()).get();
@@ -360,9 +360,9 @@ public void testClearIllegalScrollId() throws Exception {
public void testSimpleScrollQueryThenFetchClearAllScrollIds() throws Exception {
indicesAdmin().prepareCreate("test").setSettings(Settings.builder().put("index.number_of_shards", 3)).get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
- clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().get();
for (int i = 0; i < 100; i++) {
prepareIndex("test").setId(Integer.toString(i)).setSource(jsonBuilder().startObject().field("field", i).endObject()).get();
@@ -553,7 +553,7 @@ public void testCloseAndReopenOrDeleteWithActiveScroll() {
public void testScrollInvalidDefaultKeepAlive() throws IOException {
IllegalArgumentException exc = expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings()
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().put("search.max_keep_alive", "1m").put("search.default_keep_alive", "2m"))
);
assertThat(exc.getMessage(), containsString("was (2m > 1m)"));
@@ -564,7 +564,8 @@ public void testScrollInvalidDefaultKeepAlive() throws IOException {
exc = expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings().setPersistentSettings(Settings.builder().put("search.default_keep_alive", "3m"))
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(Settings.builder().put("search.default_keep_alive", "3m"))
);
assertThat(exc.getMessage(), containsString("was (3m > 2m)"));
@@ -572,7 +573,8 @@ public void testScrollInvalidDefaultKeepAlive() throws IOException {
exc = expectThrows(
IllegalArgumentException.class,
- clusterAdmin().prepareUpdateSettings().setPersistentSettings(Settings.builder().put("search.max_keep_alive", "30s"))
+ clusterAdmin().prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
+ .setPersistentSettings(Settings.builder().put("search.max_keep_alive", "30s"))
);
assertThat(exc.getMessage(), containsString("was (1m > 30s)"));
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/stats/SearchStatsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/stats/SearchStatsIT.java
index 23384d1b199f9..e5ca2c6968bb9 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/search/stats/SearchStatsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/search/stats/SearchStatsIT.java
@@ -156,7 +156,7 @@ public void testSimpleStats() throws Exception {
}
private Set nodeIdsWithIndex(String... indices) {
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
GroupShardsIterator allAssignedShardsGrouped = state.routingTable().allAssignedShardsGrouped(indices, true);
Set nodes = new HashSet<>();
for (ShardIterator shardIterator : allAssignedShardsGrouped) {
@@ -239,7 +239,7 @@ public void testOpenContexts() {
}
protected int numAssignedShards(String... indices) {
- ClusterState state = clusterAdmin().prepareState().get().getState();
+ ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
GroupShardsIterator> allAssignedShardsGrouped = state.routingTable().allAssignedShardsGrouped(indices, true);
return allAssignedShardsGrouped.size();
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java
index f61cce863ce59..5bdf156e39999 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java
@@ -971,7 +971,7 @@ public void testQueuedSnapshotsWaitingForShardReady() throws Exception {
logger.info("--> wait for relocations to start");
assertBusy(
- () -> assertThat(clusterAdmin().prepareHealth(testIndex).get().getRelocatingShards(), greaterThan(0)),
+ () -> assertThat(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, testIndex).get().getRelocatingShards(), greaterThan(0)),
1L,
TimeUnit.MINUTES
);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/CustomMetadataContextIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/CustomMetadataContextIT.java
index 041d722591391..08f9d74ab477e 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/CustomMetadataContextIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/CustomMetadataContextIT.java
@@ -106,7 +106,7 @@ public void testShouldRestoreOnlySnapshotMetadata() throws Exception {
.setWaitForCompletion(true)
.get();
- var metadata = clusterAdmin().prepareState().get().getState().getMetadata();
+ var metadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getMetadata();
logger.info("check that custom persistent metadata [{}] is correctly restored", metadata);
if (isSnapshotMetadataSet) {
assertThat(metadata.custom(SnapshotMetadata.TYPE).getData(), equalTo("before_snapshot_s"));
@@ -127,7 +127,7 @@ public void testShouldKeepGatewayMetadataAfterRestart() throws Exception {
internalCluster().fullRestart();
ensureYellow();
- var metadata = clusterAdmin().prepareState().get().getState().getMetadata();
+ var metadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getMetadata();
logger.info("check that gateway custom metadata [{}] survived full cluster restart", metadata);
assertThat(metadata.custom(GatewayMetadata.TYPE).getData(), equalTo("before_restart_s_gw"));
assertThat(metadata.custom(ApiMetadata.TYPE), nullValue());
@@ -140,7 +140,7 @@ public void testShouldExposeApiMetadata() throws Exception {
metadataBuilder.putCustom(NonApiMetadata.TYPE, new NonApiMetadata("before_restart_ns"));
}));
- var metadata = clusterAdmin().prepareState().get().getState().getMetadata();
+ var metadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState().getMetadata();
logger.info("check that api custom metadata [{}] is visible via api", metadata);
assertThat(metadata.custom(ApiMetadata.TYPE).getData(), equalTo("before_restart_s_gw"));
assertThat(metadata.custom(NonApiMetadata.TYPE), nullValue());
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
index 19f051404bce0..3788f2dd2cb61 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java
@@ -245,7 +245,7 @@ public void testRestoreIndexWithMissingShards() throws Exception {
logger.info("--> shutdown one of the nodes");
internalCluster().stopRandomDataNode();
assertThat(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueMinutes(1))
.setWaitForNodes("<2")
@@ -432,7 +432,7 @@ public boolean clearData(String nodeName) {
});
assertThat(
- clusterAdmin().prepareHealth()
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT)
.setWaitForEvents(Priority.LANGUID)
.setTimeout(TimeValue.timeValueMinutes(1))
.setWaitForNodes("2")
@@ -666,7 +666,7 @@ public void testRestoreShrinkIndex() throws Exception {
assertAcked(indicesAdmin().prepareDelete(sourceIdx).get());
assertAcked(indicesAdmin().prepareDelete(shrunkIdx).get());
internalCluster().stopRandomDataNode();
- clusterAdmin().prepareHealth().setTimeout(TimeValue.timeValueSeconds(30)).setWaitForNodes("1");
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setTimeout(TimeValue.timeValueSeconds(30)).setWaitForNodes("1");
logger.info("--> start a new data node");
final Settings dataSettings = Settings.builder()
@@ -674,7 +674,7 @@ public void testRestoreShrinkIndex() throws Exception {
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) // to get a new node id
.build();
internalCluster().startDataOnlyNode(dataSettings);
- clusterAdmin().prepareHealth().setTimeout(TimeValue.timeValueSeconds(30)).setWaitForNodes("2");
+ clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setTimeout(TimeValue.timeValueSeconds(30)).setWaitForNodes("2");
logger.info("--> restore the shrunk index and ensure all shards are allocated");
RestoreSnapshotResponse restoreResponse = clusterAdmin().prepareRestoreSnapshot(TEST_REQUEST_TIMEOUT, repo, snapshot)
@@ -1127,7 +1127,7 @@ public void testSnapshotDeleteRelocatingPrimaryIndex() throws Exception {
logger.info("--> wait for relocations to start");
assertBusy(
- () -> assertThat(clusterAdmin().prepareHealth(indexName).get().getRelocatingShards(), greaterThan(0)),
+ () -> assertThat(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, indexName).get().getRelocatingShards(), greaterThan(0)),
1L,
TimeUnit.MINUTES
);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/MultiClusterRepoAccessIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/MultiClusterRepoAccessIT.java
index 0fd96b96c8756..2daa36ee00a01 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/MultiClusterRepoAccessIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/MultiClusterRepoAccessIT.java
@@ -142,7 +142,7 @@ public void testConcurrentDeleteFromOtherCluster() {
+ repoNameOnFirstCluster
+ "] concurrent modification of the index-N file, expected current generation [2] but it was not found in "
+ "the repository. The last cluster to write to this repository was ["
- + secondCluster.client().admin().cluster().prepareState().get().getState().metadata().clusterUUID()
+ + secondCluster.client().admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState().metadata().clusterUUID()
+ "] at generation [4]."
)
);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoriesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoriesIT.java
index d4c0a4c80a3b5..6870a1d6b2649 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoriesIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoriesIT.java
@@ -75,7 +75,12 @@ public void testRepositoryCreation() throws Exception {
assertThat(FileSystemUtils.files(location).length, equalTo(numberOfFiles));
logger.info("--> check that repository is really there");
- ClusterStateResponse clusterStateResponse = client.admin().cluster().prepareState().clear().setMetadata(true).get();
+ ClusterStateResponse clusterStateResponse = client.admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .clear()
+ .setMetadata(true)
+ .get();
Metadata metadata = clusterStateResponse.getState().getMetadata();
RepositoriesMetadata repositoriesMetadata = metadata.custom(RepositoriesMetadata.TYPE);
assertThat(repositoriesMetadata, notNullValue());
@@ -86,7 +91,7 @@ public void testRepositoryCreation() throws Exception {
createRepository("test-repo-2", "fs");
logger.info("--> check that both repositories are in cluster state");
- clusterStateResponse = client.admin().cluster().prepareState().clear().setMetadata(true).get();
+ clusterStateResponse = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).clear().setMetadata(true).get();
metadata = clusterStateResponse.getState().getMetadata();
repositoriesMetadata = metadata.custom(RepositoriesMetadata.TYPE);
assertThat(repositoriesMetadata, notNullValue());
@@ -117,7 +122,7 @@ public void testRepositoryCreation() throws Exception {
.isAcknowledged(),
equalTo(true)
);
- assertEquals(beforeStateUuid, client.admin().cluster().prepareState().clear().get().getState().stateUUID());
+ assertEquals(beforeStateUuid, client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).clear().get().getState().stateUUID());
logger.info("--> delete repository test-repo-1");
client.admin().cluster().prepareDeleteRepository(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT, "test-repo-1").get();
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RestoreSnapshotIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RestoreSnapshotIT.java
index 7626e59cd1b9d..725fcbc1a5849 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RestoreSnapshotIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RestoreSnapshotIT.java
@@ -224,7 +224,7 @@ public void testRestoreIncreasesPrimaryTerms() {
}
}
- final IndexMetadata indexMetadata = clusterAdmin().prepareState()
+ final IndexMetadata indexMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setIndices(indexName)
.setMetadata(true)
@@ -251,7 +251,7 @@ public void testRestoreIncreasesPrimaryTerms() {
assertThat(restoreSnapshotResponse.getRestoreInfo().successfulShards(), equalTo(numPrimaries));
assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(0));
- final IndexMetadata restoredIndexMetadata = clusterAdmin().prepareState()
+ final IndexMetadata restoredIndexMetadata = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
.clear()
.setIndices(indexName)
.setMetadata(true)
@@ -307,7 +307,13 @@ public void testRestoreWithDifferentMappingsAndSettings() throws Exception {
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
logger.info("--> assert that old mapping is restored");
- MappingMetadata mappings = clusterAdmin().prepareState().get().getState().getMetadata().getIndices().get("test-idx").mapping();
+ MappingMetadata mappings = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .get()
+ .getState()
+ .getMetadata()
+ .getIndices()
+ .get("test-idx")
+ .mapping();
assertThat(mappings.sourceAsMap().toString(), containsString("baz"));
assertThat(mappings.sourceAsMap().toString(), not(containsString("foo")));
@@ -818,7 +824,14 @@ public void testRecreateBlocksOnRestore() throws Exception {
.get();
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
- ClusterBlocks blocks = client.admin().cluster().prepareState().clear().setBlocks(true).get().getState().blocks();
+ ClusterBlocks blocks = client.admin()
+ .cluster()
+ .prepareState(TEST_REQUEST_TIMEOUT)
+ .clear()
+ .setBlocks(true)
+ .get()
+ .getState()
+ .blocks();
// compute current index settings (as we cannot query them if they contain SETTING_BLOCKS_METADATA)
Settings mergedSettings = Settings.builder().put(initialSettings).put(changedSettings).build();
logger.info("--> merged block settings {}", mergedSettings);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
index cd57401550f12..08daeaaec016b 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java
@@ -228,7 +228,7 @@ public void testBasicWorkFlow() throws Exception {
ensureGreen();
assertDocCount("test-idx-1", 100);
- ClusterState clusterState = clusterAdmin().prepareState().get().getState();
+ ClusterState clusterState = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(clusterState.getMetadata().hasIndex("test-idx-1"), equalTo(true));
assertThat(clusterState.getMetadata().hasIndex("test-idx-2"), equalTo(false));
@@ -511,7 +511,7 @@ public void testDataFileFailureDuringRestore() throws Exception {
// same node again during the same reroute operation. Then another reroute
// operation is scheduled, but the RestoreInProgressAllocationDecider will
// block the shard to be assigned again because it failed during restore.
- final ClusterStateResponse clusterStateResponse = client.admin().cluster().prepareState().get();
+ final ClusterStateResponse clusterStateResponse = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get();
assertEquals(1, clusterStateResponse.getState().getNodes().getDataNodes().size());
assertEquals(
restoreInfo.failedShards(),
@@ -663,7 +663,10 @@ private void unrestorableUseCase(
assertThat(restoreResponse.getRestoreInfo().totalShards(), equalTo(numShards.numPrimaries));
assertThat(restoreResponse.getRestoreInfo().successfulShards(), equalTo(0));
- ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().setCustoms(true).setRoutingTable(true).get();
+ ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .setCustoms(true)
+ .setRoutingTable(true)
+ .get();
// check that there is no restore in progress
RestoreInProgress restoreInProgress = clusterStateResponse.getState().custom(RestoreInProgress.TYPE);
@@ -867,7 +870,7 @@ public void testSnapshotClosedIndex() throws Exception {
ensureGreen();
logger.info("--> closing index test-idx-closed");
assertAcked(client.admin().indices().prepareClose("test-idx-closed"));
- ClusterStateResponse stateResponse = client.admin().cluster().prepareState().get();
+ ClusterStateResponse stateResponse = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get();
assertThat(stateResponse.getState().metadata().index("test-idx-closed").getState(), equalTo(IndexMetadata.State.CLOSE));
assertThat(stateResponse.getState().routingTable().index("test-idx-closed"), notNullValue());
@@ -1261,7 +1264,7 @@ public void testSnapshotRelocatingPrimary() throws Exception {
logger.info("--> wait for relocations to start");
assertBusy(
- () -> assertThat(clusterAdmin().prepareHealth("test-idx").get().getRelocatingShards(), greaterThan(0)),
+ () -> assertThat(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, "test-idx").get().getRelocatingShards(), greaterThan(0)),
1L,
TimeUnit.MINUTES
);
@@ -2185,7 +2188,7 @@ public void testHiddenIndicesIncludedInSnapshot() throws Exception {
equalTo(restoreSnapshotResponse.getRestoreInfo().totalShards())
);
assertThat(restoreSnapshotResponse.getRestoreInfo().indices(), containsInAnyOrder(normalIndex, hiddenIndex, dottedHiddenIndex));
- ClusterState clusterState = client.admin().cluster().prepareState().get().getState();
+ ClusterState clusterState = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(clusterState.getMetadata().hasIndex(normalIndex), equalTo(true));
assertThat(clusterState.getMetadata().hasIndex(hiddenIndex), equalTo(true));
assertThat(clusterState.getMetadata().hasIndex(dottedHiddenIndex), equalTo(true));
@@ -2205,7 +2208,7 @@ public void testHiddenIndicesIncludedInSnapshot() throws Exception {
equalTo(restoreSnapshotResponse.getRestoreInfo().totalShards())
);
assertThat(restoreSnapshotResponse.getRestoreInfo().indices(), containsInAnyOrder(normalIndex, hiddenIndex));
- ClusterState clusterState = client.admin().cluster().prepareState().get().getState();
+ ClusterState clusterState = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(clusterState.getMetadata().hasIndex(normalIndex), equalTo(true));
assertThat(clusterState.getMetadata().hasIndex(hiddenIndex), equalTo(true));
assertThat(clusterState.getMetadata().hasIndex(dottedHiddenIndex), equalTo(false));
@@ -2225,7 +2228,7 @@ public void testHiddenIndicesIncludedInSnapshot() throws Exception {
equalTo(restoreSnapshotResponse.getRestoreInfo().totalShards())
);
assertThat(restoreSnapshotResponse.getRestoreInfo().indices(), containsInAnyOrder(hiddenIndex));
- ClusterState clusterState = client.admin().cluster().prepareState().get().getState();
+ ClusterState clusterState = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(clusterState.getMetadata().hasIndex(normalIndex), equalTo(false));
assertThat(clusterState.getMetadata().hasIndex(hiddenIndex), equalTo(true));
assertThat(clusterState.getMetadata().hasIndex(dottedHiddenIndex), equalTo(false));
@@ -2245,7 +2248,7 @@ public void testHiddenIndicesIncludedInSnapshot() throws Exception {
equalTo(restoreSnapshotResponse.getRestoreInfo().totalShards())
);
assertThat(restoreSnapshotResponse.getRestoreInfo().indices(), containsInAnyOrder(dottedHiddenIndex));
- ClusterState clusterState = client.admin().cluster().prepareState().get().getState();
+ ClusterState clusterState = client.admin().cluster().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
assertThat(clusterState.getMetadata().hasIndex(normalIndex), equalTo(false));
assertThat(clusterState.getMetadata().hasIndex(hiddenIndex), equalTo(false));
assertThat(clusterState.getMetadata().hasIndex(dottedHiddenIndex), equalTo(true));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotBrokenSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotBrokenSettingsIT.java
index 6c91db0ad7228..92e0b437cbebb 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotBrokenSettingsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotBrokenSettingsIT.java
@@ -36,14 +36,14 @@ public void testExceptionWhenRestoringPersistentSettings() {
Client client = client();
Consumer setSettingValue = value -> client.admin()
.cluster()
- .prepareUpdateSettings()
+ .prepareUpdateSettings(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT)
.setPersistentSettings(Settings.builder().put(BrokenSettingPlugin.BROKEN_SETTING.getKey(), value))
.get();
Consumer assertSettingValue = value -> assertThat(
client.admin()
.cluster()
- .prepareState()
+ .prepareState(TEST_REQUEST_TIMEOUT)
.setRoutingTable(false)
.setNodes(false)
.get()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotShutdownIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotShutdownIT.java
index 2d1e16dc64273..3d16293c1462b 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotShutdownIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotShutdownIT.java
@@ -177,7 +177,12 @@ public void testRemoveNodeAndFailoverMasterDuringSnapshot() throws Exception {
SubscribableListener.newForked(
l -> client().execute(
TransportAddVotingConfigExclusionsAction.TYPE,
- new AddVotingConfigExclusionsRequest(Strings.EMPTY_ARRAY, new String[] { masterName }, TimeValue.timeValueSeconds(10)),
+ new AddVotingConfigExclusionsRequest(
+ TEST_REQUEST_TIMEOUT,
+ Strings.EMPTY_ARRAY,
+ new String[] { masterName },
+ TimeValue.timeValueSeconds(10)
+ ),
l
)
)
@@ -212,7 +217,7 @@ public void testRemoveNodeAndFailoverMasterDuringSnapshot() throws Exception {
// flush master queue to ensure the completion is applied everywhere
safeAwait(
SubscribableListener.newForked(
- l -> client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).execute(l)
+ l -> client().admin().cluster().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).execute(l)
)
);
@@ -230,7 +235,7 @@ public void testRemoveNodeAndFailoverMasterDuringSnapshot() throws Exception {
}
safeAwait(SubscribableListener.newForked(l -> {
- final var clearVotingConfigExclusionsRequest = new ClearVotingConfigExclusionsRequest();
+ final var clearVotingConfigExclusionsRequest = new ClearVotingConfigExclusionsRequest(TEST_REQUEST_TIMEOUT);
clearVotingConfigExclusionsRequest.setWaitForRemoval(false);
client().execute(TransportClearVotingConfigExclusionsAction.TYPE, clearVotingConfigExclusionsRequest, l);
}));
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStatusApisIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStatusApisIT.java
index fb282b4bf6a48..d4e27d5630c5b 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStatusApisIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStatusApisIT.java
@@ -738,7 +738,7 @@ public void testInfiniteTimeout() throws Exception {
try {
waitForBlockOnAnyDataNode("test-repo");
// Make sure that the create-snapshot task completes on master
- assertFalse(clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).get().isTimedOut());
+ assertFalse(clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setWaitForEvents(Priority.LANGUID).get().isTimedOut());
final List snapshotStatus = clusterAdmin().prepareSnapshotStatus(TEST_REQUEST_TIMEOUT, "test-repo")
.setMasterNodeTimeout(TimeValue.MINUS_ONE)
.get()
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStressTestsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStressTestsIT.java
index 9c9076dff00e2..e8d61e4677c98 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStressTestsIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStressTestsIT.java
@@ -89,7 +89,12 @@
public class SnapshotStressTestsIT extends AbstractSnapshotIntegTestCase {
public void testRandomActivities() throws InterruptedException {
- final DiscoveryNodes discoveryNodes = clusterAdmin().prepareState().clear().setNodes(true).get().getState().nodes();
+ final DiscoveryNodes discoveryNodes = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT)
+ .clear()
+ .setNodes(true)
+ .get()
+ .getState()
+ .nodes();
new TrackedCluster(internalCluster(), nodeNames(discoveryNodes.getMasterNodes()), nodeNames(discoveryNodes.getDataNodes())).run();
disableRepoConsistencyCheck("have not necessarily written to all repositories");
}
@@ -354,14 +359,20 @@ public void run() throws InterruptedException {
if (failedPermitAcquisitions.isEmpty() == false) {
logger.warn("--> failed to acquire all permits: {}", failedPermitAcquisitions);
- logger.info("--> current cluster state:\n{}", Strings.toString(clusterAdmin().prepareState().get().getState(), true, true));
+ logger.info(
+ "--> current cluster state:\n{}",
+ Strings.toString(clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState(), true, true)
+ );
fail("failed to acquire all permits: " + failedPermitAcquisitions);
}
logger.info("--> acquired all permits");
if (ThreadPool.terminate(threadPool, 30, TimeUnit.SECONDS) == false) {
logger.warn("--> threadpool termination timed out");
- logger.info("--> current cluster state:\n{}", Strings.toString(clusterAdmin().prepareState().get().getState(), true, true));
+ logger.info(
+ "--> current cluster state:\n{}",
+ Strings.toString(clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState(), true, true)
+ );
}
}
@@ -381,7 +392,7 @@ private void acquirePermitsAtEnd(
logger.warn("--> failed to acquire permit [{}]", label);
logger.info(
"--> current cluster state:\n{}",
- Strings.toString(clusterAdmin().prepareState().get().getState(), true, true)
+ Strings.toString(clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState(), true, true)
);
HotThreads.logLocalHotThreads(
logger,
@@ -1604,7 +1615,7 @@ Releasable tryAcquirePartialSnapshottingPermit() {
// Prepares a health request with twice the default (30s) timeout that waits for all cluster tasks to finish as well as all cluster
// nodes before returning
private static ClusterHealthRequestBuilder prepareClusterHealthRequest(String... targetIndexNames) {
- return clusterAdmin().prepareHealth(targetIndexNames)
+ return clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT, targetIndexNames)
.setTimeout(TimeValue.timeValueSeconds(60))
.setWaitForNodes(Integer.toString(internalCluster().getNodeNames().length))
.setWaitForEvents(Priority.LANGUID);
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemIndicesSnapshotIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemIndicesSnapshotIT.java
index 706ceaad7905c..32f76bdcc61e8 100644
--- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemIndicesSnapshotIT.java
+++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemIndicesSnapshotIT.java
@@ -704,7 +704,11 @@ public void testPartialSnapshotsOfSystemIndexRemovesFeatureState() throws Except
// Stop a random data node so we lose a shard from the partial index
internalCluster().stopRandomDataNode();
- assertBusy(() -> assertEquals(ClusterHealthStatus.RED, clusterAdmin().prepareHealth().get().getStatus()), 30, TimeUnit.SECONDS);
+ assertBusy(
+ () -> assertEquals(ClusterHealthStatus.RED, clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).get().getStatus()),
+ 30,
+ TimeUnit.SECONDS
+ );
// Get ready to block
blockMasterFromFinalizingSnapshotOnIndexFile(REPO_NAME);
diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java
index 82e4e4123e4fe..139ef58e4292e 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java
@@ -40,24 +40,28 @@ public class AddVotingConfigExclusionsRequest extends MasterNodeRequest {
- public Request() {
- super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT);
+ public Request(TimeValue masterNodeTimeout) {
+ super(masterNodeTimeout);
}
public Request(StreamInput in) throws IOException {
diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDeleteDesiredNodesAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDeleteDesiredNodesAction.java
index 11bdd41f458d3..f71def58820a0 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDeleteDesiredNodesAction.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportDeleteDesiredNodesAction.java
@@ -9,7 +9,6 @@
package org.elasticsearch.action.admin.cluster.desirednodes;
import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.support.ActionFilters;
@@ -27,6 +26,7 @@
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.util.concurrent.EsExecutors;
+import org.elasticsearch.core.TimeValue;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.injection.guice.Inject;
import org.elasticsearch.tasks.Task;
@@ -102,17 +102,12 @@ public ClusterState afterBatchExecution(ClusterState clusterState, boolean clust
}
public static class Request extends AcknowledgedRequest {
- public Request() {
- super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT, DEFAULT_ACK_TIMEOUT);
+ public Request(TimeValue masterNodeTimeout, TimeValue ackTimeout) {
+ super(masterNodeTimeout, ackTimeout);
}
public Request(StreamInput in) throws IOException {
super(in);
}
-
- @Override
- public ActionRequestValidationException validate() {
- return null;
- }
}
}
diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java
index 3d8cdb4b405f8..550db4892a673 100644
--- a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java
+++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java
@@ -16,6 +16,7 @@
import org.elasticsearch.cluster.metadata.DesiredNode;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
+import org.elasticsearch.core.TimeValue;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.xcontent.ConstructingObjectParser;
import org.elasticsearch.xcontent.ParseField;
@@ -47,8 +48,15 @@ public class UpdateDesiredNodesRequest extends AcknowledgedRequest DesiredNode.fromXContent(p), NODES_FIELD);
}
- public UpdateDesiredNodesRequest(String historyID, long version, List nodes, boolean dryRun) {
- super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT, DEFAULT_ACK_TIMEOUT);
+ public UpdateDesiredNodesRequest(
+ TimeValue masterNodeTimeout,
+ TimeValue ackTimeout,
+ String historyID,
+ long version,
+ List nodes,
+ boolean dryRun
+ ) {
+ super(masterNodeTimeout, ackTimeout);
assert historyID != null;
assert nodes != null;
this.historyID = historyID;
@@ -80,10 +88,16 @@ public void writeTo(StreamOutput out) throws IOException {
}
}
- public static UpdateDesiredNodesRequest fromXContent(String historyID, long version, boolean dryRun, XContentParser parser)
- throws IOException {
+ public static UpdateDesiredNodesRequest fromXContent(
+ TimeValue masterNodeTimeout,
+ TimeValue ackTimeout,
+ String historyID,
+ long version,
+ boolean dryRun,
+ XContentParser parser
+ ) throws IOException {
List