|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License |
| 4 | + * 2.0 and the Server Side Public License, v 1; you may not use this file except |
| 5 | + * in compliance with, at your election, the Elastic License 2.0 or the Server |
| 6 | + * Side Public License, v 1. |
| 7 | + */ |
| 8 | + |
| 9 | +package org.elasticsearch.packaging.test; |
| 10 | + |
| 11 | +import org.elasticsearch.packaging.util.ServerUtils; |
| 12 | +import org.elasticsearch.packaging.util.docker.DockerRun; |
| 13 | + |
| 14 | +import java.util.Map; |
| 15 | + |
| 16 | +import static org.elasticsearch.packaging.util.docker.Docker.runContainer; |
| 17 | +import static org.elasticsearch.packaging.util.docker.DockerRun.builder; |
| 18 | + |
| 19 | +public class MemoryLockingTests extends PackagingTestCase { |
| 20 | + |
| 21 | + public void test10Install() throws Exception { |
| 22 | + install(); |
| 23 | + } |
| 24 | + |
| 25 | + public void test20MemoryLockingEnabled() throws Exception { |
| 26 | + configureAndRun( |
| 27 | + Map.of( |
| 28 | + "bootstrap.memory_lock", |
| 29 | + "true", |
| 30 | + "xpack.security.enabled", |
| 31 | + "false", |
| 32 | + "xpack.security.http.ssl.enabled", |
| 33 | + "false", |
| 34 | + "xpack.security.enrollment.enabled", |
| 35 | + "false", |
| 36 | + "discovery.type", |
| 37 | + "single-node" |
| 38 | + ) |
| 39 | + ); |
| 40 | + // TODO: very locking worked. logs? check memory of process? at least we know the process started successfully |
| 41 | + stopElasticsearch(); |
| 42 | + } |
| 43 | + |
| 44 | + public void configureAndRun(Map<String, String> settings) throws Exception { |
| 45 | + if (distribution().isDocker()) { |
| 46 | + DockerRun builder = builder(); |
| 47 | + settings.forEach(builder::envVar); |
| 48 | + runContainer(distribution(), builder); |
| 49 | + } else { |
| 50 | + |
| 51 | + for (var setting : settings.entrySet()) { |
| 52 | + ServerUtils.addSettingToExistingConfiguration(installation.config, setting.getKey(), setting.getValue()); |
| 53 | + } |
| 54 | + ServerUtils.removeSettingFromExistingConfiguration(installation.config, "cluster.initial_master_nodes"); |
| 55 | + } |
| 56 | + |
| 57 | + startElasticsearch(); |
| 58 | + } |
| 59 | +} |
0 commit comments