[TEST] Move NoMergePolicyProvider into it's own class

This commit is contained in:
Simon Willnauer 2014-11-30 12:57:33 +01:00
parent c4fd1247c0
commit c630b1e8a4
4 changed files with 50 additions and 36 deletions

View File

@ -71,6 +71,7 @@ import org.elasticsearch.indices.recovery.RecoveryTarget;
import org.elasticsearch.monitor.fs.FsStats; import org.elasticsearch.monitor.fs.FsStats;
import org.elasticsearch.snapshots.SnapshotState; import org.elasticsearch.snapshots.SnapshotState;
import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.index.merge.NoMergePolicyProvider;
import org.elasticsearch.test.store.MockFSDirectoryService; import org.elasticsearch.test.store.MockFSDirectoryService;
import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.transport.*; import org.elasticsearch.transport.*;
@ -596,22 +597,4 @@ public class CorruptedFileTest extends ElasticsearchIntegrationTest {
"index.routing.allocation.enable", "all" "index.routing.allocation.enable", "all"
)).get(); )).get();
} }
public static class NoMergePolicyProvider extends AbstractMergePolicyProvider<MergePolicy> {
@Inject
public NoMergePolicyProvider(Store store) {
super(store);
}
@Override
public MergePolicy getMergePolicy() {
return NoMergePolicy.INSTANCE;
}
@Override
public void close() throws ElasticsearchException {
}
}
} }

View File

@ -35,6 +35,7 @@ import org.elasticsearch.index.service.IndexService;
import org.elasticsearch.index.shard.service.InternalIndexShard; import org.elasticsearch.index.shard.service.InternalIndexShard;
import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.index.merge.NoMergePolicyProvider;
import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.update.UpdateTests; import org.elasticsearch.update.UpdateTests;
import org.junit.Test; import org.junit.Test;
@ -55,7 +56,7 @@ public class ParentFieldLoadingTest extends ElasticsearchIntegrationTest {
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
.put(InternalIndexShard.INDEX_REFRESH_INTERVAL, -1) .put(InternalIndexShard.INDEX_REFRESH_INTERVAL, -1)
// We never want merges in this test to ensure we have two segments for the last validation // We never want merges in this test to ensure we have two segments for the last validation
.put(MergePolicyModule.MERGE_POLICY_TYPE_KEY, UpdateTests.NoMergePolicyProvider.class) .put(MergePolicyModule.MERGE_POLICY_TYPE_KEY, NoMergePolicyProvider.class)
.build(); .build();
@Test @Test

View File

@ -0,0 +1,46 @@
/*
* 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.test.index.merge;
import org.apache.lucene.index.MergePolicy;
import org.apache.lucene.index.NoMergePolicy;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.index.merge.policy.AbstractMergePolicyProvider;
import org.elasticsearch.index.store.Store;
/**
* {@link org.elasticsearch.index.merge.policy.MergePolicyProvider} for lucenes {@link org.apache.lucene.index.NoMergePolicy}
*/
public class NoMergePolicyProvider extends AbstractMergePolicyProvider<MergePolicy> {
@Inject
public NoMergePolicyProvider(Store store) {
super(store);
}
@Override
public MergePolicy getMergePolicy() {
return NoMergePolicy.INSTANCE;
}
@Override
public void close() throws ElasticsearchException {}
}

View File

@ -46,6 +46,7 @@ import org.elasticsearch.index.merge.policy.MergePolicyModule;
import org.elasticsearch.index.store.Store; import org.elasticsearch.index.store.Store;
import org.elasticsearch.script.ScriptService; import org.elasticsearch.script.ScriptService;
import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.elasticsearch.test.index.merge.NoMergePolicyProvider;
import org.junit.Test; import org.junit.Test;
import java.util.ArrayList; import java.util.ArrayList;
@ -614,23 +615,6 @@ public class UpdateTests extends ElasticsearchIntegrationTest {
} }
public static class NoMergePolicyProvider extends AbstractMergePolicyProvider<MergePolicy> {
@Inject
public NoMergePolicyProvider(Store store) {
super(store);
}
@Override
public MergePolicy getMergePolicy() {
return NoMergePolicy.INSTANCE;
}
@Override
public void close() throws ElasticsearchException {
}
}
@Test @Test
@Slow @Slow
public void stressUpdateDeleteConcurrency() throws Exception { public void stressUpdateDeleteConcurrency() throws Exception {