ElasticSearch failed to start: AssertionError while creating Node object

37 views Asked by At

I'm trying to create a Node object using below environment settings- environment settings:

 Settings elasticsearchSettings = Settings.builder()
            .put("http.cors.enabled", "true")
            .put("path.data", "target/es-data_" + UUIDs.randomBase64UUID().toLowerCase())
            .put("path.home", "target/es-home_" + UUIDs.randomBase64UUID().toLowerCase())
            .put("cluster.name", "testCluster")
            .put(NetworkModule.HTTP_TYPE_KEY, "netty4")
            .put("http.port", 9200)
            .build();
 private static class ElasticNode extends Node {
        public ElasticNode(Settings settings, Collection<Class<? extends Plugin>> classpathPlugins) {
            super(InternalSettingsPreparer.prepareEnvironment(settings,new HashMap<>(), null, () -> "node1"), classpathPlugins, false);
        }
        
    }

ElasticSearch version 7.17.10, Java version: 11.0.4, vendor: Oracle Corporation, OS name: "linux", version: "5.15.0-67-generic", arch: "amd64", family: "UNIX"

and getting the following error:-

    Caused by: java.lang.AssertionError
    #14 85.59   at org.elasticsearch.monitor.os.OsProbe.getControlGroups(OsProbe.java:262) ~[elasticsearch-7.17.10.jar:7.17.10]

what I'm missing in the config? Please help!

1

There are 1 answers

0
imotov On

For integration testing my suggestion would be to start elasticsearch externally. For example, you can configure it using docker compose and spawn it before running your tests. Alternatively, you can spawn elasticsearch as a separate process from your test or from gradle (if you are good with it). There is just way too much stuff happening during the node bootstrapping process to try replicating it in your code.

Even elasticsearch project itself is spawning elasticsearch cluster in a special gradle tasks. By the way this task is available in their test framework, so you can use their gradle build plugin to incorporate such task in your project. Here is an example of how to do that - https://github.com/imotov/esitsandbox