我有一个大型 Groovy 应用程序,其中包含大量 JUnit 集成测试 (256),其中大部分使用“com.github.tlrx.elasticsearch-test”,版本:“1.2.1”在本地运行 elasticsearch。
在运行所有测试类的过程中,所有使用 elasticsearch 的测试开始抛出“ElasticsearchIllegalStateException”消息“无法获取节点锁定,以下位置是否可写?:[./target/elasticsearch-test/data/cluster-test-kiml42s-MacBook-Pro.local]'。
如果我单独运行这些类中的任何一个,它都可以正常工作。
这是我在所有@Befores 中运行的初始化代码:
esSetup = new EsSetup();
CreateIndex createIndex = createIndex(index)
for(int i = 0; i < types.size(); i++){
createIndex.withMapping(types[i], fromClassPath(mappings[i]))
}
esSetup.execute(deleteAll(), createIndex)
client = esSetup.client()
如果我的拆解代码在@Afters 中运行:
client.admin().indices().prepareDelete(index).get()
这个问题似乎没有发生在我们的构建服务器上,所以它只是烦人和不方便,不是一个严重的问题,但我们将不胜感激任何帮助。谢谢。
最佳答案
这个问题似乎是由于在 jUnit 运行所有测试时让测试节点处于事件状态引起的 - 最终它无法创建新节点。解决方案是在每次测试结束后使用 esSetup.terminate() 销毁节点。
这是一个正确使用它的例子:https://gist.github.com/tlrx/4117854
关于testing - Elasticsearch 在测试中途抛出 'ElasticsearchIllegalStateException',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35336694/