[TEST] snapshot test shoudl use assertBusy to provide more info when failing
This commit is contained in:
parent
8060cd0794
commit
d3e36d0940
|
@ -1861,7 +1861,7 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests {
|
||||||
ListenableActionFuture<CreateSnapshotResponse> snapshotFuture = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").execute();
|
ListenableActionFuture<CreateSnapshotResponse> snapshotFuture = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").execute();
|
||||||
|
|
||||||
// Await until shard updates are in pending state.
|
// Await until shard updates are in pending state.
|
||||||
assertTrue(waitForPendingTasks("update snapshot state", numberOfShards));
|
assertBusyPendingTasks("update snapshot state", numberOfShards);
|
||||||
snapshotListener.unblock();
|
snapshotListener.unblock();
|
||||||
|
|
||||||
// Check that the snapshot was successful
|
// Check that the snapshot was successful
|
||||||
|
@ -1890,7 +1890,7 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests {
|
||||||
ListenableActionFuture<RestoreSnapshotResponse> futureRestore = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute();
|
ListenableActionFuture<RestoreSnapshotResponse> futureRestore = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute();
|
||||||
|
|
||||||
// Await until shard updates are in pending state.
|
// Await until shard updates are in pending state.
|
||||||
assertTrue(waitForPendingTasks("update snapshot state", numberOfShards));
|
assertBusyPendingTasks("update snapshot state", numberOfShards);
|
||||||
restoreListener.unblock();
|
restoreListener.unblock();
|
||||||
|
|
||||||
RestoreSnapshotResponse restoreSnapshotResponse = futureRestore.actionGet();
|
RestoreSnapshotResponse restoreSnapshotResponse = futureRestore.actionGet();
|
||||||
|
@ -1906,10 +1906,10 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests {
|
||||||
assertEquals(1, restoreListener.count());
|
assertEquals(1, restoreListener.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean waitForPendingTasks(final String taskPrefix, final int expectedCount) throws InterruptedException {
|
private void assertBusyPendingTasks(final String taskPrefix, final int expectedCount) throws Exception {
|
||||||
return awaitBusy(new Predicate<Object>() {
|
assertBusy(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Object o) {
|
public void run() {
|
||||||
PendingClusterTasksResponse tasks = client().admin().cluster().preparePendingClusterTasks().get();
|
PendingClusterTasksResponse tasks = client().admin().cluster().preparePendingClusterTasks().get();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for(PendingClusterTask task : tasks) {
|
for(PendingClusterTask task : tasks) {
|
||||||
|
@ -1917,7 +1917,7 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return expectedCount == count;
|
assertThat(count, equalTo(expectedCount));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1931,21 +1931,13 @@ public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests {
|
||||||
public class BlockingClusterStateListener implements ClusterStateListener {
|
public class BlockingClusterStateListener implements ClusterStateListener {
|
||||||
|
|
||||||
private final Predicate<ClusterChangedEvent> blockOn;
|
private final Predicate<ClusterChangedEvent> blockOn;
|
||||||
|
|
||||||
private final Predicate<ClusterChangedEvent> countOn;
|
private final Predicate<ClusterChangedEvent> countOn;
|
||||||
|
|
||||||
private final ClusterService clusterService;
|
private final ClusterService clusterService;
|
||||||
|
|
||||||
private final CountDownLatch latch;
|
private final CountDownLatch latch;
|
||||||
|
|
||||||
private final Priority passThroughPriority;
|
private final Priority passThroughPriority;
|
||||||
|
|
||||||
private int count;
|
private int count;
|
||||||
|
|
||||||
private boolean timedOut;
|
private boolean timedOut;
|
||||||
|
|
||||||
private final TimeValue timeout;
|
private final TimeValue timeout;
|
||||||
|
|
||||||
private long stopWaitingAt = -1;
|
private long stopWaitingAt = -1;
|
||||||
|
|
||||||
public BlockingClusterStateListener(ClusterService clusterService, String blockOn, String countOn, Priority passThroughPriority) {
|
public BlockingClusterStateListener(ClusterService clusterService, String blockOn, String countOn, Priority passThroughPriority) {
|
||||||
|
|
Loading…
Reference in New Issue