Configuring Elasticsearch for Java Integration Tests
I inherited a project that has a lot of sleep statements that allow Elasticsearch to index in their integration tests ... deep breath.
Most of the time I have a tiny amount of data in Elasticsearch and would really like me to wait. I installed node in JVM for my tests like this:
ImmutableSettings.Builder elasticsearchSettings = ImmutableSettings.settingsBuilder() .put("http.enabled", "false") .put("path.data", dataDirectory) .put("script.disable_dynamic", "false") .put("script.inline", "on") .put("script.indexed", "on") .put(EsExecutors.PROCESSORS, 1) .put("index.store.type", "ram") .put("gateway.type", "none") ; node = nodeBuilder() .clusterName("cluster_" + (new java.util.Random().nextInt())) .local(true) .data(true) .settings(elasticsearchSettings.build()) .node(); Client client = node.client(); Settings indexSettings = ImmutableSettings.settingsBuilder() .put("number_of_shards", 1) .put("number_of_replicas", 1) .build(); CreateIndexRequest indexRequest = new CreateIndexRequest( "test_inst", indexSettings); client.admin().indices().create(indexRequest).actionGet();
However, I still get a lot of crashes when I reduce sleep times and some requests that go against the external emergency search instance fail when running node in the JVM.
I tried to do an update using:
but it doesn't seem to help. Some of the glitches are intermittent, which implies that I am exposed to the 1st refresh interval.
Does anyone have any suggestions on how to force the indexing so that I can speed up these tests?
source to share
No one has answered this question yet
Check out similar questions: