Search in sources :

Example 1 with Settings

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class EvilLoggerTests method testProperties.

public void testProperties() throws IOException, UserException {
    final Settings.Builder builder = Settings.builder().put("cluster.name", randomAsciiOfLength(16));
    if (randomBoolean()) {
        builder.put("node.name", randomAsciiOfLength(16));
    }
    final Settings settings = builder.build();
    setupLogging("minimal", settings);
    assertNotNull(System.getProperty("es.logs.base_path"));
    assertThat(System.getProperty("es.logs.cluster_name"), equalTo(ClusterName.CLUSTER_NAME_SETTING.get(settings).value()));
    if (Node.NODE_NAME_SETTING.exists(settings)) {
        assertThat(System.getProperty("es.logs.node_name"), equalTo(Node.NODE_NAME_SETTING.get(settings)));
    } else {
        assertNull(System.getProperty("es.logs.node_name"));
    }
}
Also used : Settings(org.elasticsearch.common.settings.Settings)

Example 2 with Settings

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class NodeEnvironmentEvilTests method testMissingWritePermissionOnIndex.

public void testMissingWritePermissionOnIndex() throws IOException {
    assumeTrue("posix filesystem", isPosix);
    final String[] tempPaths = tmpPaths();
    Path path = PathUtils.get(randomFrom(tempPaths));
    Path fooIndex = path.resolve("nodes").resolve("0").resolve(NodeEnvironment.INDICES_FOLDER).resolve("foo");
    Files.createDirectories(fooIndex);
    try (PosixPermissionsResetter attr = new PosixPermissionsResetter(fooIndex)) {
        attr.setPermissions(new HashSet<>(Arrays.asList(PosixFilePermission.OTHERS_READ, PosixFilePermission.GROUP_READ, PosixFilePermission.OWNER_READ)));
        Settings build = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toAbsolutePath().toString()).putArray(Environment.PATH_DATA_SETTING.getKey(), tempPaths).build();
        IOException ioException = expectThrows(IOException.class, () -> {
            new NodeEnvironment(build, new Environment(build));
        });
        assertTrue(ioException.getMessage(), ioException.getMessage().startsWith("failed to write in data directory"));
    }
}
Also used : Path(java.nio.file.Path) IOException(java.io.IOException) PosixPermissionsResetter(org.elasticsearch.test.PosixPermissionsResetter) Settings(org.elasticsearch.common.settings.Settings)

Example 3 with Settings

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class AwsS3ServiceImplTests method testAwsCredsExplicitConfigSettings.

public void testAwsCredsExplicitConfigSettings() {
    Settings repositorySettings = Settings.builder().put(InternalAwsS3Service.CLIENT_NAME.getKey(), "myconfig").build();
    MockSecureSettings secureSettings = new MockSecureSettings();
    secureSettings.setString("s3.client.myconfig.access_key", "aws_key");
    secureSettings.setString("s3.client.myconfig.secret_key", "aws_secret");
    secureSettings.setString("s3.client.default.access_key", "wrong_key");
    secureSettings.setString("s3.client.default.secret_key", "wrong_secret");
    Settings settings = Settings.builder().setSecureSettings(secureSettings).build();
    launchAWSCredentialsWithElasticsearchSettingsTest(repositorySettings, settings, "aws_key", "aws_secret");
}
Also used : MockSecureSettings(org.elasticsearch.common.settings.MockSecureSettings) Settings(org.elasticsearch.common.settings.Settings) MockSecureSettings(org.elasticsearch.common.settings.MockSecureSettings)

Example 4 with Settings

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class AwsS3ServiceImplTests method testAWSConfigurationWithAwsAndS3SettingsBackcompat.

public void testAWSConfigurationWithAwsAndS3SettingsBackcompat() {
    Settings settings = Settings.builder().put(AwsS3Service.PROTOCOL_SETTING.getKey(), "http").put(AwsS3Service.PROXY_HOST_SETTING.getKey(), "aws_proxy_host").put(AwsS3Service.PROXY_PORT_SETTING.getKey(), 8080).put(AwsS3Service.PROXY_USERNAME_SETTING.getKey(), "aws_proxy_username").put(AwsS3Service.PROXY_PASSWORD_SETTING.getKey(), "aws_proxy_password").put(AwsS3Service.SIGNER_SETTING.getKey(), "AWS3SignerType").put(AwsS3Service.READ_TIMEOUT.getKey(), "5s").put(AwsS3Service.CLOUD_S3.PROTOCOL_SETTING.getKey(), "https").put(AwsS3Service.CLOUD_S3.PROXY_HOST_SETTING.getKey(), "s3_proxy_host").put(AwsS3Service.CLOUD_S3.PROXY_PORT_SETTING.getKey(), 8081).put(AwsS3Service.CLOUD_S3.PROXY_USERNAME_SETTING.getKey(), "s3_proxy_username").put(AwsS3Service.CLOUD_S3.PROXY_PASSWORD_SETTING.getKey(), "s3_proxy_password").put(AwsS3Service.CLOUD_S3.SIGNER_SETTING.getKey(), "NoOpSignerType").put(AwsS3Service.CLOUD_S3.READ_TIMEOUT.getKey(), "10s").build();
    launchAWSConfigurationTest(settings, Settings.EMPTY, Protocol.HTTPS, "s3_proxy_host", 8081, "s3_proxy_username", "s3_proxy_password", "NoOpSignerType", 3, false, 10000);
    assertSettingDeprecationsAndWarnings(new Setting<?>[] { AwsS3Service.PROXY_USERNAME_SETTING, AwsS3Service.PROXY_PASSWORD_SETTING, AwsS3Service.PROTOCOL_SETTING, AwsS3Service.PROXY_HOST_SETTING, AwsS3Service.PROXY_PORT_SETTING, AwsS3Service.SIGNER_SETTING, AwsS3Service.READ_TIMEOUT, AwsS3Service.CLOUD_S3.PROXY_USERNAME_SETTING, AwsS3Service.CLOUD_S3.PROXY_PASSWORD_SETTING, AwsS3Service.CLOUD_S3.PROTOCOL_SETTING, AwsS3Service.CLOUD_S3.PROXY_HOST_SETTING, AwsS3Service.CLOUD_S3.PROXY_PORT_SETTING, AwsS3Service.CLOUD_S3.SIGNER_SETTING, AwsS3Service.CLOUD_S3.READ_TIMEOUT });
}
Also used : MockSecureSettings(org.elasticsearch.common.settings.MockSecureSettings) Settings(org.elasticsearch.common.settings.Settings)

Example 5 with Settings

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class AwsS3ServiceImplTests method testRepositoryMaxRetries.

public void testRepositoryMaxRetries() {
    Settings repositorySettings = generateRepositorySettings(null, null, null, 20);
    Settings settings = Settings.builder().put(S3Repository.Repositories.MAX_RETRIES_SETTING.getKey(), 10).build();
    launchAWSConfigurationTest(settings, repositorySettings, Protocol.HTTPS, null, -1, null, null, null, 20, false, 50000);
}
Also used : MockSecureSettings(org.elasticsearch.common.settings.MockSecureSettings) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

Settings (org.elasticsearch.common.settings.Settings)1248 Test (org.junit.Test)197 IndexSettings (org.elasticsearch.index.IndexSettings)167 IOException (java.io.IOException)133 Path (java.nio.file.Path)121 ClusterState (org.elasticsearch.cluster.ClusterState)120 ArrayList (java.util.ArrayList)108 ClusterSettings (org.elasticsearch.common.settings.ClusterSettings)106 HashMap (java.util.HashMap)105 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)98 Version (org.elasticsearch.Version)91 Matchers.containsString (org.hamcrest.Matchers.containsString)91 Environment (org.elasticsearch.env.Environment)87 Map (java.util.Map)85 List (java.util.List)79 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)72 Index (org.elasticsearch.index.Index)70 HashSet (java.util.HashSet)58 IndexMetadata (org.elasticsearch.cluster.metadata.IndexMetadata)54 ThreadPool (org.elasticsearch.threadpool.ThreadPool)54