Skip to content

Commit

Permalink
Recovery: Fix wrong reused file bytes in Recovery API reports
Browse files Browse the repository at this point in the history
Simple snapshot.restore test case that also exposes the bug mentioned in elastic#11876

Fix elastic#11876
Closes elastic#11965
  • Loading branch information
szroland authored and bleskes committed Jul 1, 2015
1 parent fd4764a commit e63e9fd
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
@@ -0,0 +1,57 @@
---
setup:

- do:
snapshot.create_repository:
repository: test_repo1
body:
type: fs
settings:
location: "test_repo1"

- do:
indices.create:
index: test_index
body:
settings:
number_of_shards: 1
number_of_replicas: 1

- do:
cluster.health:
wait_for_status: yellow

---
"Create a snapshot and then restore it":

- do:
snapshot.create:
repository: test_repo1
snapshot: test_snapshot
wait_for_completion: true

- match: { snapshot.snapshot: test_snapshot }
- match: { snapshot.state : SUCCESS }
- match: { snapshot.shards.successful: 1 }
- match: { snapshot.shards.failed : 0 }

- do:
indices.close:
index : test_index

- do:
snapshot.restore:
repository: test_repo1
snapshot: test_snapshot
wait_for_completion: true

- do:
indices.recovery:
index: test_index

- match: { test_index.shards.0.type: SNAPSHOT }
- match: { test_index.shards.0.stage: DONE }
- match: { test_index.shards.0.index.files.recovered: 1}
- gt: { test_index.shards.0.index.size.recovered_in_bytes: 0}
- match: { test_index.shards.0.index.files.reused: 0}
- match: { test_index.shards.0.index.size.reused_in_bytes: 0}
Expand Up @@ -1035,7 +1035,7 @@ public synchronized XContentBuilder toXContent(XContentBuilder builder, Params p
// stream size first, as it matters more and the files section can be long
builder.startObject(Fields.SIZE);
builder.byteSizeField(Fields.TOTAL_IN_BYTES, Fields.TOTAL, totalBytes());
builder.byteSizeField(Fields.REUSED_IN_BYTES, Fields.REUSED, totalBytes());
builder.byteSizeField(Fields.REUSED_IN_BYTES, Fields.REUSED, reusedBytes());
builder.byteSizeField(Fields.RECOVERED_IN_BYTES, Fields.RECOVERED, recoveredBytes());
builder.field(Fields.PERCENT, String.format(Locale.ROOT, "%1.1f%%", recoveredBytesPercent()));
builder.endObject();
Expand Down

0 comments on commit e63e9fd

Please sign in to comment.