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:

elasticSearchClientUtil.getClient().admin().indices().prepareRefresh().execute().actionGet();

      

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?

+3
java elasticsearch


source to share


No one has answered this question yet

Check out similar questions:

6170
Is Java "pass-by-reference" or "pass-by-value"?
3799
How do I read / convert an InputStream to a string in Java?
3324
How to generate random integers in a specific range in Java?
3073
How to efficiently loop over each entry in a Java map?
3044
Making a memory leak with Java
2956
What is the difference between public, secure, batch and private in Java?
2936
When to use LinkedList over ArrayList in Java?
2853
How can I convert String to int in Java?
2248
Is a finally block always executable in Java?
2171
How to determine if an array contains a specific value in Java?



All Articles
Loading...
X
Show
Funny
Dev
Pics