Fix BlobStoreIncrementalityIT (#54055) (#54060)

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
This commit is contained in:
Armin Braun 2020-03-24 11:46:40 +01:00 committed by GitHub
parent d33d20bfdc
commit 4e462db2ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 10 deletions

View File

@ -21,7 +21,7 @@ package org.elasticsearch.snapshots;
import org.elasticsearch.action.DocWriteResponse;
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStats;
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse;
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus;
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
import org.elasticsearch.action.admin.indices.stats.IndexStats;
import org.elasticsearch.action.bulk.BulkItemResponse;
@ -46,7 +46,6 @@ import static org.hamcrest.Matchers.is;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
public class BlobStoreIncrementalityIT extends AbstractSnapshotIntegTestCase {
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/54034")
public void testIncrementalBehaviorOnPrimaryFailover() throws InterruptedException, ExecutionException, IOException {
internalCluster().startMasterOnlyNode();
final String primaryNode = internalCluster().startDataOnlyNode();
@ -174,10 +173,8 @@ public class BlobStoreIncrementalityIT extends AbstractSnapshotIntegTestCase {
client().admin().cluster().prepareCreateSnapshot(repo, snapshot2).setIndices(indexName).setWaitForCompletion(true).get();
logger.info("--> asserting that the two snapshots refer to different files in the repository");
final SnapshotsStatusResponse response =
client().admin().cluster().prepareSnapshotStatus(repo).setSnapshots(snapshot2).get();
final SnapshotStats secondSnapshotShardStatus =
response.getSnapshots().get(0).getIndices().get(indexName).getShards().get(0).getStats();
getStats(repo, snapshot2).getIndices().get(indexName).getShards().get(0).getStats();
assertThat(secondSnapshotShardStatus.getIncrementalFileCount(), greaterThan(0));
}
@ -191,19 +188,20 @@ public class BlobStoreIncrementalityIT extends AbstractSnapshotIntegTestCase {
private void assertTwoIdenticalShardSnapshots(String repo, String indexName, String snapshot1, String snapshot2) {
logger.info(
"--> asserting that snapshots [{}] and [{}] are referring to the same files in the repository", snapshot1, snapshot2);
final SnapshotsStatusResponse response =
client().admin().cluster().prepareSnapshotStatus(repo).setSnapshots(snapshot1, snapshot2).get();
final SnapshotStats firstSnapshotShardStatus =
response.getSnapshots().get(0).getIndices().get(indexName).getShards().get(0).getStats();
final SnapshotStats firstSnapshotShardStatus = getStats(repo, snapshot1).getIndices().get(indexName).getShards().get(0).getStats();
final int totalFilesInShard = firstSnapshotShardStatus.getTotalFileCount();
assertThat(totalFilesInShard, greaterThan(0));
assertThat(firstSnapshotShardStatus.getIncrementalFileCount(), is(totalFilesInShard));
final SnapshotStats secondSnapshotShardStatus =
response.getSnapshots().get(1).getIndices().get(indexName).getShards().get(0).getStats();
getStats(repo, snapshot2).getIndices().get(indexName).getShards().get(0).getStats();
assertThat(secondSnapshotShardStatus.getTotalFileCount(), is(totalFilesInShard));
assertThat(secondSnapshotShardStatus.getIncrementalFileCount(), is(0));
}
private SnapshotStatus getStats(String repository, String snapshot) {
return client().admin().cluster().prepareSnapshotStatus(repository).setSnapshots(snapshot).get().getSnapshots().get(0);
}
private void ensureRestoreSingleShardSuccessfully(String repo, String indexName, String snapshot, String indexSuffix) {
logger.info("--> restoring [{}]", snapshot);
final RestoreSnapshotResponse restoreSnapshotResponse = client().admin().cluster().prepareRestoreSnapshot(repo, snapshot)