Test: testRelocationWithBusyClusterUpdateThread - use cluster state listener instead of assertBusy
This commit is contained in:
parent
1b7920f202
commit
45ecb49a09
|
@ -462,9 +462,6 @@ public class RelocationTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(response.isTimedOut(), is(false));
|
||||
|
||||
|
||||
ClusterService clusterService = internalCluster().getInstance(ClusterService.class, node1);
|
||||
|
||||
|
||||
client().admin().indices().prepareCreate(indexName)
|
||||
.setSettings(
|
||||
ImmutableSettings.builder()
|
||||
|
@ -486,8 +483,9 @@ public class RelocationTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
final CountDownLatch allReplicasAssigned = new CountDownLatch(1);
|
||||
final CountDownLatch releaseClusterState = new CountDownLatch(1);
|
||||
final CountDownLatch unassignedShardsAfterReplicasAssigned = new CountDownLatch(1);
|
||||
try {
|
||||
clusterService.addLast(new ClusterStateListener() {
|
||||
internalCluster().getInstance(ClusterService.class, node1).addLast(new ClusterStateListener() {
|
||||
@Override
|
||||
public void clusterChanged(ClusterChangedEvent event) {
|
||||
if (event.state().routingNodes().hasUnassignedShards() == false) {
|
||||
|
@ -501,6 +499,15 @@ public class RelocationTests extends ElasticsearchIntegrationTest {
|
|||
}
|
||||
});
|
||||
|
||||
internalCluster().getInstance(ClusterService.class, master).addLast(new ClusterStateListener() {
|
||||
@Override
|
||||
public void clusterChanged(ClusterChangedEvent event) {
|
||||
if (event.state().routingNodes().hasUnassigned() && allReplicasAssigned.getCount() == 0) {
|
||||
unassignedShardsAfterReplicasAssigned.countDown();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
logger.info("--> starting replica recovery");
|
||||
// we don't expect this to be acknowledge by node1 where we block the cluster state thread
|
||||
assertFalse(client().admin().indices().prepareUpdateSettings(indexName)
|
||||
|
@ -514,13 +521,7 @@ public class RelocationTests extends ElasticsearchIntegrationTest {
|
|||
logger.info("--> waiting for node1 to process replica existence");
|
||||
allReplicasAssigned.await();
|
||||
logger.info("--> waiting for recovery to fail");
|
||||
assertBusy(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ClusterHealthResponse response = client().admin().cluster().prepareHealth().get();
|
||||
assertThat(response.getUnassignedShards(), equalTo(1));
|
||||
}
|
||||
});
|
||||
unassignedShardsAfterReplicasAssigned.countDown();
|
||||
} finally {
|
||||
logger.info("--> releasing cluster state update thread");
|
||||
releaseClusterState.countDown();
|
||||
|
|
Loading…
Reference in New Issue