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