Skip to content

Commit ff067e1

Browse files
Fix BlobStoreIncrementalityIT (#54055)
The snapshot stats response list of snapshot statuses is not ordered according to the given list of snapshot names so randomly we could mix up snapshot1 and snapshot2 when asserting on the stats. Fixed by getting each snapshot's stats individually. Closes #54034
1 parent f4bdcd9 commit ff067e1

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

server/src/test/java/org/elasticsearch/snapshots/BlobStoreIncrementalityIT.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.elasticsearch.action.DocWriteResponse;
2222
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
2323
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStats;
24-
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse;
24+
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus;
2525
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
2626
import org.elasticsearch.action.admin.indices.stats.IndexStats;
2727
import org.elasticsearch.action.bulk.BulkItemResponse;
@@ -46,7 +46,6 @@
4646
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
4747
public class BlobStoreIncrementalityIT extends AbstractSnapshotIntegTestCase {
4848

49-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/54034")
5049
public void testIncrementalBehaviorOnPrimaryFailover() throws InterruptedException, ExecutionException, IOException {
5150
internalCluster().startMasterOnlyNode();
5251
final String primaryNode = internalCluster().startDataOnlyNode();
@@ -174,10 +173,8 @@ public void testForceMergeCausesFullSnapshot() throws Exception {
174173
client().admin().cluster().prepareCreateSnapshot(repo, snapshot2).setIndices(indexName).setWaitForCompletion(true).get();
175174

176175
logger.info("--> asserting that the two snapshots refer to different files in the repository");
177-
final SnapshotsStatusResponse response =
178-
client().admin().cluster().prepareSnapshotStatus(repo).setSnapshots(snapshot2).get();
179176
final SnapshotStats secondSnapshotShardStatus =
180-
response.getSnapshots().get(0).getIndices().get(indexName).getShards().get(0).getStats();
177+
getStats(repo, snapshot2).getIndices().get(indexName).getShards().get(0).getStats();
181178
assertThat(secondSnapshotShardStatus.getIncrementalFileCount(), greaterThan(0));
182179
}
183180

@@ -191,19 +188,20 @@ private void assertCountInIndexThenDelete(String index, long expectedCount) thro
191188
private void assertTwoIdenticalShardSnapshots(String repo, String indexName, String snapshot1, String snapshot2) {
192189
logger.info(
193190
"--> asserting that snapshots [{}] and [{}] are referring to the same files in the repository", snapshot1, snapshot2);
194-
final SnapshotsStatusResponse response =
195-
client().admin().cluster().prepareSnapshotStatus(repo).setSnapshots(snapshot1, snapshot2).get();
196-
final SnapshotStats firstSnapshotShardStatus =
197-
response.getSnapshots().get(0).getIndices().get(indexName).getShards().get(0).getStats();
191+
final SnapshotStats firstSnapshotShardStatus = getStats(repo, snapshot1).getIndices().get(indexName).getShards().get(0).getStats();
198192
final int totalFilesInShard = firstSnapshotShardStatus.getTotalFileCount();
199193
assertThat(totalFilesInShard, greaterThan(0));
200194
assertThat(firstSnapshotShardStatus.getIncrementalFileCount(), is(totalFilesInShard));
201195
final SnapshotStats secondSnapshotShardStatus =
202-
response.getSnapshots().get(1).getIndices().get(indexName).getShards().get(0).getStats();
196+
getStats(repo, snapshot2).getIndices().get(indexName).getShards().get(0).getStats();
203197
assertThat(secondSnapshotShardStatus.getTotalFileCount(), is(totalFilesInShard));
204198
assertThat(secondSnapshotShardStatus.getIncrementalFileCount(), is(0));
205199
}
206200

201+
private SnapshotStatus getStats(String repository, String snapshot) {
202+
return client().admin().cluster().prepareSnapshotStatus(repository).setSnapshots(snapshot).get().getSnapshots().get(0);
203+
}
204+
207205
private void ensureRestoreSingleShardSuccessfully(String repo, String indexName, String snapshot, String indexSuffix) {
208206
logger.info("--> restoring [{}]", snapshot);
209207
final RestoreSnapshotResponse restoreSnapshotResponse = client().admin().cluster().prepareRestoreSnapshot(repo, snapshot)

0 commit comments

Comments
 (0)