|
5 | 5 | */
|
6 | 6 | package org.elasticsearch.xpack.ccr.action;
|
7 | 7 |
|
| 8 | +import org.elasticsearch.ElasticsearchException; |
| 9 | +import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest; |
| 10 | +import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; |
8 | 11 | import org.elasticsearch.action.admin.indices.stats.ShardStats;
|
9 | 12 | import org.elasticsearch.common.settings.Settings;
|
10 | 13 | import org.elasticsearch.common.xcontent.XContentType;
|
@@ -84,4 +87,33 @@ public void testGetOperationsBasedOnGlobalSequenceId() throws Exception {
|
84 | 87 | assertThat(operation.id(), equalTo("5"));
|
85 | 88 | }
|
86 | 89 |
|
| 90 | + public void testMissingOperations() { |
| 91 | + client().admin().indices().prepareCreate("index") |
| 92 | + .setSettings(Settings.builder() |
| 93 | + .put("index.soft_deletes.enabled", true) |
| 94 | + .put("index.soft_deletes.retention.operations", 0) |
| 95 | + .put("index.number_of_shards", 1) |
| 96 | + .put("index.number_of_replicas", 0)) |
| 97 | + .get(); |
| 98 | + |
| 99 | + for (int i = 0; i < 16; i++) { |
| 100 | + client().prepareIndex("index", "_doc", "1").setSource("{}", XContentType.JSON).get(); |
| 101 | + client().prepareDelete("index", "_doc", "1").get(); |
| 102 | + } |
| 103 | + client().admin().indices().refresh(new RefreshRequest("index")).actionGet(); |
| 104 | + ForceMergeRequest forceMergeRequest = new ForceMergeRequest("index"); |
| 105 | + forceMergeRequest.maxNumSegments(1); |
| 106 | + client().admin().indices().forceMerge(forceMergeRequest).actionGet(); |
| 107 | + |
| 108 | + ShardStats shardStats = client().admin().indices().prepareStats("index").get().getIndex("index").getShards()[0]; |
| 109 | + String historyUUID = shardStats.getCommitStats().getUserData().get(Engine.HISTORY_UUID_KEY); |
| 110 | + ShardChangesAction.Request request = new ShardChangesAction.Request(shardStats.getShardRouting().shardId(), historyUUID); |
| 111 | + request.setFromSeqNo(0L); |
| 112 | + request.setMaxOperationCount(1); |
| 113 | + |
| 114 | + Exception e = expectThrows(ElasticsearchException.class, () -> client().execute(ShardChangesAction.INSTANCE, request).actionGet()); |
| 115 | + assertThat(e.getMessage(), equalTo("Operations are no longer available for replicating. Maybe increase the retention setting " + |
| 116 | + "[index.soft_deletes.retention.operations]?")); |
| 117 | + } |
| 118 | + |
87 | 119 | }
|
0 commit comments