[TEST] use CFS consistently to not trigger single segment merge without force flag

This commit is contained in:
Simon Willnauer 2014-08-23 16:40:21 +02:00
parent 06fb9ff761
commit 5f188d29fa
1 changed files with 11 additions and 1 deletions

View File

@ -31,6 +31,7 @@ import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.util.BloomFilter; import org.elasticsearch.common.util.BloomFilter;
import org.elasticsearch.index.codec.CodecService; import org.elasticsearch.index.codec.CodecService;
import org.elasticsearch.index.engine.Segment; import org.elasticsearch.index.engine.Segment;
import org.elasticsearch.index.merge.policy.AbstractMergePolicyProvider;
import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.Test; import org.junit.Test;
@ -40,6 +41,8 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
public class InternalEngineIntegrationTest extends ElasticsearchIntegrationTest { public class InternalEngineIntegrationTest extends ElasticsearchIntegrationTest {
@Test @Test
@ -135,7 +138,14 @@ public class InternalEngineIntegrationTest extends ElasticsearchIntegrationTest
} }
public void testForceOptimize() throws ExecutionException, InterruptedException { public void testForceOptimize() throws ExecutionException, InterruptedException {
client().admin().indices().prepareCreate("test").setSettings(ImmutableSettings.builder().put("number_of_replicas", 0).put("number_of_shards", 1)).get(); boolean compound = randomBoolean();
assertAcked(client().admin().indices().prepareCreate("test").setSettings(ImmutableSettings.builder()
.put("number_of_replicas", 0)
.put("number_of_shards", 1)
// this is important otherwise the MP will still trigger a merge even if there is only one segment
.put(InternalEngine.INDEX_COMPOUND_ON_FLUSH, compound)
.put(AbstractMergePolicyProvider.INDEX_COMPOUND_FORMAT, compound)
));
final int numDocs = randomIntBetween(10, 100); final int numDocs = randomIntBetween(10, 100);
IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs]; IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs];
for (int i = 0; i < builders.length; i++) { for (int i = 0; i < builders.length; i++) {