gpt4 book ai didi

java - Elasticsearch 2.2.0 ESIntegTestCase : ensureYellow() results in “timed out waiting for yellow”

转载 作者:行者123 更新时间:2023-11-30 07:32:32 27 4
gpt4 key购买 nike

我正在重写我们的集成测试以与 Elasticsearch 2.2.0 配合使用。我有一个扩展 org.elasticsearch.test.ESIntegTestCase 的抽象测试用例类:

@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1)
@ThreadLeakScope(ThreadLeakScope.Scope.NONE)
public abstract class AbstractApplicationTest extends ESIntegTestCase {
...

@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.settingsBuilder()
.put(super.nodeSettings(nodeOrdinal))
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
.put(Node.HTTP_ENABLED, true)
.put("script.groovy.sandbox.enabled", true)
.put("script.engine.groovy.inline.search", true)
.put("script.engine.groovy.inline.update", "true")
.put("script.inline", true)
.put("script.update", true)
.put("script.indexed", true)
.put("script.default_lang", "groovy")
.build();
}

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return pluginList(GroovyPlugin.class, DeleteByQueryPlugin.class, AnalysisICUPlugin.class);
}

@Before
public void setUpElastic() throws Exception {
// add the index and the mappings
prepareCreate("bokun")
.setSettings(Settings.builder().loadFromSource(loadFromClasspath("indices/settings.json")))
.addMapping(AccommodationSearchIndex.INDEX_ACCOMMODATION_TYPE, loadFromClasspath("indices/accommodation.json"))
.addMapping(AccommodationSearchIndex.INDEX_ROOM_TYPE, loadFromClasspath("indices/room.json"))
...
.execute().actionGet();
ensureYellow();
}
...
}

我的测试用例类扩展了这个抽象类。它有 6 个测试,其中 3-4 个测试不断失败,并在上面的调用 ensureYellow() 期间显示“等待黄色超时”消息。

如果我注释掉 ensureYellow() 调用,那么在执行索引请求时我会从 Elasticsearch 收到“unavailable_shards_exception”:

{
"took": 60001,
"errors": true,
"items": [{
"index": {
"_index": "bokun",
"_type": "activity_availability",
"_id": "20_20160309",
"status": 503,
"error": {
"type": "unavailable_shards_exception",
"reason": "[bokun][2] primary shard is not active Timeout: [1m], request: [shard bulk {[bokun][2]}]"
}
}
}, {
"index": {
"_index": "bokun",
"_type": "activity_availability",
"_id": "20_20160310",
"status": 503,
"error": {
"type": "unavailable_shards_exception",
"reason": "[bokun][1] primary shard is not active Timeout: [1m], request: [shard bulk {[bokun][1]}]"
}
}
},
...
{
"index": {
"_index": "bokun",
"_type": "activity_availability",
"_id": "20_20160322",
"status": 503,
"error": {
"type": "unavailable_shards_exception",
"reason": "[bokun][0] primary shard is not active Timeout: [1m], request: [shard bulk {[bokun][0]}]"
}
}
}, {
"index": {
"_index": "bokun",
"_type": "activity",
"_id": "12",
"status": 503,
"error": {
"type": "unavailable_shards_exception",
"reason": "[bokun][2] primary shard is not active Timeout: [1m], request: [shard bulk {[bokun][2]}]"
}
}
}]
}

测试用例范围是ESIntegTestCase.Scope.SUITE,这意味着将为每个SUITE而不是测试创建一个集群,然后我在每个测试之前创建索引并添加映射。我假设每次测试后索引都会被删除,如 page状态:

By default the tests are run with unique cluster per test suite. Of course all indices and templates are deleted between each test.

有人知道我在这里做错了什么吗?

附注我正在使用 SBT 来运行我的测试。

最佳答案

我已经解决了这个问题。我启动了一个调试器,并在 EsIntegTestCase 中找到了一条日志语句,但我没有输出。所以我修改了我的日志配置,然后来自elasticsearch的实际错误开始出现。

问题是字段映射不一致:

ensureYellow timed out, cluster state:
version: 8
state uuid: twZ91SH7QIytVTrQuixDbg
from_diff: false
meta data version: 3
nodes:
{node_s0}{H_1t-4MwSKueM5vXRw_P4A}{local}{local[1]}{mode=local}, local, master
routing_table (version 6):
-- index [bokun]
----shard_id [bokun][0]
--------[bokun][0], node[null], [P], v[3], s[UNASSIGNED], unassigned_info[[reason=ALLOCATION_FAILED], at[2016-03-09T13:07:48.812Z], details[failed to update mappings, failure IllegalArgumentException[Mapper for [translations.excerpt] conflicts with existing mapping in other types:
[mapper [translations.excerpt] has different [store] values]]]]

关于java - Elasticsearch 2.2.0 ESIntegTestCase : ensureYellow() results in “timed out waiting for yellow” ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35887431/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com