[TEST] Close the node env after test is done

This commit is contained in:
Simon Willnauer 2014-12-11 21:21:09 +01:00
parent 3877dc618d
commit dac520170f
1 changed files with 65 additions and 69 deletions

View File

@ -18,22 +18,15 @@
*/
package org.elasticsearch.gateway.local.state.shards;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.*;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ElasticsearchTestCase;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -41,7 +34,8 @@ import java.util.Map;
public class LocalGatewayShardStateTests extends ElasticsearchTestCase {
public void testWriteShardState() throws Exception {
LocalGatewayShardsState state = new LocalGatewayShardsState(ImmutableSettings.EMPTY, newNodeEnvironment(), null);
try (NodeEnvironment env = newNodeEnvironment()) {
LocalGatewayShardsState state = new LocalGatewayShardsState(ImmutableSettings.EMPTY, env, null);
ShardId id = new ShardId("foo", 1);
long version = between(1, Integer.MAX_VALUE / 2);
boolean primary = randomBoolean();
@ -60,11 +54,12 @@ public class LocalGatewayShardStateTests extends ElasticsearchTestCase {
shardStateInfo = state.loadShardInfo(id);
assertEquals(shardStateInfo, state3);
assertTrue(state.getCurrentState().isEmpty());
}
}
public void testPersistRoutingNode() throws Exception {
LocalGatewayShardsState state = new LocalGatewayShardsState(ImmutableSettings.EMPTY, newNodeEnvironment(), null);
try (NodeEnvironment env = newNodeEnvironment()) {
LocalGatewayShardsState state = new LocalGatewayShardsState(ImmutableSettings.EMPTY, env, null);
int numShards = between(0, 100);
List<MutableShardRouting> shards = new ArrayList<>();
List<MutableShardRouting> active = new ArrayList<>();
@ -123,3 +118,4 @@ public class LocalGatewayShardStateTests extends ElasticsearchTestCase {
}
}
}
}