# Local (in memory during unit test) Node stays RED after .stop()/.start() call

**URL:** <https://discuss.elastic.co/t/local-in-memory-during-unit-test-node-stays-red-after-stop-start-call/14294>\
**Category:** Elasticsearch\
**Created:** [November 6, 2013, 11:46pm UTC](https://discuss.elastic.co/t/local-in-memory-during-unit-test-node-stays-red-after-stop-start-call/14294 "2013-11-06T23:46:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Conlin](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Mark\_Conlin](https://discuss.elastic.co/u/Mark_Conlin)\
**Post date:** [November 6, 2013, 11:46pm UTC](https://discuss.elastic.co/t/local-in-memory-during-unit-test-node-stays-red-after-stop-start-call/14294/1 "2013-11-06T23:46:48Z")

</div>

_Problem:_  
Using node.stop() and then node.start() cluster stays RED

_Longer Description:_  
I am attempting to write some unit tests for a plugin. One of the things I  
would like to test is the persistence of certain settings after node  
stop/start.  
I cant seem to get my node to leave the RED state once I call node.stop()  
and then node.start() on it. I have set the timeout to as long as 5  
minutes, no luck.

_Here is a test that shows this issue:_

public void testStopStartNode() throws Exception {  
Settings settings = ImmutableSettings.settingsBuilder().put("http.port",  
9211).put("node.http.enabled", true)  
.put("index.number\_of\_shards", 1).put("index.number\_of\_replicas", 0).put(  
"path.data", "target")  
.put("index.cache.field.type", "soft").build();

Node mynode = nodeBuilder().local(true).settings(settings).clusterName(  
"junit\_test\_cluster").node();  
mynode.start();

mynode.client().admin().cluster().prepareHealth().setWaitForGreenStatus().  
execute().actionGet();

mynode.stop();  
mynode.start();

System.out.println("Waiting for Yellow Status after node.stop()......");  
ClusterHealthResponse healthResponse = mynode.client().admin().cluster().  
prepareHealth().setWaitForYellowStatus().setTimeout(TimeValue.  
timeValueMinutes(2)).execute().actionGet();  
ClusterHealthStatus healthStatus = healthResponse.getStatus();

System.out.println("Done waiting : " + healthStatus.name());  
}

_Output of above test:_

INFO: [Needle] version[0.90.6], pid[20711],  
build[e2a24ef/2013-11-04T13:54:09Z]  
Nov 06, 2013 6:37:32 PM org.elasticsearch.node  
INFO: [Needle] initializing ...  
Nov 06, 2013 6:37:32 PM org.elasticsearch.plugins  
INFO: [Needle] loaded [query-cache], sites []  
Nov 06, 2013 6:37:32 PM org.elasticsearch.node  
INFO: [Needle] initialized  
Nov 06, 2013 6:37:32 PM org.elasticsearch.node  
INFO: [Needle] starting ...  
Nov 06, 2013 6:37:32 PM org.elasticsearch.transport  
INFO: [Needle] bound\_address {local[2]}, publish\_address {local[2]}  
Nov 06, 2013 6:37:32 PM org.elasticsearch.cluster.service  
INFO: [Needle] new\_master [Needle][2][local[2]]{http.enabled=true,  
local=true}, reason: local-disco-initial\_connect(master)  
Nov 06, 2013 6:37:32 PM org.elasticsearch.discovery  
INFO: [Needle] junit\_test\_cluster/2  
Nov 06, 2013 6:37:32 PM org.elasticsearch.gateway  
INFO: [Needle] recovered [0] indices into cluster\_state  
Nov 06, 2013 6:37:32 PM org.elasticsearch.http  
INFO: [Needle] bound\_address {inet[/0:0:0:0:0:0:0:0:9211]}, publish\_address  
{inet[/192.168.111.203:9211]}  
Nov 06, 2013 6:37:32 PM org.elasticsearch.node  
INFO: [Needle] started  
Nov 06, 2013 6:37:32 PM org.elasticsearch.node  
INFO: [Needle] stopping ...  
Nov 06, 2013 6:37:32 PM org.elasticsearch.node  
INFO: [Needle] stopped  
Nov 06, 2013 6:37:32 PM org.elasticsearch.node  
INFO: [Needle] starting ...  
Nov 06, 2013 6:37:32 PM org.elasticsearch.transport  
INFO: [Needle] bound\_address {local[3]}, publish\_address {local[3]}  
Nov 06, 2013 6:37:32 PM org.elasticsearch.cluster.service  
INFO: [Needle] new\_master [Needle][3][local[3]]{http.enabled=true,  
local=true}, reason: local-disco-initial\_connect(master)  
Nov 06, 2013 6:38:02 PM org.elasticsearch.discovery  
WARNING: [Needle] waited for 30s and no initial state was set by the  
discovery  
Nov 06, 2013 6:38:02 PM org.elasticsearch.discovery  
INFO: [Needle] junit\_test\_cluster/3  
Nov 06, 2013 6:38:02 PM org.elasticsearch.http  
INFO: [Needle] bound\_address {inet[/0:0:0:0:0:0:0:0:9211]}, publish\_address  
{inet[/192.168.111.203:9211]}  
Nov 06, 2013 6:38:02 PM org.elasticsearch.node  
INFO: [Needle] started  
_Waiting for Yellow Status after node.stop()......_  
_Done waiting : RED_

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [November 7, 2013, 8:16am UTC](https://discuss.elastic.co/t/local-in-memory-during-unit-test-node-stays-red-after-stop-start-call/14294/2 "2013-11-07T08:16:50Z")

</div>

I think after you stopped a node, not all resources were released like you  
wanted to.

Try closing the node instead of stopping.

Also, unless you set gateway.type to "none", ES tries to recover a node  
when starting, which is probably not intended in junit tests.

Jörg

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:08am UTC](https://discuss.elastic.co/t/local-in-memory-during-unit-test-node-stays-red-after-stop-start-call/14294/3 "2017-07-06T02:08:24Z")

</div>

Closed on July 6, 2017, 2:08am UTC


