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("", dataDirectory)
        .put("script.disable_dynamic", "false")
        .put("script.inline", "on")
        .put("script.indexed", "on")
        .put(EsExecutors.PROCESSORS, 1)
        .put("", "ram")
        .put("gateway.type", "none")

node = nodeBuilder()
        .clusterName("cluster_" + (new java.util.Random().nextInt()))

Client client = node.client();

Settings indexSettings = ImmutableSettings.settingsBuilder()
        .put("number_of_shards", 1)
        .put("number_of_replicas", 1)
CreateIndexRequest indexRequest = new CreateIndexRequest(
        "test_inst", indexSettings);



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

All Articles