2017-04-10 11 views
1

私はelasticsearchコンテナを使用してテストを書きます。 https://www.testcontainers.org/ライブラリで実行します。私はテストのための私のポートを再設定し、9200ポートが使用可能であるテストのための伸縮性検索とテスト容器

org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{9fuJUZYWS6O6IgLGOgJDaA}{localhost}{127.0.0.1:32792}] 

(testcontainersによってマッピングされたポート上) - 私はでそれを確認: それは私の設定です:

@ClassRule 
public static GenericContainer elasticContainer = 
     new GenericContainer("docker.elastic.co/elasticsearch/elasticsearch:5.3.0") 
       .withExposedPorts(9300, 9200) 
       .withEnv("xpack.security.enabled", "false") 
       .withEnv("transport.host", "127.0.0.1") 
       .withEnv("http.host", "0.0.0.0"); 

そして私は、例外が発生しましたカール。しかし、9300はそうではありません。

誰もがトランスポートホストの問題を修正する方法を知っていますか?

答えて

3

問題は弾力性のある検索コンテナであり、testcontainersではなくlibです。

私はここ https://github.com/olivere/elastic/issues/57#issuecomment-88697714

交通クライアントは、コンテナ内のElasticSearchノードを解決できない解決策を発見しました。

最終的なコードは次のとおりです。

@ClassRule 
public static GenericContainer elasticContainer = 
     new FixedHostPortGenericContainer("docker.elastic.co/elasticsearch/elasticsearch:5.3.0") 
       .withFixedExposedPort(9200, 9200) 
       .withFixedExposedPort(9300, 9300) 
       .waitingFor(Wait.forHttp("/")) // Wait until elastic start 
       .withEnv("xpack.security.enabled", "false") 
       .withEnv("network.host", "_site_") 
       .withEnv("network.publish_host", "_local_"); 

また、あなただけのドッキングウィンドウでElasticSearchを開始し、9300(トランスポート・ポート)を使用する場合は、この実行します。

docker run -p 9300:9300 -p 9200:9200 -e "xpack.security.enabled=false" -e "network.host=_site_" -e "network.publish_host=_local_" docker.elastic.co/elasticsearch/elasticsearch:5.3.0 
関連する問題