testing - Elasticsearch 在测试中途抛出 'ElasticsearchIllegalStateException'

标签 testing elasticsearch groovy junit

我有一个大型 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/

相关文章:

asp.net - 这是测试演示者的正确方法吗

用于标准输入测试的 Golang 模式

elasticsearch - 在 Elastic Search 中将嵌套查询与 bool 查询相结合

c# - 计算Elasticsearch中的过滤数据(ElasticClient nest)

grails - Grails命令对象和输入名称值

unit-testing - 您如何测试特定的 Rust 错误?

在没有 FPGA 的情况下测试我的 HDL 代码(Verilog/VHDL)?

amazon-web-services - Lambda S3 getObject流到ES接收管道

grails - 检查变量是否为数组

java - groovy 脚本 eval(string) 方法的性能问题