Make Recovery API support `detailed` params (#29076)

Properly forwards the `detailed` parameter to show the recovery stats details.

Closes #28910
This commit is contained in:
Yu 2019-06-21 15:02:23 +08:00 committed by Yannick Welsch
parent 90e151edeb
commit c88f2f23a5
3 changed files with 27 additions and 2 deletions

View File

@ -249,7 +249,7 @@ Response:
}
--------------------------------------------------
// TESTRESPONSE[s/"source" : \{[^}]*\}/"source" : $body.$_path/]
// TESTRESPONSE[s/"details" : \[[^\]]*\]//]
// TESTRESPONSE[s/"details" : \[[^\]]*\]/"details" : $body.$_path/]
// TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
// TESTRESPONSE[s/: "[^"]*"/: $body.$_path/]
////

View File

@ -130,3 +130,28 @@
index: [v*]
- match: { $body: {} }
---
"Indices recovery test with detailed parameter":
- skip:
version: " - 7.2.99"
reason: bug with detailed parameter fixed in 7.3
- do:
indices.create:
index: test_3
body:
settings:
index:
number_of_replicas: 0
- do:
cluster.health:
wait_for_status: green
- do:
indices.recovery:
index: [test_3]
human: true
detailed: true
- match: { test_3.shards.0.index.files.details: [] }

View File

@ -929,7 +929,7 @@ public class RecoveryState implements ToXContentFragment, Streamable, Writeable
builder.field(Fields.REUSED, reusedFileCount());
builder.field(Fields.RECOVERED, recoveredFileCount());
builder.field(Fields.PERCENT, String.format(Locale.ROOT, "%1.1f%%", recoveredFilesPercent()));
if (params.paramAsBoolean("details", false)) {
if (params.paramAsBoolean("detailed", false)) {
builder.startArray(Fields.DETAILS);
for (File file : fileDetails.values()) {
file.toXContent(builder, params);