From cb206c94ecd4b435e7c76cfa919afbd243da2082 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Tue, 2 Sep 2014 16:33:40 +0200 Subject: [PATCH] [TEST] Add simple test to test RT Lucene IW settings --- .../index/engine/internal/InternalEngine.java | 5 +++ .../internal/InternalEngineSettingsTest.java | 40 +++++++++++++++++++ .../test/ElasticsearchSingleNodeTest.java | 6 +++ 3 files changed, 51 insertions(+) create mode 100644 src/test/java/org/elasticsearch/index/engine/internal/InternalEngineSettingsTest.java diff --git a/src/main/java/org/elasticsearch/index/engine/internal/InternalEngine.java b/src/main/java/org/elasticsearch/index/engine/internal/InternalEngine.java index 640998a4449..56058ebc3d0 100644 --- a/src/main/java/org/elasticsearch/index/engine/internal/InternalEngine.java +++ b/src/main/java/org/elasticsearch/index/engine/internal/InternalEngine.java @@ -1281,6 +1281,11 @@ public class InternalEngine extends AbstractIndexShardComponent implements Engin } } + LiveIndexWriterConfig currentIndexWriterConfig() { + ensureOpen(); + return this.indexWriter.getConfig(); + } + class FailEngineOnMergeFailure implements MergeSchedulerProvider.FailureListener { @Override public void onFailedMerge(MergePolicy.MergeException e) { diff --git a/src/test/java/org/elasticsearch/index/engine/internal/InternalEngineSettingsTest.java b/src/test/java/org/elasticsearch/index/engine/internal/InternalEngineSettingsTest.java new file mode 100644 index 00000000000..0e3c1cf5554 --- /dev/null +++ b/src/test/java/org/elasticsearch/index/engine/internal/InternalEngineSettingsTest.java @@ -0,0 +1,40 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.index.engine.internal; + +import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.test.ElasticsearchSingleNodeTest; + +import static org.hamcrest.Matchers.is; + +public class InternalEngineSettingsTest extends ElasticsearchSingleNodeTest { + + public void testLuceneSettings() { + final IndexService service = createIndex("foo"); + // INDEX_COMPOUND_ON_FLUSH + assertThat(engine(service).currentIndexWriterConfig().getUseCompoundFile(), is(true)); + client().admin().indices().prepareUpdateSettings("foo").setSettings(ImmutableSettings.builder().put(InternalEngine.INDEX_COMPOUND_ON_FLUSH, false).build()).get(); + assertThat(engine(service).currentIndexWriterConfig().getUseCompoundFile(), is(false)); + client().admin().indices().prepareUpdateSettings("foo").setSettings(ImmutableSettings.builder().put(InternalEngine.INDEX_COMPOUND_ON_FLUSH, true).build()).get(); + assertThat(engine(service).currentIndexWriterConfig().getUseCompoundFile(), is(true)); + } + + +} diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeTest.java index fd9e1fd8fe4..2f8bb5ff7fa 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeTest.java @@ -34,7 +34,9 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.index.engine.internal.InternalEngine; import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.shard.service.InternalIndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.node.Node; import org.elasticsearch.node.NodeBuilder; @@ -172,6 +174,10 @@ public abstract class ElasticsearchSingleNodeTest extends ElasticsearchTestCase return instanceFromNode.indexServiceSafe(index); } + protected static InternalEngine engine(IndexService service) { + return ((InternalEngine)((InternalIndexShard)service.shard(0)).engine()); + } + /** * Create a new search context. */