[TEST] Add simple test to test RT Lucene IW settings

This commit is contained in:
Simon Willnauer 2014-09-02 16:33:40 +02:00
parent 89f8f6c51e
commit cb206c94ec
3 changed files with 51 additions and 0 deletions

View File

@ -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) {

View File

@ -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));
}
}

View File

@ -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.
*/