use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.
the class MetadataIndexTemplateServiceTests method putTemplate.
private static List<Throwable> putTemplate(NamedXContentRegistry xContentRegistry, PutRequest request) {
MetadataCreateIndexService createIndexService = new MetadataCreateIndexService(Settings.EMPTY, null, null, null, null, createTestShardLimitService(randomIntBetween(1, 1000)), new Environment(builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(), null), IndexScopedSettings.DEFAULT_SCOPED_SETTINGS, null, xContentRegistry, new SystemIndices(Collections.emptyMap()), true);
MetadataIndexTemplateService service = new MetadataIndexTemplateService(null, createIndexService, new AliasValidator(), null, new IndexScopedSettings(Settings.EMPTY, IndexScopedSettings.BUILT_IN_INDEX_SETTINGS), xContentRegistry);
final List<Throwable> throwables = new ArrayList<>();
service.putTemplate(request, new MetadataIndexTemplateService.PutListener() {
@Override
public void onResponse(MetadataIndexTemplateService.PutResponse response) {
}
@Override
public void onFailure(Exception e) {
throwables.add(e);
}
});
return throwables;
}
use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.
the class MetadataIndexTemplateServiceTests method getMetadataIndexTemplateService.
private MetadataIndexTemplateService getMetadataIndexTemplateService() {
IndicesService indicesService = getInstanceFromNode(IndicesService.class);
ClusterService clusterService = getInstanceFromNode(ClusterService.class);
MetadataCreateIndexService createIndexService = new MetadataCreateIndexService(Settings.EMPTY, clusterService, indicesService, null, null, createTestShardLimitService(randomIntBetween(1, 1000)), new Environment(builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(), null), IndexScopedSettings.DEFAULT_SCOPED_SETTINGS, null, xContentRegistry(), new SystemIndices(Collections.emptyMap()), true);
return new MetadataIndexTemplateService(clusterService, createIndexService, new AliasValidator(), indicesService, new IndexScopedSettings(Settings.EMPTY, IndexScopedSettings.BUILT_IN_INDEX_SETTINGS), xContentRegistry());
}
use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.
the class InternalSettingsPreparerTests method testDefaultPropertiesDoNothing.
public void testDefaultPropertiesDoNothing() throws Exception {
Map<String, String> props = Collections.singletonMap("default.setting", "foo");
Environment env = InternalSettingsPreparer.prepareEnvironment(baseEnvSettings, props, null, () -> "default_node_name");
assertEquals("foo", env.settings().get("default.setting"));
assertNull(env.settings().get("setting"));
}
use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.
the class InternalSettingsPreparerTests method testEmptySettings.
public void testEmptySettings() {
Settings settings = InternalSettingsPreparer.prepareSettings(Settings.EMPTY);
assertNull(settings.get("node.name"));
// a cluster name was set
assertNotNull(settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey()));
int size = settings.names().size();
String defaultNodeName = randomAlphaOfLength(8);
Environment env = InternalSettingsPreparer.prepareEnvironment(baseEnvSettings, emptyMap(), null, () -> defaultNodeName);
settings = env.settings();
assertEquals(defaultNodeName, settings.get("node.name"));
// a cluster name was set
assertNotNull(settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey()));
assertEquals(settings.toString(), size + 1, /* path.home is in the base settings */
settings.names().size());
String home = Environment.PATH_HOME_SETTING.get(baseEnvSettings);
String configDir = env.configFile().toString();
assertTrue(configDir, configDir.startsWith(home));
}
use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.
the class BlobStoreRepositoryTests method testFsRepositoryCompressDeprecated.
public void testFsRepositoryCompressDeprecated() {
final Path location = OpenSearchIntegTestCase.randomRepoPath(node().settings());
final Settings settings = Settings.builder().put(node().settings()).put("location", location).build();
final RepositoryMetadata metadata = new RepositoryMetadata("test-repo", REPO_TYPE, settings);
Settings useCompressSettings = Settings.builder().put(node().getEnvironment().settings()).put(FsRepository.REPOSITORIES_COMPRESS_SETTING.getKey(), true).build();
Environment useCompressEnvironment = new Environment(useCompressSettings, node().getEnvironment().configFile());
new FsRepository(metadata, useCompressEnvironment, null, BlobStoreTestUtil.mockClusterService(), null);
assertWarnings("[repositories.fs.compress] setting was deprecated in OpenSearch and will be removed in a future release!" + " See the breaking changes documentation for the next major version.");
}
Aggregations