LUCENE-7006: increase BaseMergePolicyTestCase use (TestNoMergePolicy and TestSortingMergePolicy now extend it, TestUpgradeIndexMergePolicy added)

This commit is contained in:
Christine Poerschke 2016-02-01 17:51:09 +00:00
parent fce97a6ca6
commit ce0b931da8
4 changed files with 42 additions and 4 deletions

View File

@ -266,6 +266,10 @@ Other
* LUCENE-7005: TieredMergePolicy tweaks (>= vs. >, @see get vs. set)
(Christine Poerschke)
* LUCENE-7006: increase BaseMergePolicyTestCase use (TestNoMergePolicy and
TestSortingMergePolicy now extend it, TestUpgradeIndexMergePolicy added)
(Christine Poerschke)
======================= Lucene 5.4.1 =======================
Bug Fixes

View File

@ -25,11 +25,15 @@ import java.util.Arrays;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test;
public class TestNoMergePolicy extends LuceneTestCase {
public class TestNoMergePolicy extends BaseMergePolicyTestCase {
public MergePolicy mergePolicy() {
return NoMergePolicy.INSTANCE;
}
@Test
public void testNoMergePolicy() throws Exception {
MergePolicy mp = NoMergePolicy.INSTANCE;
MergePolicy mp = mergePolicy();
assertNull(mp.findMerges(null, (SegmentInfos)null, null));
assertNull(mp.findForcedMerges(null, 0, null, null));
assertNull(mp.findForcedDeletesMerges(null, null));

View File

@ -0,0 +1,26 @@
package org.apache.lucene.index;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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.
*/
public class TestUpgradeIndexMergePolicy extends BaseMergePolicyTestCase {
public MergePolicy mergePolicy() {
return new UpgradeIndexMergePolicy(newMergePolicy(random()));
}
}

View File

@ -50,7 +50,7 @@ import org.apache.lucene.util.TestUtil;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
public class TestSortingMergePolicy extends LuceneTestCase {
public class TestSortingMergePolicy extends BaseMergePolicyTestCase {
private List<String> terms;
private Directory dir1, dir2;
@ -78,6 +78,10 @@ public class TestSortingMergePolicy extends LuceneTestCase {
return doc;
}
public MergePolicy mergePolicy() {
return newSortingMergePolicy(sort);
}
public static SortingMergePolicy newSortingMergePolicy(Sort sort) {
// usually create a MP with a low merge factor so that many merges happen
MergePolicy mp;
@ -113,7 +117,7 @@ public class TestSortingMergePolicy extends LuceneTestCase {
final long seed = random().nextLong();
final IndexWriterConfig iwc1 = newIndexWriterConfig(new MockAnalyzer(new Random(seed)));
final IndexWriterConfig iwc2 = newIndexWriterConfig(new MockAnalyzer(new Random(seed)));
iwc2.setMergePolicy(newSortingMergePolicy(sort));
iwc2.setMergePolicy(mergePolicy());
final RandomIndexWriter iw1 = new RandomIndexWriter(new Random(seed), dir1, iwc1);
final RandomIndexWriter iw2 = new RandomIndexWriter(new Random(seed), dir2, iwc2);
for (int i = 0; i < numDocs; ++i) {