我正在使用Elasticsearch 2.3,我想开始集成测试一个可以通过HTTP访问的内存中节点。
我有一些
https://www.elastic.co/guide/en/elasticsearch/reference/current/integration-tests.html
我可以将此框架与Specs2一起使用吗?
我使用Scala,因此最好让它在我的Stack中使用Specs2,而不仅仅是JUnit。
同样,我想测试通过Elastic的Rest API访问它的数据。
谢谢!
答案 0 :(得分:0)
一个简单的解决方案是启动内存弹性搜索
import org.elasticsearch.common.settings.ImmutableSettings._
import org.elasticsearch.node.NodeBuilder._
class InMemoryEmbeddedElasticSearch {
def doStart(): Unit = node.start
def stop(): Unit = {
node.stop()
node.close()
}
private val dataDirectory = s"target/elastic/"
private val node =
nodeBuilder().settings(
settingsBuilder.put("node.local", "false",
"network.host", "127.0.0.1",
"http.enabled", "true",
"path.data", dataDirectory))
.node()
}