Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Settings to improve elasticsearch startup time for unit tests?

I'm writing tests that start a elasticsearch 6.4 single-node cluster to ensure that my queries behave as expected. It takes about 10 seconds for the cluster to start an my tests RestHighLevelClient to ping it without a connection error

Process proc = new ProcessBuilder("elasticsearch").start();
RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(
  new HttpHost('localhost', 9200, 'http'),
  new HttpHost('localhost', 9201, 'http'),

));

// wait for cluster, takes about 10 seconds in practice.
do {
  try {
    client.ping(RequestOptions.DEFAULT);
    break;
  } catch (IOException ex) { }
} while (true);

Are there settings I can change to improve startup time?

  • I don't need to persist indexes across test runs, so the index could be kept in memory. I don't see memory listed in the 6.4 store types
  • Are there settings that cause the whole cluster to run without writing to disk (disable logging, disable file storage, disable pid/state)?
  • The cluster will be single-node so I can disable discovery, but I haven't found that setting. Edit: discovery.type=single-node in 6.4
like image 969
everett1992 Avatar asked Sep 16 '19 21:09

everett1992


1 Answers

There's no way so store all indexes into memory. index.store.type: memory did exist in ES 1.x but disappeared in ES 2.0 a long time ago.

You can disable all logging by modifying te log4j2.properties file and setting all loggers to OFF (and optionally use a NullAppender)

logger.action.level = OFF
rootLogger.level = OFF
logger.deprecation.level = OFF
logger.index_search_slowlog_rolling.level = OFF
logger.index_indexing_slowlog.level = OFF
logger.xpack_security_audit_logfile.level = OFF

Regarding disabling the discovery, you got it right by setting discovery.type=single-node

like image 135
Val Avatar answered Sep 30 '22 16:09

Val