My Unit Tests with Elastic Search 0.13 throw ClusterBlockException

I just tried upgrading my project to ElasticSearch 0.13 and the unit tests are throwing out:

org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [1/not recovered from gateway];

I read the thread from this form entitled "Search failures on server restarts" (which discusses ClusterBlockException) and tried the following advice from it without success:

client().admin().cluster().prepareHealth(INDEX_NAME).setWaitForYellowStatus().execute().actionGet();

In case it is useful info, this is how I start up the node and create the index in my test:

hostNode = NodeBuilder.nodeBuilder().loadConfigSettings(false).clusterName("test.cluster").local(true).settings(
ImmutableSettings.settingsBuilder()
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 1)
.put("gateway.type", "none")
.build()

    ).node().start();
    elasticSearchClient = hostNode.client();

    elasticSearchClient.admin().indices().create(Requests.createIndexRequest("index0")).actionGet();
    
    String json = (new FileUtil()).readTextFileFromClasspath("mail_mappings.json");
    elasticSearchClient.admin().indices().putMapping(Requests.putMappingRequest("index0").source(json)).actionGet();
    json = (new FileUtil()).readTextFileFromClasspath("attachment_mappings.json");
    elasticSearchClient.admin().indices().putMapping(Requests.putMappingRequest("index0").source(json)).actionGet();

At the end of each test, I do this:
elasticSearchClient.close();
hostNode.close();
(I tried taking this last part out, and it doesn't to help; I just get different a different error (IndexAlreadyExistsException) when the next tests run.)

Thanks in advance for any help you can afford.
-john

I should add: these tests were working fine with Elastic Search 0.12.1.

Seems I've found something that gets the job done. I took this part out of the end of the test class:

elasticSearchClient.close();
hostNode.close();

And then when I create the index at the beginning of the next test class, I wrap the index creation in a try/catch and ignore and keep going if I catch:
try {
elasticSearchClient.admin().indices().create(Requests.createIndexRequest("index0")).actionGet();
} catch (ElasticSearchException e) {
e.printStackTrace();
}

This way, my tests can be run in any order or one at a time, as they create the index but don't fail if another has already created it.

Anyway, seems to be working; let me know if this is a bad way of doing things, but it looks ok to me.

In case of none gateway, there shouldn't be the block created (for a very
short time) if it not being recovered from the gateway. You can try and
prepare a cluster health but wait for nodes and not on a specific index, it
should help.

On Tue, Nov 30, 2010 at 1:44 AM, John Chang jchangkihtest2@gmail.comwrote:

Seems I've found something that gets the job done. I took this part out of
the end of the test class:

   elasticSearchClient.close();
   hostNode.close();

And then when I create the index at the beginning of the next test class, I
wrap the index creation in a try/catch and ignore and keep going if I
catch:
try {

elasticSearchClient.admin().indices().create(Requests.createIndexRequest("index0")).actionGet();
} catch (ElasticSearchException e) {
e.printStackTrace();
}

This way, my tests can be run in any order or one at a time, as they create
the index but don't fail if another has already created it.

Anyway, seems to be working; let me know if this is a bad way of doing
things, but it looks ok to me.

View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/My-Unit-Tests-with-Elastic-Search-0-13-throw-ClusterBlockException-tp1989068p1989668.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.