[TEST] Delete index in test to release file handles

This commit is contained in:
Simon Willnauer 2014-11-20 15:34:50 +01:00
parent 17110508ac
commit 26b4ebcd00
1 changed files with 13 additions and 9 deletions

View File

@ -85,10 +85,10 @@ public class FileBasedMappingsTests extends ElasticsearchTestCase {
.put("gateway.type", "none") .put("gateway.type", "none")
.build(); .build();
try (Node node = NodeBuilder.nodeBuilder().local(true).data(true).settings(settings).build()) { try (Node node = NodeBuilder.nodeBuilder().local(true).data(true).settings(settings).node()) {
node.start();
assertAcked(node.client().admin().indices().prepareCreate("index").addMapping("type", "h", "type=string").get()); assertAcked(node.client().admin().indices().prepareCreate("index").addMapping("type", "h", "type=string").get());
try {
final GetMappingsResponse response = node.client().admin().indices().prepareGetMappings("index").get(); final GetMappingsResponse response = node.client().admin().indices().prepareGetMappings("index").get();
assertTrue(response.mappings().toString(), response.mappings().containsKey("index")); assertTrue(response.mappings().toString(), response.mappings().containsKey("index"));
MappingMetaData mappings = response.mappings().get("index").get("type"); MappingMetaData mappings = response.mappings().get("index").get("type");
@ -96,6 +96,10 @@ public class FileBasedMappingsTests extends ElasticsearchTestCase {
Map<?, ?> properties = (Map<?, ?>) (mappings.getSourceAsMap().get("properties")); Map<?, ?> properties = (Map<?, ?>) (mappings.getSourceAsMap().get("properties"));
assertNotNull(properties); assertNotNull(properties);
assertEquals(ImmutableSet.of("f", "g", "h"), properties.keySet()); assertEquals(ImmutableSet.of("f", "g", "h"), properties.keySet());
} finally {
// remove the index...
assertAcked(node.client().admin().indices().prepareDelete("index"));
}
} }
} finally { } finally {
IOUtils.rm(configDir.toPath()); IOUtils.rm(configDir.toPath());